createCamera.perspective#getProjectionMatrix¶
Summary¶
createCamera.perspective#getProjectionMatrix returns the current perspective projection matrix from fov, aspect, near, and far. The returned array is reused across calls, so copy it before modifying it or retaining a snapshot.
Syntax¶
Parameters¶
This method does not take parameters.
Returns¶
number[] - 4x4 perspective projection matrix in column-major array form.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const camera = wgpu.createCamera.perspective({
fov: 50,
aspect: canvas.clientWidth / canvas.clientHeight,
near: 0.1,
far: 1500
});
const projection = camera.getProjectionMatrix();
console.log(projection.length, projection);