Represents a spatial transform within a !scene.SceneModel | SceneModel.

A SceneTransform defines a local coordinate space using position, rotation, and scale, and can be composed into a hierarchy of transforms. !scene.SceneMesh | SceneMesh instances are typically attached to transforms, allowing geometry to inherit transforms from parent nodes.

  • Transforms form a tree (scene graph) within a !scene.SceneModel | SceneModel
  • Each transform has an optional parent transform
  • Child transforms and meshes inherit the parent’s transform
  • Transforms can be authored using TRS (position / rotation / scale) or a matrix

Transforms are created via SceneModel.createTransform and referenced by ID. Meshes are attached to transforms, and meshes can then be grouped into !scene.SceneObject | SceneObjects for selection, visibility, and interaction.

// Create a root transform positioned in world space
sceneModel.createTransform({
id: "rootTransform",
position: [100000, 0, 0]
});

// Create a child transform for a table leg
sceneModel.createTransform({
id: "childTransform",
parentTransformId: "rootTransform",
position: [-4, -6, -4],
scale: [1, 3, 1]
});

// Create geometry
sceneModel.createGeometry({
id: "demoGeometry",
//...
});

// Attach a mesh to the transform
sceneModel.createMesh({
id: "redLegMesh",
geometryId: "demoGeometry",
parentTransformId: "childTransform",
color: [1, 0, 0]
});

// Group the mesh into a scene object
sceneModel.createObject({
id: "redLegObject",
meshIds: ["redLegMesh"]
});

// Update transforms dynamically (eg. animation)
const root = sceneModel.transforms["rootTransform"];
root.rotation = [0, performance.now() / 40, 0];
  • Setting position, rotation, quaternion, or scale updates the local transform.
  • Setting matrix directly replaces the local transform and updates TRS values.
  • Destroying a transform automatically detaches it from the hierarchy.

See @xeokit/sdk/model/scene for more complete examples.

Properties

destroyed: boolean = false

True once destroy has been called.

id: string

Unique identifier for this transform within the !scene.SceneModel | SceneModel.

model: SceneModel

The !scene.SceneModel | SceneModel this transform belongs to.

uniqueId: string

The global ID of this SceneTransform, unique among all SceneTransforms within the Scene, *

Accessors

Methods

  • Removes a child transform from this transform by ID (if it is currently parented here).

    When destroyed, logs an error and returns a failed result.

    Parameters

    • childTransformId: string

      ID of the child transform to remove.

    Returns SDKResult<any>

  • Sets the parent transform for this transform.

    Parameters

    • parentTransformId: string

      ID of the new parent transform, or null/undefined to unparent.

    • Optionalopts: { preserveWorld?: boolean }

      Options.

      • OptionalpreserveWorld?: boolean

        When true, keeps the world transform unchanged.

    Returns SDKResult<any>