createTransform#getWorldPosition¶
Summary¶
createTransform#getWorldPosition reads the world-space translation after applying the parent hierarchy. Pass reusable storage when following an object or updating world-space labels each frame.
Syntax¶
Transform.getWorldPosition(out?: number[] | Float32Array): number[] | Float32Array
transform.getWorldPosition(position);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
out |
number[] | Float32Array |
No | Destination for [x, y, z]. Provide at least three entries for a typed array. |
Returns¶
number[] | Float32Array - The supplied array after writing its first three entries, or a fresh JavaScript array when omitted. Calling on a disposed transform throws.
Example¶
const parent = wgpu.createTransform().setPosition(10, 0, 0);
const child = wgpu.createTransform().setParent(parent).setPosition(0, 2, 0);
const position = new Float32Array(3);
child.getWorldPosition(position); // [10, 2, 0]
child.dispose();
parent.dispose();