Skip to content
On this page

Class: Node

WebSG.Node

Class representing a node in a scene graph.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Node()

Properties

matrix

Readonly matrix: Matrix4

The node's local transformation matrix as a Matrix4.

Defined in

websg.d.ts:711


rotation

Readonly rotation: Quaternion

The node's rotation as a Quaternion.

Defined in

websg.d.ts:701


scale

Readonly scale: Vector3

The node's scale as a Vector3.

Defined in

websg.d.ts:706


translation

Readonly translation: Vector3

The node's translation as a Vector3.

Defined in

websg.d.ts:696


worldMatrix

Readonly worldMatrix: ReadonlyMatrix4

The node's world transformation matrix as a ReadonlyMatrix4.

Defined in

websg.d.ts:716

Accessors

collider

get collider(): undefined | Collider

Get the collider associated with this node.

Returns

undefined | Collider

Defined in

websg.d.ts:795

set collider(collider): void

Set the collider associated with this node.

Parameters

NameTypeDescription
colliderundefined | ColliderThe collider to associate with this node or undefined to unset.

Returns

void

Defined in

websg.d.ts:801


interactable

get interactable(): undefined | Interactable

Gets the interactable behavior associated with this node.

Returns

undefined | Interactable

Defined in

websg.d.ts:817


isStatic

get isStatic(): boolean

Gets or sets whether this node is static.

Returns

boolean

Defined in

websg.d.ts:749

set isStatic(value): void

Sets whether this node is static and can be optimized by the engine. Optimizations include world matrix calculations. When a node is static, you may not modify its transform properties (translation, rotation, scale).

Parameters

NameTypeDescription
valuebooleanWhether this node is static.

Returns

void

Defined in

websg.d.ts:757


light

get light(): undefined | Light

Get the light associated with this node.

Returns

undefined | Light

Defined in

websg.d.ts:784

set light(light): void

Set the light associated with this node.

Parameters

NameTypeDescription
lightundefined | LightThe light to associate with this node or undefined to unset.

Returns

void

Defined in

websg.d.ts:790


mesh

get mesh(): undefined | Mesh

Get the mesh associated with this node.

Returns

undefined | Mesh

Defined in

websg.d.ts:773

set mesh(mesh): void

Set the mesh associated with this node.

Parameters

NameTypeDescription
meshundefined | MeshThe mesh to associate with this node or undefined to unset.

Returns

void

Defined in

websg.d.ts:779


parent

get parent(): undefined | Node

Gets the parent node of this node or undefined if this node has no parent.

Returns

undefined | Node

Defined in

websg.d.ts:744


physicsBody

get physicsBody(): undefined | PhysicsBody

Gets the physics body behavior associated with this node.

Returns

undefined | PhysicsBody

Defined in

websg.d.ts:833


uiCanvas

get uiCanvas(): undefined | UICanvas

Get the UI canvas associated with this node.

Returns

undefined | UICanvas

Defined in

websg.d.ts:806

set uiCanvas(uiCanvas): void

Set the UI canvas associated with this node.

Parameters

NameTypeDescription
uiCanvasundefined | UICanvasThe UI canvas to associate with this node or undefined to unset.

Returns

void

Defined in

websg.d.ts:812


visible

get visible(): boolean

Returns whether or not this node is visible

Returns

boolean

Defined in

websg.d.ts:762

set visible(value): void

Sets whether or not this node is visible

Parameters

NameTypeDescription
valuebooleanWhether or not this node is visible

Returns

void

Defined in

websg.d.ts:768

Methods

addChild

addChild(node): Node

Adds a child node to this node.

Parameters

NameTypeDescription
nodeNodeThe node to add as a child.

Returns

Node

Defined in

websg.d.ts:722


addComponent

addComponent(component): undefined

Adds a component to this node.

Parameters

NameTypeDescription
componentComponentStorethe component type to add.

Returns

undefined

Defined in

websg.d.ts:855


addInteractable

addInteractable(props?): Interactable

Adds an interactable behavior to this node.

Parameters

NameTypeDescription
props?InteractablePropsOptional interactable properties.

Returns

Interactable

Defined in

websg.d.ts:823


addPhysicsBody

addPhysicsBody(props?): PhysicsBody

Adds a physics body behavior to this node.

Parameters

NameTypeDescription
props?PhysicsBodyPropsOptional physics body properties.

Returns

PhysicsBody

Defined in

websg.d.ts:839


children

children(): NodeIterator

Returns an iterator for the children of this node.

Returns

NodeIterator

Defined in

websg.d.ts:739


getChild

getChild(index): undefined | Node

Gets the child node at the specified index or undefined if the index is out of range.

Parameters

NameTypeDescription
indexnumberThe index of the child node.

Returns

undefined | Node

Defined in

websg.d.ts:734


getComponent

getComponent(component): undefined | Component

Gets an instance of a component of the specified type on this node. If the component does not exist on this node, it will return undefined.

Parameters

NameTypeDescription
componentComponentStorethe component type to get.

Returns

undefined | Component

Defined in

websg.d.ts:871


hasComponent

hasComponent(component): boolean

Checks if this node has a component.

Parameters

NameTypeDescription
componentComponentStorethe component type to check for.

Returns

boolean

Defined in

websg.d.ts:865


removeChild

removeChild(node): Node

Removes a child node from this node.

Parameters

NameTypeDescription
nodeNodeThe node to remove.

Returns

Node

Defined in

websg.d.ts:728


removeComponent

removeComponent(component): undefined

Removes a component from this node.

Parameters

NameTypeDescription
componentComponentStorethe component type to remove.

Returns

undefined

Defined in

websg.d.ts:860


removeInteractable

removeInteractable(): undefined

Removes the interactable property from this node.

Returns

undefined

Defined in

websg.d.ts:828


removePhysicsBody

removePhysicsBody(): undefined

Removes the physics body behavior from this node.

Returns

undefined

Defined in

websg.d.ts:844


startOrbit

startOrbit(options?): undefined

Enables orbit camera control mode for this node.

Parameters

NameTypeDescription
options?OrbitOptionsOptional orbit options.

Returns

undefined

Defined in

websg.d.ts:850