UWAL / Camera2D
Classes
Camera2D
Camera manager class for scenes using 2D nodes and shapes.
Extends
Node2D
Properties
CullTest
ts
CullTest: 0 | 1 | 2 = 2;Defaults to axis-aligned bounding box.
Constructors
Constructor
ts
new Camera2D(rendererWidth?, height?): Camera2D;Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
rendererWidth? | number | RenderStage | innerWidth | Width of the viewport or a Renderer instance. |
height? | number | innerHeight | Height of the viewport, optional when called with a Renderer instance. |
Returns
Overrides
ts
Node2D.constructorMethods
UpdateProjectionMatrix()
ts
UpdateProjectionMatrix(): void;Compute the projection matrix and write the result into the corresponding uniform buffer if present.
Returns
void
SetRenderPipeline()
ts
SetRenderPipeline(Pipeline): GPUBuffer;Create and update an internal uniform buffer of this camera's projection matrix.
Parameters
| Parameter | Type | Description |
|---|---|---|
Pipeline | RenderPipelineInstance | Pipeline using this camera's projection. |
Returns
GPUBuffer
Contains()
ts
Contains(Shape): boolean;Check if a shape is contained in the camera's viewport when cull testing is performed. This method is called internally on every render when cull testing is enabled.
Parameters
| Parameter | Type | Description |
|---|---|---|
Shape | Shape | 2D shape to test for culling. |
Returns
boolean
Whether the shape is in the camera's viewport.
Destroy()
ts
Destroy(): void;Destroy the internal projection matrix buffer.
Returns
void
Accessors
MatrixBuffer
Get Signature
ts
get MatrixBuffer(): GPUBuffer | undefined;Returns
GPUBuffer | undefined
Matrix buffer created by the SetRenderPipeline method.
Size
Set Signature
ts
set Size(size): void;Parameters
| Parameter | Type | Description |
|---|---|---|
size | number[] | Float32Array<ArrayBufferLike> | Camera's viewport width and height. |
Returns
void
PositionZ
Set Signature
ts
set PositionZ(z): void;Parameters
| Parameter | Type | Description |
|---|---|---|
z | number | Camera's position on the Z-axis used in light calculations. |
Returns
void
Position3D
Get Signature
ts
get Position3D(): Float32Array<ArrayBufferLike>;Returns
Float32Array<ArrayBufferLike>
Camera's position in 3D space.