Contains a model's geometry and materials.

See @xeokit/sdk/model/scene for usage.

Properties

animations: { [key: string]: SceneAnimation }

Authored animation assets within this SceneModel.

coordinateSystem: CoordinateSystem

Configures the SceneModel's local coordinate system.

Internally, a matrix is created to transform coordinates between SceneModel and Scene CoordinateSystems. The matrix of each SceneMesh is premultiplied by that matrix, effectively transforming the SceneModel into the global coordinate system.

destroyed: boolean = false

Indicates if this SceneModel has been destroyed.

  • Set true by SceneModel.destroy.
  • Don't create anything more in this SceneModel once it's destroyed.
geometries: { [key: string]: SceneGeometry }

Geometries within this SceneModel, each mapped to SceneGeometry.id.

globalizedIds: boolean

Whether IDs of SceneObjects are globalized.

When globalized, the IDs are prefixed with the value of SceneModel.id

This is false by default.

headless: boolean

Whether this SceneModel is an invisible scratchpad.

Headless models are intended for offline/import/export work inside a Scene. Viewers, renderers and scene collision/AABB indexing ignore them.

id: string

Unique ID of this SceneModel.

SceneModel are stored against this ID in Scene.models.

layerId?: string

If we want to view this SceneModel with a Viewer, an optional ID of a ViewLayer to view it in.

materials: { [key: string]: SceneMaterial }

Materials within this SceneModel, each mapped to SceneMaterial.id.

meshes: { [key: string]: SceneMesh }

SceneMeshes within this SceneModel, each mapped to SceneMesh.id.

objects: { [key: string]: SceneObject }

SceneObjects within this SceneModel, each mapped to SceneObject.id.

repSets: { [key: string]: SceneRepSet }

Representation sets within this SceneModel, each mapped to SceneRepSet.id.

A representation set declares alternative groups of SceneObjects that represent the same logical content. It is generic model metadata and does not store the active representation for any view.

scene: Scene

The Scene that contains this SceneModel.

Statistics on this SceneModel.

Values are updated as content is created/destroyed:

  • numTransforms, numGeometries, numMeshes, numObjects
  • numVertices, numTriangles, numLines, numPoints
  • numTextures, numMaterials, textureBytes
textures: { [key: string]: SceneTexture }

Textures within this SceneModel, each mapped to SceneTexture.id.

transforms: { [key: string]: SceneTransform }

SceneTransforms within this SceneModel, each mapped to SceneTransform.id.

Accessors

  • get building(): boolean

    Whether this SceneModel is currently being populated by a loader.

    ModelLoader sets this true for the duration of a load and false when it finishes (or fails). The renderer observes the paired onSceneModelBuildStarted / onSceneModelBuildFinished events to suspend per-frame uploads + draws until the model is fully assembled, then renders it once — avoiding redundant mid-load frames.

    Setting the same value twice is a no-op (no event fired), so it's safe for a loader to clear it in a finally even on the error path.

    Returns boolean

  • set building(building: boolean): void

    Parameters

    • building: boolean

    Returns void

  • get coordinateSystemMatrix(): Mat4

    Caches a matrix used to transform positions between SceneModel and Scene CoordinateSystems. Each SceneMesh's matrix is pre-multiplied by this matrix to effectively move the vertex positions from the SceneModel CoordinateSystem to the Scene CoordinateSystem within.

    Returns Mat4

