Skip to content

CameraMaths beta ​

Class of @v12-engine/client/lite-views

ts
export declare class CameraMaths

The matrices of one camera at one size of its view, and what is asked of them: update works them out, the rest read them

Members ​

eye ​

ts
readonly eye: {
        x: number;
        y: number;
        z: number;
    };

Where the camera stands

forwardTo ​

ts
forwardTo(out: XYZ): XYZ;

The way the camera looks, of length 1, into out

groundAt ​

ts
groundAt(x: number, y: number, terrain: Terrain, reach?: number): Vec2 | null;

The ground under a point of the view, as it rises and falls: the ray it was found along is left in ray

height ​

ts
height: number;

Its height in CSS pixels

inverse ​

ts
readonly inverse: Mat4;

What undoes both: what a ray is made by

project ​

ts
project(x: number, y: number, z: number): {
        x: number;
        y: number;
    } | null;

Position in the view of a point of the world, or null when it is behind the camera: a new point each time

projection ​

ts
readonly projection: Mat4;

Its lens

projectTo ​

ts
projectTo(x: number, y: number, z: number, out: {
        x: number;
        y: number;
        z?: number;
    }): boolean;

Puts the position in the view of a point of the world into out, in CSS pixels from its top left, with its depth where out has a z. False, and out left alone, when it is behind the camera or past what it sees

ray ​

ts
readonly ray: PickRay;

The ray the ground under a point was last found along (groundAt): a pick reads it after

rayTo ​

ts
rayTo(x: number, y: number, out: PickRay): PickRay;

The ray of the world under a point of the view, into out

rightTo ​

ts
rightTo(out: Vec2): Vec2;

The camera's right along the ground, of length 1, into out: how wide a body is seen

update ​

ts
update(camera: ViewCamera, width: number, height: number, aspect?: number): this;

The matrices of a camera for a view width by height CSS pixels, aspect times as wide as high where its drawing pixels say otherwise than those do (the renderer's is canvas.width / canvas.height)

view ​

ts
readonly view: Mat4;

The world as the camera sees it

viewProjection ​

ts
readonly viewProjection: Mat4;

Both: what a point is projected by, without the renderer's jitter

width ​

ts
width: number;

The view's size in CSS pixels: what a point of the screen is measured in