Scene.getBounds¶
Summary¶
Scene.getBounds computes an aggregate bounding volume from meshes, point clouds, glyph fields, and nodelinks. By default it only considers visible objects, so visible nodelinks are included automatically and hidden ones are skipped unless you pass visibleOnly: false. The result includes box and sphere bounds plus empty/partial flags.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
options |
SceneBoundsOptions |
No | Controls whether hidden objects are included in the aggregation. |
Returns¶
Bounds3 - Aggregated world-space bounds for the selected object subset.
Type Details¶
SceneBoundsOptions¶
SceneBoundsOptions Fields¶
| Name | Type | Required | Description |
|---|---|---|---|
visibleOnly |
boolean |
No | When true (default), ignore objects with visible === false across meshes, point clouds, glyph fields, and nodelinks. |
Vec3¶
Bounds3¶
type Bounds3 = {
boxMin: Vec3;
boxMax: Vec3;
sphereCenter: Vec3;
sphereRadius: number;
empty: boolean;
partial: boolean;
};
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const scene = wgpu.createScene();
scene.add(wgpu.createNodeLink({
nodePositions: new Float32Array([
-1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
1.0, 0.0, 0.0
]),
edges: new Uint16Array([
0, 1,
1, 2
])
}));
const visibleBounds = scene.getBounds();
const allBounds = scene.getBounds({ visibleOnly: false });
console.log(visibleBounds, allBounds);