Skip to main content

CameraProjection

@3dverse/livelink v0.8.10


@3dverse/livelink / CameraProjection

Class: CameraProjection

Defined in: livelink.js/sources/rendering/CameraProjection.ts:38

Holds the projection and transform matrices associated to a camera entity.

The data in this class is guaranteed to be synchronized with the frame being rendered. It accounts for the delays that occur between the remote server and the client. The data it holds come from the frame meta data that are provided along with the frame sent by the server.

As for the transform values in the camera entity, they are not guaranteed to be synchronized with the frame being rendered. This is because the camera entity can be updated at any time, and might be too recent to be used in the current frame.

In short, camera controllers should use the camera entity and frame drawers (RenderingSurface, Overlay, ...) should use the CameraProjection.

Constructors

new CameraProjection()

new CameraProjection(params): CameraProjection

Defined in: livelink.js/sources/rendering/CameraProjection.ts:125

Creates a new CameraProjection instance for the given camera entity and viewport.

Parameters

params

The parameters for the CameraProjection instance.

camera_entity

Entity

The entity that holds the camera and lens components.

viewport

Viewport

The viewport in which the camera is rendered.

Returns

CameraProjection

Throws

Error if the camera entity does not have a camera or lens component.

Properties

camera_entity

readonly camera_entity: Entity

Defined in: livelink.js/sources/rendering/CameraProjection.ts:42

The entity that holds the camera and lens components.


viewport

readonly viewport: Viewport

Defined in: livelink.js/sources/rendering/CameraProjection.ts:47

The viewport in which the camera is rendered.

Accessors

clip_from_view_matrix

Get Signature

get clip_from_view_matrix(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:77

Transformation matrix from view space to clip space, aka the projection matrix.

Returns

readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]


clip_from_world_matrix

Get Signature

get clip_from_world_matrix(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:84

Transformation matrix from world space to clip space, aka the model-view-projection matrix.

Returns

readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]


world_from_clip_matrix

Get Signature

get world_from_clip_matrix(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:91

Transformation matrix from clip space to world space, aka the inverse of model-view-projection matrix.

Returns

readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]


world_from_view_matrix

Get Signature

get world_from_view_matrix(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:98

Transformation matrix from view space to world space, aka the inverse of the view matrix.

Returns

readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]


world_position

Get Signature

get world_position(): readonly [number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:105

World space position of the camera as used to render the currently processed frame.

Returns

readonly [number, number, number]


world_orientation

Get Signature

get world_orientation(): readonly [number, number, number, number]

Defined in: livelink.js/sources/rendering/CameraProjection.ts:112

World space orientation of the camera as used to render the currently processed frame.

Returns

readonly [number, number, number, number]

Methods

projectWorldToClip()

projectWorldToClip(params): Vec3

Defined in: livelink.js/sources/rendering/CameraProjection.ts:164

Projects a world space position to clip space.

Parameters

params
world_position

Vec3

The position in world space to project.

out_clip_position

Vec3 = ...

The output position in clip space.

Returns

Vec3

The position in clip space.


projectClipToWorld()

projectClipToWorld(param): Vec3

Defined in: livelink.js/sources/rendering/CameraProjection.ts:184

Projects a clip space position to world space.

Parameters

param
clip_position

Vec3

The position in clip space to project.

out_world_position

Vec3 = ...

The output position in world space.

Returns

Vec3

The position in world space.


computeRayFromScreenPosition()

computeRayFromScreenPosition(param): Ray

Defined in: livelink.js/sources/rendering/CameraProjection.ts:204

Computes a ray from the camera origin to the given screen coordinates. (0, 0) is the top-left corner of the viewport, (1, 1) is the bottom-right corner.

Parameters

param
screen_position

Vec2

The screen coordinates to compute the ray from.

Returns

Ray

The ray.


computeRayFromClipPosition()

computeRayFromClipPosition(param): Ray

Defined in: livelink.js/sources/rendering/CameraProjection.ts:218

Computes a ray from the camera origin to the given clip coordinates. (-1, -1) is the bottom-left corner of the viewport, (1, 1) is the top-right corner.

Parameters

param
clip_position

Vec3

The clip coordinates to compute the ray from.

Returns

Ray

The ray.


updateProjectionMatrix()

updateProjectionMatrix(): void

Defined in: livelink.js/sources/rendering/CameraProjection.ts:299

Updates the projection matrix of the camera entity. This method should be called whenever the camera entity or viewport changes.

Returns

void