createMesh#transform¶
Summary¶
createMesh#transform is the placement of one mesh. Use it to position, rotate, or scale the mesh while reusing the same geometry across meshes.
Syntax¶
readonly Mesh.transform: Transform
readonly Mesh.geometry: Geometry
mesh.transform.setPosition(2, 0, 0);
Returns¶
Transform - The live transform owned by the mesh. Rendering and world bounds use its world matrix. Destroying the mesh disposes the transform and releases one reference to its geometry.
Example¶
const wgpu = await WasmGPU.create(document.querySelector("canvas"));
const mesh = wgpu.createMesh(wgpu.geometry.box(1), wgpu.material.unlit());
mesh.transform.setPosition(2, 0, 0);
console.log(mesh.transform.worldPosition); // [2, 0, 0]
mesh.destroy();
wgpu.destroy();
Notes¶
Use setParent to parent to another mesh. The geometry property exposes the shared object. Acquire a geometry reference with retain before giving it to another mesh.