Scene.clear¶
Summary¶
Scene.clear removes all meshes, point clouds, and glyph fields from the scene in one call. Light objects are not affected by this method. Use this when rebuilding object content while preserving lighting setup.
Syntax¶
Parameters¶
This method does not take parameters.
Returns¶
Scene - The same scene instance with object collections emptied.
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const scene = wgpu.createScene();
scene.add(wgpu.createMesh(wgpu.geometry.box(1, 1, 1), wgpu.material.unlit({ color: [0.9, 0.4, 0.2] })));
scene.add(wgpu.createMesh(wgpu.geometry.sphere(0.5, 16, 12), wgpu.material.unlit({ color: [0.2, 0.7, 1.0] })));
scene.clear();
console.log(scene.meshes.length);