Skip to content

UWAL / Scene

Type Aliases ​

SceneNode ​

ts
type SceneNode = Node2D | Node;

Type Parameters ​

Type Parameter

Camera ​

ts
type Camera = 
  | Camera2D
  | OrthographicCamera
  | PerspectiveCamera;

Type Parameters ​

Type Parameter

Classes ​

Scene ​

Content manager for objects rendered onto the canvas element. Used to add, search, update, and remove nodes, 2D shapes, and 3D meshes within the render pipeline.

Properties ​

Label ​
ts
Label: string;

Scene name.

Children ​
ts
Children: SceneNode[] = [];

List of all elements in the scene graph.

MainCamera ​
ts
MainCamera: Camera | undefined;

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

Constructors ​

Constructor ​
ts
new Scene(label?): Scene;
Parameters ​
ParameterTypeDefault valueDescription
label?string"Scene"Scene name.
Returns ​

Scene

Methods ​

Add() ​
ts
Add(children): void;

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

Parameters ​
ParameterTypeDescription
childrenSceneNode | SceneNode[]Element(s) 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[]Element(s) 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. The scene itself will be excluded from the iteration.

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

void

Destroy() ​
ts
Destroy(): void;

Call the Destroy method on every element of the scene graph if 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 the camera's view-projection matrix.

Released under the MIT License.