Frustum(l,r,b,t,n,f) { var m = mat4(1); m[0][0] = 2 * n / (r - l); m[0][1] = 0; m[0][2] = (r + l) / (r - l); m[0][3] = 0; m[1][0] = 0; m[1][1] = 2 * n / (t - b); m[1][2] = (t + b) / (t - b); m[1][3] = 0; m[2][0] = 0; m[2][1] = 0; m[2][2] = -(f + n) / (f - n); m[2][3] = -2 * f * n / (f - n); m[3][0] = 0; m[3][1] = 0; m[3][2] = -1; m[3][3] = 0; return m; }
lookAt
function in MV.js.
var eye = lookAt([0,0,-1],[0,0,0],[0,1,0]); var proj = this.Frustum(-0.5,0.5,-0.5,0.5,1,20); proj = mult(proj,eye); this.gl.uniformMatrix4fv(this.projLoc, false,flatten(proj));