WasmGPU.math.vec3.copy¶
Summary¶
WasmGPU.math.vec3.copy clones the input into a new array. Use it when you want an explicit copy before further edits.
Syntax¶
Precision-Specific Wasm Forms¶
WasmGPU.math.vec3f.copy(out: WasmPtr, v: WasmPtr): void
WasmGPU.math.vec3d.copy(out: WasmPtr, v: WasmPtr): void
These forms use caller-owned pointers to 3-element vector blocks in WasmGPU driver memory: binary32 for vec3f and binary64 for vec3d. 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 |
|---|---|---|---|
v |
number[] |
Yes | Vector input as [x, y, z]. |
Returns¶
number[] - New 3D vector as [x, y, z].
Type Details¶
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const v = [1, 2, 3];
const result = wgpu.math.vec3.copy(v);
console.log(result);