Contains a model's geometry and materials

See @xeokit/sdk/scene for usage.

Hierarchy (View Summary)

Properties

built: boolean

Indicates if this SceneModel has already been built.

destroyed: boolean

Indicates if this SceneModel has been destroyed.

  • Set true by SceneModel.destroy.
  • Don't create anything more in this SceneModel once it's destroyed.
dirty: boolean
edgeThreshold: number

The edge threshold for automatic edge primitive generation.

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.

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.

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.

objectsList: SceneObject[]

List of SceneObjects within this SceneModel.

rendererModel: RendererModel

Internal interface through which a SceneModel can load updated content into a renderers.

retained: boolean

Whether this SceneModel retains SceneObjects, SceneMeshes, SceneGeometries etc after we call SceneModel.build.

Default value is true.

scene: Scene

The Scene that contains this SceneModel.

Statistics on this SceneModel.

streamParams?: SceneModelStreamParams

Indicates what renderer resources will need to be allocated in a Viewer's Renderer to support progressive loading for the SceneModel.

See @xeokit/sdk/scene for usage.

textures: { [key: string]: SceneTexture }

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

textureSets: { [key: string]: SceneTextureSet }

TextureSets within this SceneModel, each mapped to SceneTextureSet.id.

tiles: { [key: string]: SceneTile }

The Tiles used by this SceneModel, each mapped to SceneTile.id.

tilesList: SceneTile[]

The Tiles used by this SceneModel.

Accessors

Methods

  • Finalizes this SceneModel, readying it for use.

    • Fires an event via SceneModel.onBuilt and SceneModel.onCreated, to indicate to subscribers that the SceneModel is complete and ready to use.
    • Sets SceneModel.built true.
    • You can only call this method once on a SceneModel.
    • The SceneModel must have at least one SceneObject.
    • Once built, no more components can be created in a SceneModel.
    sceneMode.onBuilt.subscribe(()=>{
    // Our SceneModel is built and ready to use
    });

    myScene.onModelCreated.subscribe((sceneModel)=>{
    // Another way to subscribe to SceneModel readiness
    });

    mySceneModel.build().then((result) => { // Asynchronous (texture compression etc).
    if (result instanceof SDKError) {
    console.log(result.message);
    } else {
    // Now we can do things with our SceneModel
    }
    }).catch(sdkError) {// SDKError
    console.log(sdkError.message);
    };

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

    Returns Promise<SceneModel>

    SDKError

    • If SceneModel has already been built or destroyed.
    • If no SceneObjects were created in this SceneModel.
  • Creates a new SceneGeometry within this SceneModel, from non-compressed geometry parameters.

    const boxGeometry = 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 (boxGeometry instanceof SDKError) {
    console.log(boxGeometry.message);
    } else {
    const boxGeometryAgain = sceneModel.geometries["boxGeometry"];
    }

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

    Parameters

    Returns SDKError | SceneGeometry

    SceneGeometry

    • On success.
  • Protected

    Logs an error for this component to the JavaScript console.

    The console message will have this format: [ERROR] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The error message to log

    Returns void

  • Protected

    Logs a message for this component.

    The message will have this format: [LOG] [<component type> <component id>: <message>

    Parameters

    • message: string

      The message to log

    Returns void

  • Protected

    Logs a warning for this component to the JavaScript console.

    The console message will have this format: [WARN] [<component type> =<component id>: <message>

    Parameters

    • message: string

      The warning message to log

    Returns void

Events

onBuilt: EventEmitter<SceneModel, null>

Emits an event when this SceneModel has been built.

onBuilt

onDestroyed: EventEmitter<SceneModel, null>

Emits an event when this SceneModel has been destroyed.

onDestroyed