Skip to main content

Scene.INode

Scene Node

A scene node is an object with a 3D transform: position, rotation, and scale. It can contain a collection of components and manages their life cycle.

A scene node has the following states:

Initializing - after construction but before start has been called

Updating - after start has been called but before stop has been called

Destroyed - after stop has been called

Components can only be added during the Initializing state. A scene node cannot be restarted.

const [sceneObject] = await sdk.Scene.createObjects(1);
const node = sceneObject.addNode();
node.addComponent('mp.gltfLoader', {
url: 'http://www.someModelSite.com/rabbit.gltf'
});

node.position.set(0, 1, 0);
node.start();

Setting the position, rotation, or scale of a scene node affects child components.

Properties

id

id: (readonly) string

A read-only unique id used to reference this node in a path binding. This id is autogenerated unless it is specifed and created via the Scene.Object.

name

name: string

The node name.

position

position: (readonly) THREE.Vector3

The scene node position. You can call methods on this object to set its values. See {@link https://threejs.org/docs/#api/en/math/Vector3}

quaternion

quaternion: (readonly) THREE.Quaternion

The scene node rotation. You can call methods on this object to set its values. See {@link https://threejs.org/docs/#api/en/math/Quaternion}

scale

scale: (readonly) THREE.Vector3

The scene node scale vector. You can call methods on this object to set its values. See {@link https://threejs.org/docs/#api/en/math/Vector3}

Methods

addComponent

addComponent(name: T, initialInputs?: SceneComponentOptions[T], id?: string): Scene.IComponent

Instantiates a component and adds it to the nodes internal component list. This function does nothing if the node is in the Operating or Destroyed state.

ParameterType
nameT
The registered component name.
initialInputs?SceneComponentOptions[T]
initial key-value pairs that will be applied to the component before onInit is called. If the keys do not match the components inputs, they are ignored.
id?string
an optional id for this component, if not specified an id will be computed for the component.

Returns: Scene.IComponent

The newly created component.

componentIterator

componentIterator(): IterableIterator<Scene.IComponent>

Returns in iterator iterating over all the components contained by this node.

Returns: IterableIterator<Scene.IComponent>

start

start(): void

Transitions the node to Operating if it is in the Initializing state. Calling this function has no effect if the node is already Operating.

stop

stop(): void

Transitions the node to Destroyed state if it is in any state. Calling this function has no effect if the node is already Destroyed.