CameraProjection
Defined in: livelink.js/sources/rendering/CameraProjection.ts:41
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: {
camera_entity: Entity;
viewport: Viewport;
}): CameraProjection
Defined in: livelink.js/sources/rendering/CameraProjection.ts:140
Creates a new CameraProjection instance for the given camera entity and viewport.
Parameters
Parameter | Type | Description |
---|---|---|
params | { camera_entity : Entity ; viewport : Viewport ; } | The parameters for the CameraProjection instance. |
params.camera_entity | Entity | The entity that holds the camera and lens components. |
params.viewport | Viewport | The viewport in which the camera is rendered. |
Returns
Throws
Error if the camera entity does not have a camera or lens component.
Properties
Property | Modifier | Type | Description |
---|---|---|---|
camera_entity | readonly | Entity | The entity that holds the camera and lens components. |
viewport | readonly | Viewport | 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:85
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
]
view_from_clip_matrix
Get Signature
get view_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:92
Transformation matrix from clip space to view space, aka the inverse of 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:99
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:106
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:113
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:120
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:127
World space orientation of the camera as used to render the currently processed frame.
Returns
readonly [number
, number
, number
, number
]
Methods
projectWorldToClip()
projectWorldToClip(params: {
world_position: Vec3;
out_clip_position: Vec3;
}): Vec3
Defined in: livelink.js/sources/rendering/CameraProjection.ts:181
Projects a world space position to clip space.
Parameters
Parameter | Type | Description |
---|---|---|
params | { world_position : Vec3 ; out_clip_position : Vec3 ; } | |
params.world_position | Vec3 | The position in world space to project. |
params.out_clip_position ? | Vec3 | The output position in clip space. |
Returns
The position in clip space.
projectClipToWorld()
projectClipToWorld(param: {
clip_position: Vec3;
out_world_position: Vec3;
}): Vec3
Defined in: livelink.js/sources/rendering/CameraProjection.ts:201
Projects a clip space position to world space.
Parameters
Parameter | Type | Description |
---|---|---|
param | { clip_position : Vec3 ; out_world_position : Vec3 ; } | |
param.clip_position | Vec3 | The position in clip space to project. |
param.out_world_position ? | Vec3 | The output position in world space. |
Returns
The position in world space.
computeRayFromScreenPosition()
computeRayFromScreenPosition(param: {
screen_position: Vec2;
}): Ray
Defined in: livelink.js/sources/rendering/CameraProjection.ts:221
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
Parameter | Type | Description |
---|---|---|
param | { screen_position : Vec2 ; } | |
param.screen_position | Vec2 | The screen coordinates to compute the ray from. |
Returns
The ray.
computeRayFromClipPosition()
computeRayFromClipPosition(param: {
clip_position: Vec3;
}): Ray
Defined in: livelink.js/sources/rendering/CameraProjection.ts:235
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
Parameter | Type | Description |
---|---|---|
param | { clip_position : Vec3 ; } | |
param.clip_position | Vec3 | The clip coordinates to compute the ray from. |
Returns
The ray.
updateProjectionMatrix()
updateProjectionMatrix(): void
Defined in: livelink.js/sources/rendering/CameraProjection.ts:316
Updates the projection matrix of the camera entity. This method should be called whenever the camera entity or viewport changes.
Returns
void