Trying to understand the math behind the perspective matrix in WebGL
问题 All matrix libraries for WebGL have some sort of perspective function that you call to get the perspective matrix for the scene. For example, the perspective method within the mat4.js file that's part of gl-matrix is coded as such: mat4.perspective = function (out, fovy, aspect, near, far) { var f = 1.0 / Math.tan(fovy / 2), nf = 1 / (near - far); out[0] = f / aspect; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 0; out[5] = f; out[6] = 0; out[7] = 0; out[8] = 0; out[9] = 0; out[10] = (far +