Skip to content

UWAL / Scene

Type Aliases

Camera

ts
type Camera = Camera2D | PerspectiveCamera | OrthographicCamera;

Type Parameters

Type Parameter

SceneNode

ts
type SceneNode = Node | Node2D;

Type Parameters

Type Parameter

Classes

Scene

Content manager for the canvas element. Used to add, search, update and remove Nodes, 2D Shapes, and 3D Meshes within the rendering pipeline.

Properties

Label
ts
Label: string;

Name of the scene.

Children
ts
Children: SceneNode[] = [];

List of all elements in the scene graph.

MainCamera
ts
MainCamera: Camera | undefined;

Camera from whose point of view the scene will be rendered.

Constructors

Constructor
ts
new Scene(label?): Scene;
Parameters
ParameterTypeDefault valueDescription
label?string"Scene"Name of the scene
Returns

Scene

Methods

Add()
ts
Add(children): void;

Add any Mesh, Shape or SceneNode element(s) to the scene graph.

Parameters
ParameterTypeDescription
childrenSceneNode | SceneNode[]List of elements to add
Returns

void

Remove()
ts
Remove(children): void;

Remove any Mesh, Shape or SceneNode element(s) from the scene graph. Only unlinking is performed; the Destroy method on removed element(s) is not called.

Parameters
ParameterTypeDescription
childrenSceneNode | SceneNode[]List of elements to remove
Returns

void

AddMainCamera()
ts
AddMainCamera(camera): void;

Add a Camera as a child of the scene and assign it to the MainCamera property. To switch to a different camera, simply assign it to the MainCamera member.

Parameters
ParameterTypeDescription
cameraCameraCamera to use
Returns

void

See

Cameras / UV Mapping for reference.

UpdateWorldMatrix()
ts
UpdateWorldMatrix(): void;

Update local and world matrices of all elements in the scene graph. Its use is discouraged since this method is called internally on every render.

Returns

void

Traverse()
ts
Traverse(callback): void;

Perform the callback function on every element of the scene graph.
NOTE: The scene itself will be excluded from the iteration.

Parameters
ParameterTypeDescription
callback(node) => unknownFunction to call with the reference of the child element
Returns

void

Destroy()
ts
Destroy(): void;

Call the Destroy method on every element of the scene graph when available. Remove all children and reset the MainCamera member.

Returns

void

Accessors

WorldMatrix
Get Signature
ts
get WorldMatrix(): Float32Array<ArrayBufferLike>;
Returns

Float32Array<ArrayBufferLike>

The world matrix of the scene. Its use is discouraged since this getter is called internally when updating camera's view projection matrix.

Released under the MIT License.