Core scene-graph types and APIs for constructing, inspecting, importing, exporting,
and rendering 3D content in xeokit.
This module defines xeokit’s primary in-memory scene graph model. It provides a
structured, extensible representation of 3D content that is designed to work
consistently in both browsers and Node.js.
The scene graph is deliberately buildable and serializable:
Content can be created programmatically using builder-style APIs.
Models can be imported from and exported to multiple industry formats
(eg. gltf, las, cityjson, xgf, dotbim, ifc).
SceneModels can be serialized to JSON and reconstructed later.
A Scene can be attached to a Viewer for interactive
rendering, or used headlessly in Node.js for conversion and processing workflows.
The SceneEvents system exposes lifecycle and error events, allowing applications
to observe and react to changes as models, objects, and resources are created or destroyed.
A Scene uses a CoordinateSystem to specify its basis, units, origin, and scale. Each
SceneModel can also have its own CoordinateSystem, enabling models from various sources
to be combined without prior conversion. The SDK manages coordinate system transformations
automatically during rendering and interaction, preserving each model’s original data.
Installation
npminstall@xeokit/sdk
Quick Start (Tutorial)
This tutorial builds a simple “table” model (5 parts), attaches a Viewer, and shows how to read back created components.
4) Configure the Scene coordinate system (optional)
The Scene coordinate system is configured via Scene.coordinateSystem. By default, the Scene uses a
right-handed Z-Up coordinate system.
Each SceneModel may also specify its own SceneModel.coordinateSystem, allowing you to mix models
that originate in different coordinate systems without pre-processing them into a single common basis.
Example: set the Scene to a left-handed, Y-Up basis:
A Scene is renderer-agnostic. In Node.js you typically build/convert/export without rendering.
In the browser, attach the Scene to a Viewer and WebGLRenderer.
// 4) Create objects (logical entities). Each SceneObject references one or more meshes. sceneModel.createObject({ id:"redLegObject", meshIds: ["redLegMesh"] }); sceneModel.createObject({ id:"greenLegObject", meshIds: ["greenLegMesh"] }); sceneModel.createObject({ id:"blueLegObject", meshIds: ["blueLegMesh"] }); sceneModel.createObject({ id:"yellowLegObject", meshIds: ["yellowLegMesh"] }); sceneModel.createObject({ id:"tableTopObject", meshIds: ["tableTopMesh"] });
// SceneModel is now ready for use (rendering, picking, exporting, etc).
7) Read back components you created
The SceneModel stores its components in dictionaries keyed by ID.
Note: the Scene also indexes objects globally by ID, so you can access an object through either the model or the scene.
If you want faster SceneModel creation (or you already have geometry data offline), you can pre-compress
parameters using compressGeometryParams, then create geometry from those compressed parameters using
SceneModel.createGeometryCompressed.
exporter.write({ sceneModel, dataModel, version:"1.1.0"// Optional; defaults to the latest supported version }).then(fileData=> { // Use fileData as needed }).catch(err=> { console.error(err); });
Importing a SceneModel from a file
Import SceneModels from several formats. For example, load DotBIM using
DotBIMLoader:
xeokit Scene (Buildable 3D Scene Representation)
Core scene-graph types and APIs for constructing, inspecting, importing, exporting, and rendering 3D content in xeokit.
This module defines xeokit’s primary in-memory scene graph model. It provides a structured, extensible representation of 3D content that is designed to work consistently in both browsers and Node.js.
At its core:
The scene graph is deliberately buildable and serializable:
The SceneEvents system exposes lifecycle and error events, allowing applications to observe and react to changes as models, objects, and resources are created or destroyed.
A Scene uses a CoordinateSystem to specify its basis, units, origin, and scale. Each SceneModel can also have its own CoordinateSystem, enabling models from various sources to be combined without prior conversion. The SDK manages coordinate system transformations automatically during rendering and interaction, preserving each model’s original data.
Installation
Quick Start (Tutorial)
This tutorial builds a simple “table” model (5 parts), attaches a Viewer, and shows how to read back created components.
1) Import the modules you’ll use
2) Create a Scene
3) Subscribe to Scene lifecycle events (optional)
Everything that happens in a Scene is reported via the SceneEvents dispatcher at Scene.events.
4) Configure the Scene coordinate system (optional)
The Scene coordinate system is configured via Scene.coordinateSystem. By default, the Scene uses a right-handed Z-Up coordinate system.
Each SceneModel may also specify its own SceneModel.coordinateSystem, allowing you to mix models that originate in different coordinate systems without pre-processing them into a single common basis.
Example: set the Scene to a left-handed, Y-Up basis:
5) Attach a Viewer (browser only)
A Scene is renderer-agnostic. In Node.js you typically build/convert/export without rendering. In the browser, attach the Scene to a Viewer and WebGLRenderer.
A minimal setup uses:
6) Build a SceneModel (a simple “table”)
Next we create a SceneModel and populate it with:
We’ll also set a local coordinate system for this SceneModel (optional).
7) Read back components you created
The SceneModel stores its components in dictionaries keyed by ID. Note: the Scene also indexes objects globally by ID, so you can access an object through either the model or the scene.
Using Compressed Geometry
When you create a SceneGeometry via SceneModel.createGeometry, the SDK may perform on-the-fly processing and compression of geometry parameters.
If you want faster SceneModel creation (or you already have geometry data offline), you can pre-compress parameters using compressGeometryParams, then create geometry from those compressed parameters using SceneModel.createGeometryCompressed.
In the example below, compressGeometryParams converts SceneGeometryParams into SceneGeometryCompressedParams:
A SceneGeometryCompressedParams typically includes:
aabb) used to de-quantize in the ViewerCreate geometry from the compressed parameters:
Exporting a SceneModel to a file
SceneModels can be exported to several formats. For example, export to DotBIM with
DotBIMExporter:Importing a SceneModel from a file
Import SceneModels from several formats. For example, load DotBIM using
DotBIMLoader:Serializing a SceneModel to JSON
Deserializing a SceneModel from JSON
Destroying a SceneModel