Scene.findByName¶
Summary¶
Scene.findByName returns the first mesh whose name exactly matches the input string. It searches only mesh objects, not point clouds or glyph fields. Use this for fast single-match lookup when names are unique.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Exact mesh name to search for. |
Returns¶
Mesh | undefined - First matching mesh, or undefined if no mesh has that name.
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const scene = wgpu.createScene();
const mesh = wgpu.createMesh(wgpu.geometry.box(1, 1, 1), wgpu.material.unlit({ color: [0.9, 0.4, 0.2] }));
mesh.name = "roi";
scene.add(mesh);
console.log(scene.findByName("roi"));