WasmGPU.math.quat.init¶
Summary¶
WasmGPU.math.quat.init creates a quaternion from explicit components. It is useful for importing or constructing known quaternion values.
Syntax¶
WasmGPU.math.quat.init(a: number, b: number, c: number, d: number): number[]
const result = wgpu.math.quat.init(a, b, c, d);
Precision-Specific Wasm Forms¶
WasmGPU.math.quatf.init(out: WasmPtr, x: number, y: number, z: number, w: number): void
WasmGPU.math.quatd.init(out: WasmPtr, x: number, y: number, z: number, w: number): void
These forms use caller-owned pointers to 4-element quaternion blocks in WasmGPU driver memory: binary32 for quatf and binary64 for quatd. Methods with an output pointer write that block instead of allocating a JavaScript array. See WasmGPU.math for allocation, views, aliasing, and release requirements.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
a |
number |
Yes | X component of the quaternion. |
b |
number |
Yes | Y component of the quaternion. |
c |
number |
Yes | Z component of the quaternion. |
d |
number |
Yes | W component of the quaternion. |
Returns¶
number[] - New quaternion as [x, y, z, w].
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const a = 0.0;
const b = 0.7071;
const c = 0.0;
const d = 0.7071;
const result = wgpu.math.quat.init(a, b, c, d);
console.log(result);