createMesh#setParent¶
Summary¶
createMesh#setParent reparents this mesh's transform to another mesh or detaches it with null. It rejects self-parenting and cycles, preserves local—not world—transform values, and does not change either mesh's scene membership.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
parent |
Mesh \| null |
Yes | Parent mesh/transform reference; use null to detach. |
Returns¶
this - The same object instance, returned for fluent chaining.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const geometry = wgpu.geometry.box(1, 1, 1);
const material = wgpu.material.unlit({ color: [0.9, 0.6, 0.2], opacity: 1.0 });
const mesh = wgpu.createMesh(geometry, material);
const parent = null;
const result = mesh.setParent(parent);
console.log(result);