How do I add a Frustum Clipping Plane to a Camera View Matrix? I'm confused on how to add it to the Camera Matrix so it clips the edges of the orthogonal view. The javascript has been extracted from a bigger application so it doesn't actually run in a sandbox. My apologies. If someone could provide a sandboxed example that I can convert into my code I'd be forever grateful as searching on the net for m4.frustum information returned little results.
var m4 = twgl.m4;
var zoom = 1;
var gridW = 17;
var gridH = 13;
var tilesize = 16;
var webglwidth = this.webgl.canvas.width / zoom;
var webglheight = this.webgl.canvas.height / zoom;
var screenW = gridW -2;
var screenH = gridH -2;
this.orthMatrix2 = m4.ortho(
0, 1,
0, 1,
0, -1);
var cameraMatrix = m4.rotationY(Math.PI);
cameraMatrix = m4.rotateZ(cameraMatrix, Math.PI);
var clipCameraW = -2;
var clipCameraH = -2;
cameraMatrix = m4.scale(cameraMatrix, [1/screenW, 1/screenH, 1]);
// Some Camera Translation shifting code here removed for readability.
cameraMatrix = m4.scale(cameraMatrix, [screenW, screenH, 1]);
// Here I want to make the Camera Frustum clip the edges so scrolling will be smooth.
//cameraFrustum = m4.frustum(1/this.camera.gridW,(screenW)/this.camera.gridW,
// 1/this.camera.gridH,(screenH)/this.camera.gridH,0,1); // ?
// cameraMatrix = m4.multiply(cameraMatrix, cameraFrustum); // ?
webgl.viewport(0,0, webgl.canvas.width, webgl.canvas.height);
var viewProjectionMatrix = m4.multiply(this.orthMatrix2, cameraMatrix);
// Final viewProjectionMatrix for webgl's uniformMatrix4fv.
// Call DrawArrays etc.