WasmGPU.math.vec3.cross¶
Summary¶
WasmGPU.math.vec3.cross computes the 3D cross product of two vectors. The result is orthogonal to both inputs and oriented by right-hand rule.
Syntax¶
WasmGPU.math.vec3.cross(v1: number[], v2: number[]): number[]
const result = wgpu.math.vec3.cross(v1, v2);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
v1 |
number[] |
Yes | First vector input as [x, y, z]. |
v2 |
number[] |
Yes | Second 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 v1 = [1, -1, 0.5];
const v2 = [0, 1, 0];
const result = wgpu.math.vec3.cross(v1, v2);
console.log(result);