createTransform#getWorldRotation¶
Summary¶
createTransform#getWorldRotation composes the local quaternions from the root of the hierarchy to this node. Use it to match an object's orientation independently of parent scale, and pass a destination array to avoid allocating on each read.
Syntax¶
Transform.getWorldRotation(out?: number[]): number[]
const orientation = transform.getWorldRotation();
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
out |
number[] |
No | Reusable destination for [x, y, z, w]. |
Returns¶
number[] - A normalized world quaternion in the supplied array, or a new array if omitted. Invalid or near-zero local quaternions contribute identity. Calling on a disposed transform throws.
Example¶
const parent = wgpu.createTransform().setRotationFromEuler(0, Math.PI / 2, 0);
const child = wgpu.createTransform().setParent(parent);
const orientation = [0, 0, 0, 1];
child.getWorldRotation(orientation);
child.dispose();
parent.dispose();