PDA

View Full Version : gl.Frustr...ATION



SiPlus
10-29-2011, 08:02 AM
Khronos, when will you add glFrustum to WebGL standard?

VinceGL
11-03-2011, 04:48 AM
Never.

You have to do it yourself (calcule the matrix, send it to your projection mat).

function glFrustum(left, right, bottom, top, near, far) {
var rl = right-left, tb = top-bottom, fn = far-near;
<webgl context>.uniformMatrix4fv( <webgl projection uniform matrix>, false, Float32Array([
(near*2) / rl, 0, 0, 0,
0, (near*2) / tb, 0, 0,
(right + left) / rl, (top + bottom) / tb, -(far + near) / fn, -1,
0, 0, -(far*near*2) / fn, 0
]); );
};

I recommend you to use an existent matrix library in javascript (since I think you don't want to build your own).