should compute perspective1ms ‣
const fov = 2;
const aspect = 4;
const zNear = 10;
const zFar = 30;
const f = Math.tan(Math.PI * 0.5 - 0.5 * fov);
const rangeInv = 1.0 / (zNear - zFar);
const expected = [
f / aspect,
0,
0,
0,
0,
f,
0,
0,
0,
0,
zFar * rangeInv,
-1,
0,
0,
zNear * zFar * rangeInv,
0,
];
testMat4WithAndWithoutDest((newDst) => {
return mat4.perspective(fov, aspect, zNear, zFar, newDst);
}, expected);
should compute perspective with zFar at infinity0ms ‣
const fov = 2;
const aspect = 4;
const zNear = 10;
const zFar = Infinity;
const f = Math.tan(Math.PI * 0.5 - 0.5 * fov);
const expected = [
f / aspect,
0,
0,
0,
0,
f,
0,
0,
0,
0,
-1,
-1,
0,
0,
-zNear,
0,
];
testMat4WithAndWithoutDest((newDst) => {
return mat4.perspective(fov, aspect, zNear, zFar, newDst);
}, expected);
should compute perspective reverseZ with zFar0ms ‣
const fov = 2;
const aspect = 4;
const zNear = 10;
const zFar = 20;
const f = Math.tan(Math.PI * 0.5 - 0.5 * fov);
const rangeInv = 1 / (zFar - zNear);
const expected = [
f / aspect,
0,
0,
0,
0,
f,
0,
0,
0,
0,
zNear * rangeInv,
-1,
0,
0,
zFar * zNear * rangeInv,
0,
];
testMat4WithAndWithoutDest((newDst) => {
return mat4.perspectiveReverseZ(fov, aspect, zNear, zFar, newDst);
}, expected);
should compute perspective reverseZ with zFar at infinity0ms ‣
const fov = 2;
const aspect = 4;
const zNear = 10;
const zFar = Infinity;
const f = Math.tan(Math.PI * 0.5 - 0.5 * fov);
const expected = [
f / aspect,
0,
0,
0,
0,
f,
0,
0,
0,
0,
0,
-1,
0,
0,
zNear,
0,
];
testMat4WithAndWithoutDest((newDst) => {
return mat4.perspectiveReverseZ(fov, aspect, zNear, zFar, newDst);
}, expected);