InstanceNode3D
Extends Autodesk.Viewing.Scene.Node3D
Scene graph node that represents a single geometry instance.
new InstanceNode3D(geometry, material)
Creates a new detached instance node based on the given geometry and material. The instance is created in the model when the node is added to an attached scene graph.
Parameters
| geometry | |
| material |
Properties
| instanceId number, null | The instance ID in the instance collection, or null while detached. |
| parent Node3D, null | Parent node in the scene graph, or null for the root. |
| children Array.<Node3D> | Direct child nodes. |
| position | Local position relative to the parent. |
| quaternion | Local rotation relative to the parent. |
| scale | Local scale relative to the parent. |
Methods
getTransformWorld(target)
Reads the world transform matrix into the optional target matrix. When attached, reads from the instance collection (source of truth). When detached, copies from detached state.
Parameters
| target | Matrix to write into. Recommended for allocation-free reads. |
Returns
| type | description |
|---|---|
| Matrix4 | The target filled with the world matrix, or a new matrix if no target is provided. |
getVisibilityState()
Returns
| type | description |
|---|---|
| VisibilityState | The visibility state. |
setVisibilityState(value)
Sets the visibility state for this node and its descendants.
Parameters
| value* |
getMaterial()
Returns
| type | description |
|---|---|
| Material | The material of the instance represented by this node. |
setMaterial(material)
Sets material on the instance represented by this node.
Parameters
| material* |
Returns
| type | description |
|---|---|
| boolean | true, if the material was successfully set |
getGeometry()
Returns
| type | description |
|---|---|
| BufferGeometry | The geometry of the instance represented by this node. |
setGeometry(geometry)
Sets the geometry of the instance represented by this node.
Parameters
| geometry* |
Returns
| type | description |
|---|---|
| boolean | true, if the geometry was successfully set |
updateTransformWorld(force)
Updates the world transform matrix for this node and writes it to the represented instance. Computations are performed immediately and propagated to all affected descendants.
Parameters
| force boolean | If true, forces update regardless of the dirty flag. |
fromInstance(instanceId, modelOrParentNode)
Static method to create a new node from an existing instance in the instance collection.
Parameters
Returns
| type | description |
|---|---|
| InstanceNode3D | The new node. |
getTransformLocal(target)
Computes the local transform matrix for this node.
Parameters
| target | Matrix to write into. |
Returns
| type | description |
|---|---|
| Matrix4 | The target filled with the local matrix, or a new matrix if no target is provided. |
markDirty()
Marks this node as needing a world matrix update. Call this after modifying position, quaternion, or scale when using dirty tracking.
isAttached()
Returns
| type | description |
|---|---|
| boolean | True if the node is attached to a model’s instance collection, false otherwise. |
remove(children)
Removes the given child nodes from this node and from the instance collection.
Parameters
| children* Node3D, Array.<Node3D> |
Returns
| type | description |
|---|---|
| Node3D | A reference to this node. |
removeFromParent()
Removes this node from its parent and the instance collection.
Returns
| type | description |
|---|---|
| Node3D | A reference to this node. |
traverse(callback)
Traverses this node and its descendants and calls the callback for each node.
Parameters
| callback* | Called once for this node and each descendant. |
add(children)
Adds child nodes. If a child already has a parent, it is removed from that parent first. Uninitialized children are attached to this node’s instance collection.
Parameters
| children* Node3D, Array.<Node3D> |
Returns
| type | description |
|---|---|
| Node3D | A reference to this node. |
clear()
Removes all children from this node.
Returns
| type | description |
|---|---|
| Node3D | A reference to this node. |