The scene module stores 3D model content: geometry, textures, materials,
meshes, objects and transforms. It does not render by itself. Rendering is done
by attaching a Viewer and renderer such as
WebGLRenderer.
A Scene has a CoordinateSystem. Each SceneModel can also
define one. This lets one Scene contain models whose source data uses different
bases, units or origins.
Scene and SceneModel transforms use double-precision arrays on the CPU. Geometry
vertex arrays are single-precision. The WebGL renderer handles large world
coordinates with camera-relative matrices and tiled batches.
Creating a SceneModel
import { Scene } from"@xeokit/sdk/model/scene"; import { TrianglesPrimitive } from"@xeokit/sdk/base/constants";
Most SceneModels can use the defaults. When an application already knows more
about a model, it can describe that intent with updateMode and
loadingMode. Renderers can then choose storage and rendering policies that
fit the model, without adding renderer-specific settings to SceneModel.
updateMode describes how stable the
model's renderer-facing values are expected to be:
Renderer-facing values are the parts of the model that renderers cache,
upload or reorganize for drawing after the model has been created. Typical
examples are mesh transforms, object visibility and selection state, colors,
opacity, and other per-object or per-mesh values that can affect rendered
output without adding new geometry.
"auto" leaves the choice to the renderer.
"static" is for models whose renderer-facing values are mostly stable
after creation.
"dynamic" is for models whose transforms, colors or object state change
often after creation.
"open" is the default for ordinary authoring. Components can be added as
needed. commitBatch() works in this mode, but it is just a construction
boundary.
"streaming" is for models that arrive in repeated chunks or phases, such
as XGF Stream datasets. Each commitBatch() publishes another unit, and
renderers can keep stream-friendly storage available until the model is
sealed.
The separate sealed runtime state closes the model
to new topology. After seal(), beginBatch() and component creation calls
reject new content.
Size and interactivity tuning remain renderer decisions. For example, WebGPU
can combine updateMode, loadingMode, renderer profiles and observed model
size to choose compact pages, stream-friendly pages, culling and batch sizes.
Use seal when a model is complete and should reject
further topology/resource growth:
constsealRes = model.seal(); if (!sealRes.ok) thrownewError(sealRes.error);
For progressive construction of a single SceneModel, use batches when it is
useful to know which components were created during a named loading interval,
or when an importer needs to split loading into explicit phases. A batch can
stage a model file or file section and then publish it as a unit. Viewers and
renderers can defer partial batch content until commitBatch().
In loadingMode: "streaming" models, each commit means one more incremental
construction unit is ready while the model remains open for later units.
Batch IDs are SceneModel construction IDs; they do not define renderer draw
batches or XGF stream structure.
constbatchRes = model.beginBatch({ id:"storey-02" }); if (!batchRes.ok) thrownewError(batchRes.error);
Scene Graph
The scene module stores 3D model content: geometry, textures, materials, meshes, objects and transforms. It does not render by itself. Rendering is done by attaching a Viewer and renderer such as WebGLRenderer.
A Scene owns one or more SceneModels. A SceneModel contains shared resources (geometries, materials, textures) and instances (meshes, objects, transforms).
Structure
Main types:
Coordinate Systems
A Scene has a CoordinateSystem. Each SceneModel can also define one. This lets one Scene contain models whose source data uses different bases, units or origins.
Scene and SceneModel transforms use double-precision arrays on the CPU. Geometry vertex arrays are single-precision. The WebGL renderer handles large world coordinates with camera-relative matrices and tiled batches.
Creating a SceneModel
Components are indexed by id:
Update Mode and Loading Mode
Most SceneModels can use the defaults. When an application already knows more about a model, it can describe that intent with
updateModeandloadingMode. Renderers can then choose storage and rendering policies that fit the model, without adding renderer-specific settings to SceneModel.updateMode describes how stable the model's renderer-facing values are expected to be:
Renderer-facing values are the parts of the model that renderers cache, upload or reorganize for drawing after the model has been created. Typical examples are mesh transforms, object visibility and selection state, colors, opacity, and other per-object or per-mesh values that can affect rendered output without adding new geometry.
"auto"leaves the choice to the renderer."static"is for models whose renderer-facing values are mostly stable after creation."dynamic"is for models whose transforms, colors or object state change often after creation.loadingMode describes how the model is populated:
"open"is the default for ordinary authoring. Components can be added as needed.commitBatch()works in this mode, but it is just a construction boundary."streaming"is for models that arrive in repeated chunks or phases, such as XGF Stream datasets. EachcommitBatch()publishes another unit, and renderers can keep stream-friendly storage available until the model is sealed.The separate sealed runtime state closes the model to new topology. After
seal(),beginBatch()and component creation calls reject new content.Size and interactivity tuning remain renderer decisions. For example, WebGPU can combine
updateMode,loadingMode, renderer profiles and observed model size to choose compact pages, stream-friendly pages, culling and batch sizes.Use seal when a model is complete and should reject further topology/resource growth:
For progressive construction of a single SceneModel, use batches when it is useful to know which components were created during a named loading interval, or when an importer needs to split loading into explicit phases. A batch can stage a model file or file section and then publish it as a unit. Viewers and renderers can defer partial batch content until
commitBatch().In
loadingMode: "streaming"models, each commit means one more incremental construction unit is ready while the model remains open for later units. Batch IDs are SceneModel construction IDs; they do not define renderer draw batches or XGF stream structure.Rendering
Browser rendering is optional. A minimal setup uses a Scene, Viewer, WebGLRenderer, View and ModelNavigationController:
Compressed Geometry
Use compressGeometryParams when geometry has already been prepared for compact storage or faster SceneModel creation.
Dynamic Transforms
Meshes can reference SceneTransforms. Transforms can be nested and updated after creation.
Serialization
Import and Export
Format modules can load into, or export from, a SceneModel. For example, DotBIM:
Events and Lifecycle