Class: Node
WebSG.Node
Class representing a node in a scene graph.
Table of contents
Constructors
Properties
Accessors
Methods
- addChild
- addComponent
- addInteractable
- addPhysicsBody
- children
- getChild
- getComponent
- hasComponent
- removeChild
- removeComponent
- removeInteractable
- removePhysicsBody
- startOrbit
Constructors
constructor
• new Node()
Properties
matrix
• Readonly matrix: Matrix4
The node's local transformation matrix as a Matrix4.
Defined in
rotation
• Readonly rotation: Quaternion
The node's rotation as a Quaternion.
Defined in
scale
• Readonly scale: Vector3
The node's scale as a Vector3.
Defined in
translation
• Readonly translation: Vector3
The node's translation as a Vector3.
Defined in
worldMatrix
• Readonly worldMatrix: ReadonlyMatrix4
The node's world transformation matrix as a ReadonlyMatrix4.
Defined in
Accessors
collider
• get collider(): undefined | Collider
Get the collider associated with this node.
Returns
undefined | Collider
Defined in
• set collider(collider): void
Set the collider associated with this node.
Parameters
| Name | Type | Description |
|---|---|---|
collider | undefined | Collider | The collider to associate with this node or undefined to unset. |
Returns
void
Defined in
interactable
• get interactable(): undefined | Interactable
Gets the interactable behavior associated with this node.
Returns
undefined | Interactable
Defined in
isStatic
• get isStatic(): boolean
Gets or sets whether this node is static.
Returns
boolean
Defined in
• 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
| Name | Type | Description |
|---|---|---|
value | boolean | Whether this node is static. |
Returns
void
Defined in
light
• get light(): undefined | Light
Get the light associated with this node.
Returns
undefined | Light
Defined in
• set light(light): void
Set the light associated with this node.
Parameters
| Name | Type | Description |
|---|---|---|
light | undefined | Light | The light to associate with this node or undefined to unset. |
Returns
void
Defined in
mesh
• get mesh(): undefined | Mesh
Get the mesh associated with this node.
Returns
undefined | Mesh
Defined in
• set mesh(mesh): void
Set the mesh associated with this node.
Parameters
| Name | Type | Description |
|---|---|---|
mesh | undefined | Mesh | The mesh to associate with this node or undefined to unset. |
Returns
void
Defined in
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
physicsBody
• get physicsBody(): undefined | PhysicsBody
Gets the physics body behavior associated with this node.
Returns
undefined | PhysicsBody
Defined in
uiCanvas
• get uiCanvas(): undefined | UICanvas
Get the UI canvas associated with this node.
Returns
undefined | UICanvas
Defined in
• set uiCanvas(uiCanvas): void
Set the UI canvas associated with this node.
Parameters
| Name | Type | Description |
|---|---|---|
uiCanvas | undefined | UICanvas | The UI canvas to associate with this node or undefined to unset. |
Returns
void
Defined in
visible
• get visible(): boolean
Returns whether or not this node is visible
Returns
boolean
Defined in
• set visible(value): void
Sets whether or not this node is visible
Parameters
| Name | Type | Description |
|---|---|---|
value | boolean | Whether or not this node is visible |
Returns
void
Defined in
Methods
addChild
▸ addChild(node): Node
Adds a child node to this node.
Parameters
| Name | Type | Description |
|---|---|---|
node | Node | The node to add as a child. |
Returns
Defined in
addComponent
▸ addComponent(component): undefined
Adds a component to this node.
Parameters
| Name | Type | Description |
|---|---|---|
component | ComponentStore | the component type to add. |
Returns
undefined
Defined in
addInteractable
▸ addInteractable(props?): Interactable
Adds an interactable behavior to this node.
Parameters
| Name | Type | Description |
|---|---|---|
props? | InteractableProps | Optional interactable properties. |
Returns
Defined in
addPhysicsBody
▸ addPhysicsBody(props?): PhysicsBody
Adds a physics body behavior to this node.
Parameters
| Name | Type | Description |
|---|---|---|
props? | PhysicsBodyProps | Optional physics body properties. |
Returns
Defined in
children
▸ children(): NodeIterator
Returns an iterator for the children of this node.
Returns
Defined in
getChild
▸ getChild(index): undefined | Node
Gets the child node at the specified index or undefined if the index is out of range.
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of the child node. |
Returns
undefined | Node
Defined in
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
| Name | Type | Description |
|---|---|---|
component | ComponentStore | the component type to get. |
Returns
undefined | Component
Defined in
hasComponent
▸ hasComponent(component): boolean
Checks if this node has a component.
Parameters
| Name | Type | Description |
|---|---|---|
component | ComponentStore | the component type to check for. |
Returns
boolean
Defined in
removeChild
▸ removeChild(node): Node
Removes a child node from this node.
Parameters
| Name | Type | Description |
|---|---|---|
node | Node | The node to remove. |
Returns
Defined in
removeComponent
▸ removeComponent(component): undefined
Removes a component from this node.
Parameters
| Name | Type | Description |
|---|---|---|
component | ComponentStore | the component type to remove. |
Returns
undefined
Defined in
removeInteractable
▸ removeInteractable(): undefined
Removes the interactable property from this node.
Returns
undefined
Defined in
removePhysicsBody
▸ removePhysicsBody(): undefined
Removes the physics body behavior from this node.
Returns
undefined
Defined in
startOrbit
▸ startOrbit(options?): undefined
Enables orbit camera control mode for this node.
Parameters
| Name | Type | Description |
|---|---|---|
options? | OrbitOptions | Optional orbit options. |
Returns
undefined