UWAL / Camera3D
Classes
abstract Camera3D
Base class for orthographic and perspective cameras.
Extends
Node
Extended by
Properties
CullTest
CullTest: 0 | 1 | 2 = 1;Defaults to bounding sphere.
AutoUpdateWorldMatrix
AutoUpdateWorldMatrix: boolean = false;Update the camera's view projection matrix every time the world matrix is updated.
Constructors
Constructor
new Camera3D(
near?,
far?,
label?): Camera3D;Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
near? | number | 1 | Distance to the near plane. |
far? | number | 1e3 | Distance to the far plane. |
label? | string | undefined | Camera name. |
Returns
Overrides
Node.constructorMethods
UpdateWorldMatrix()
UpdateWorldMatrix(force?): void;Update the camera's world matrix buffer. When the AutoUpdateWorldMatrix or force is true, the camera's world and view projection matrices are also updated.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
force? | boolean | false | Force the camera's matrices to be updated. |
Returns
void
Overrides
Node.UpdateWorldMatrixUpdateProjectionMatrix()
UpdateProjectionMatrix(): void;Write the computed projection matrix into the corresponding uniform buffer if present.
Returns
void
UpdateViewProjectionMatrix()
UpdateViewProjectionMatrix(updateWorldMatrix?): Float32Array<ArrayBufferLike>;Compute the view-projection matrix and write the result into the corresponding uniform buffer if present. This method also updates the camera's frustum planes used in cull testing.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
updateWorldMatrix? | boolean | true | Update the camera's world matrix. |
Returns
Float32Array<ArrayBufferLike>
GetInverseViewProjectionMatrix()
GetInverseViewProjectionMatrix(translation?, dst?): Float32Array<ArrayBufferLike>;Compute the inverse of the camera's view-projection matrix. Optionally, reset the translation component of the matrix before inverting it.
Parameters
| Parameter | Type | Description |
|---|---|---|
translation? | Float32Array<ArrayBufferLike> | If passed, set the matrix translation to this vector. |
dst? | Float32Array<ArrayBufferLike> | Destination matrix. A new one is created if omitted. |
Returns
Float32Array<ArrayBufferLike>
See
SkyBox lesson for reference.
LookAt()
LookAt(target, up?): void;Rotate the camera to point at the specified point in 3D space.
Parameters
| Parameter | Type | Description |
|---|---|---|
target | Float32Array<ArrayBufferLike> | Point in 3D space to look at. |
up? | Float32Array<ArrayBufferLike> | Camera's up vector. Defaults to [0, 1, 0]. |
Returns
void
SetRenderPipeline()
SetRenderPipeline(Pipeline): GPUBuffer;Create and update an internal uniform buffer of this camera's world, projection, and view-projection matrices.
Parameters
| Parameter | Type | Description |
|---|---|---|
Pipeline | RenderPipelineInstance | Pipeline using this camera's projection. |
Returns
GPUBuffer
Contains()
Contains(Mesh): boolean;Check if a mesh is contained in the camera's frustum when cull testing is performed. This method is called internally on every render when cull testing is enabled.
Parameters
| Parameter | Type | Description |
|---|---|---|
Mesh | Mesh | 3D mesh to test for culling. |
Returns
boolean
Whether the mesh is in the camera's frustum.
Destroy()
Destroy(): void;Destroy the internal matrices buffer.
Returns
void
Accessors
ViewProjectionMatrix
Get Signature
get ViewProjectionMatrix(): Float32Array<ArrayBufferLike>;Returns
Float32Array<ArrayBufferLike>
Camera's view projection matrix.
MatrixBuffer
Get Signature
get MatrixBuffer(): GPUBuffer | undefined;Returns
GPUBuffer | undefined
Matrix buffer created by the SetRenderPipeline method.
Near
Get Signature
get Near(): number;Returns
number
Distance to the near plane of the frustum.
Set Signature
set Near(near): void;Parameters
| Parameter | Type | Description |
|---|---|---|
near | number | Distance to the near plane. |
Returns
void
Far
Get Signature
get Far(): number;Returns
number
Distance to the far plane of the frustum.
Set Signature
set Far(far): void;Parameters
| Parameter | Type | Description |
|---|---|---|
far | number | Distance to the far plane. |
Returns
void