Request

Response

    Autodesk.Viewing.Scene
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    InstanceNode3D

    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

    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.
    positionLocal position relative to the parent.
    quaternionLocal rotation relative to the parent.
    scaleLocal 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

    targetMatrix to write into. Recommended for allocation-free reads.

    Returns

    typedescription
    Matrix4 The target filled with the world matrix, or a new matrix if no target is provided.

    getVisibilityState()

    Returns

    typedescription
    VisibilityState The visibility state.

    setVisibilityState(value)

    Sets the visibility state for this node and its descendants.

    Parameters

    value*
    * Required

    getMaterial()

    Returns

    typedescription
    Material, InternalMaterial The material of the instance represented by this node. Materials that are not part of the public API are returned as InternalMaterial.

    setMaterial(material)

    Sets material on the instance represented by this node.

    Parameters

    material*
    * Required

    Returns

    typedescription
    boolean true, if the material was successfully set

    getGeometry()

    Returns

    typedescription
    BufferGeometry The geometry of the instance represented by this node.

    setGeometry(geometry)

    Sets the geometry of the instance represented by this node.

    Parameters

    geometry*
    * Required

    Returns

    typedescription
    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

    instanceId*
    number
    modelOrParentNode*Parent node to which the new node is added. If a model is provided, the new node is added to the scene graph root.
    * Required

    Returns

    typedescription
    InstanceNode3D The new node.

    getTransformLocal(target)

    Computes the local transform matrix for this node.

    Parameters

    targetMatrix to write into.

    Returns

    typedescription
    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

    typedescription
    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>
    * Required

    Returns

    typedescription
    Node3D A reference to this node.

    removeFromParent()

    Removes this node from its parent and the instance collection.

    Returns

    typedescription
    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.
    * Required

    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>
    * Required

    Returns

    typedescription
    Node3D A reference to this node.

    clear()

    Removes all children from this node.

    Returns

    typedescription
    Node3D A reference to this node.