Methods

  • Returns true if this SceneModel currently holds at least one SceneGeometry of the given primitive type — e.g. model.containsPrimitive(GaussianSplatsPrimitive).

    Backed by a live per-primitive count maintained as geometries are created and destroyed, so it is O(1) and correct regardless of when geometries were added relative to the model's creation event.

    Parameters

    • primitive: number

    Returns boolean

  • Creates a new SceneGeometry within this SceneModel, from non-compressed geometry parameters.

    const boxGeometryResult = sceneModel.createGeometry({
    id: "boxGeometry",
    primitive: TrianglesPrimitive, // @xeokit/constants
    positions: [
    1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, // v0-v1-v2-v3 front
    1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, // v0-v3-v4-v1 right
    1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, // v0-v1-v6-v1 top
    -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, // v1-v6-v7-v2 left
    -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1,// v7-v4-v3-v2 bottom
    1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1 // v4-v7-v6-v1 back
    ],
    indices: [
    0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15,
    16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
    ]
    });

    if (!boxGeometryResult.ok) {
    console.error(boxGeometryResult.error);
    return;
    } else {
    const boxGeometry = boxGeometryResult.value;
    }

    const boxGeometryAgain = sceneModel.geometries["boxGeometry"];

    See @xeokit/sdk/model/scene for more usage info.

    geometryParams.positions supplies the current/base positions for ordinary static geometry. For fixed-topology frame sequences, callers may omit positions and provide frames; in that case frames[0].positions becomes the current/base geometry while all frames are retained on the created SceneGeometry.

    Parameters

    Returns SDKResult<SceneGeometry>

    SDKResult with:

    • On success, the created SceneGeometry.
    • On failure, an error message. Reasons for failure include:
      • If this SceneModel has already been destroyed.
      • Invalid SceneGeometryParams were given.
      • A SceneGeometry with the given ID already exists in this SceneModel.
      • Unsupported primitive type was provided.
      • Neither positions nor frames[0].positions were provided.
      • Frame arrays do not match the base vertex count.
      • Frame times are missing, non-finite or not strictly increasing.
      • Mandatory indices were not provided for primitive types other than PointsPrimitive.
      • Indices are out of range of vertex positions.
      • Indices are out of range of vertex UVs.
      • Mismatch between the quantities of vertex positions and UVs.
  • Creates a new SceneGeometry within this SceneModel, from pre-compressed geometry parameters.

    const boxGeometryResult = sceneModel.createGeometryCompressed({
    id: "boxGeometry",
    primitive: TrianglesPrimitive, // @xeokit/constants
    aabb: [-1,-1,-1, 1,1,1],
    positionsCompressed: [
    65525, 65525, 65525, 0, 65525, 65525, 0, 0,
    65525, 65525, 0, 65525, 65525, 0, 0, 65525,
    65525, 0, 0, 65525, 0, 0, 0, 0
    ],
    indices: [
    0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6,
    0, 6, 1, 1, 6, 7, 1, 7, 2, 7, 4, 3, 7, 3, 2,
    4, 7, 6, 4, 6, 5
    ]
    });

    if (!boxGeometryResult.ok) {
    console.error(boxGeometryResult.error);
    return;
    } else {
    const boxGeometry = boxGeometryResult.value;
    }

    See @xeokit/sdk/model/scene for more usage info.

    geometryCompressedParams.positionsCompressed and aabb supply the current/base compressed positions for ordinary static geometry. For fixed-topology frame sequences, callers may omit those top-level fields and provide framesCompressed; in that case framesCompressed[0].positionsCompressed and framesCompressed[0].aabb become the current/base geometry while all frames are retained on the created SceneGeometry.

    Parameters

    Returns SDKResult<SceneGeometry>

    SDKResult with:

    • On success, the created SceneGeometry.
    • On failure, an error message. Reasons for failure include:
      • If this SceneModel has already been destroyed.
      • Invalid SceneGeometryCompressedParams were given.
      • SceneGeometry of given ID already exists in this SceneModel.
      • Unsupported primitive type given.
      • Neither positionsCompressed nor framesCompressed[0].positionsCompressed were given.
      • Frame arrays do not match the base vertex count.
      • Frame times are missing, non-finite or not strictly increasing.
      • Mandatory indices were not given for primitive type that is not PointsPrimitive. Indices are mandatory for all primitive types except PointsPrimitive.
      • Indices out of range of vertex positions.
      • Indices out of range of vertex UVs.
      • Mismatch between given quantities of vertex positions and UVs.
  • Creates a representation set in this SceneModel.

    A representation set declares alternative representations of the same logical content. Each representation references SceneObjects by ID; it does not own those objects and does not reference raw geometry or mesh resources.

    The active representation is intentionally not stored on SceneModel. Future viewing-layer code can choose different representations for different views at the same time.

    Parameters

    Returns SDKResult<SceneRepSet>

    SDKResult with the created representation set, or an error when validation fails.

  • Creates a new SceneTexture within this SceneModel.

    const textureResult = sceneModel.createTexture({
    id: "myColorTexture",
    src: // Path to JPEG, PNG, KTX2,
    image: // HTMLImageElement,
    buffers: // ArrayBuffer[] containing KTX2 MIP levels
    preloadColor: [1,0,0,1],
    flipY: false,
    encoding: LinearEncoding, // @xeokit/constants
    magFilter: LinearFilter,
    minFilter: LinearFilter,
    wrapR: ClampToEdgeWrapping,
    wrapS: ClampToEdgeWrapping,
    wrapT: ClampToEdgeWrapping,
    });

    if (!textureResult.ok) {
    console.error(textureResult.error);
    return;
    } else {
    const texture = textureResult.value;
    }

    const textureAgain = sceneModel.textures["myColorTexture"];

    See @xeokit/sdk/model/scene for more usage info.

    Parameters

    Returns SDKResult<SceneTexture>

    SDKResult with:

    • On success, the created SceneTexture.
    • On failure, an error message. Reasons for failure include:
      • SceneModel already destroyed.
      • Missing required parameter: textureParams.imageData, textureParams.image, textureParams.src or textureParams.buffers.
      • Texture already exists with the given ID.
      • Unsupported image extension.
  • Creates a new SceneTransform within this SceneModel.

    Parameters

    Returns SDKResult<SceneTransform>

    An SDKResult with:

    • On success, the created SceneTransform.
    • On failure, an error message. Reasons for failure include:
      • SceneModel already destroyed.
      • SceneTransform already exists with the given ID.
      • Parent SceneTransform not found with the given parentTransformId.
    const rootTransformResult = sceneModel.createTransform({
    id: "root",
    position: [10, 0, 0]
    });

    if (!rootTransformResult.ok) {
    console.error(rootTransformResult.error);
    return;
    }

    const rootTransform = rootTransformResult.value;

    sceneModel.createTransform({
    id: "child",
    parentTransformId: "root",
    rotation: [0, Math.PI * 0.5, 0]
    });

    const childTransform = sceneModel.transforms["child"];
    childTransform.position = [0, 5, 0];
    childTransform.rotation =[0, 0, 45];