src/m4.js
function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) {
  dst = dst || new MatType(16);

  const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);
  const rangeInv = 1.0 / (zNear - zFar);

  dst[0]  = f / aspect;
  dst[1]  = 0;
  dst[2]  = 0;
  dst[3]  = 0;

  dst[4]  = 0;
  dst[5]  = f;
  dst[6]  = 0;
  dst[7]  = 0;

  dst[8]  = 0;
  dst[9]  = 0;
  dst[10] = (zNear + zFar) * rangeInv;
  dst[11] = -1;

  dst[12] = 0;
  dst[13] = 0;
  dst[14] = zNear * zFar * rangeInv * 2;
  dst[15] = 0;

  return dst;
}
function perspective(fieldOfViewYInRadians, aspect, zNear, zFar, dst) {
  dst = dst || new MatType(16);

  const f = Math.tan(Math.PI * 0.5 - 0.5 * fieldOfViewYInRadians);
  const rangeInv = 1.0 / (zNear - zFar);

  dst[0]  = f / aspect;
  dst[1]  = 0;
  dst[2]  = 0;
  dst[3]  = 0;

  dst[4]  = 0;
  dst[5]  = f;
  dst[6]  = 0;
  dst[7]  = 0;

  dst[8]  = 0;
  dst[9]  = 0;
  dst[10] = (zNear + zFar) * rangeInv;
  dst[11] = -1;

  dst[12] = 0;
  dst[13] = 0;
  dst[14] = zNear * zFar * rangeInv * 2;
  dst[15] = 0;

  return dst;
}
function perspective ( fieldOfViewYInRadians , aspect , zNear , zFar , dst ) { dst = dst || new MatType ( 16 ) ; const f = Math . tan ( Math . PI * 0.5 - 0.5 * fieldOfViewYInRadians ) ; const rangeInv = 1.0 / ( zNear - zFar ) ; dst [ 0 ] = f / aspect ; dst [ 1 ] = 0 ; dst [ 2 ] = 0 ; dst [ 3 ] = 0 ; dst [ 4 ] = 0 ; dst [ 5 ] = f ; dst [ 6 ] = 0 ; dst [ 7 ] = 0 ; dst [ 8 ] = 0 ; dst [ 9 ] = 0 ; dst [ 10 ] = ( zNear + zFar ) * rangeInv ; dst [ 11 ] = - 1 ; dst [ 12 ] = 0 ; dst [ 13 ] = 0 ; dst [ 14 ] = zNear * zFar * rangeInv * 2 ; dst [ 15 ] = 0 ; return dst ; }
Computes a 4-by-4 perspective transformation matrix given the angular height
of the frustum, the aspect ratio, and the near and far clipping planes.  The
arguments define a frustum extending in the negative z direction.  The given
angle is the vertical angle of the frustum, and the horizontal angle is
determined to produce the given aspect ratio.  The arguments near and far are
the distances to the near and far clipping planes.  Note that near and far
are not z coordinates, but rather they are distances along the negative
z-axis.  The matrix generated sends the viewing frustum to the unit box.
We assume a unit box extending from -1 to 1 in the x and y dimensions and
from 0 to 1 in the z dimension.
@param {number} fieldOfViewYInRadians The camera angle from top to bottom (in radians).
@param {number} aspect The aspect ratio width / height.
@param {number} zNear The depth (negative z coordinate)
of the near clipping plane.
@param {number} zFar The depth (negative z coordinate)
of the far clipping plane.
@param {module:twgl/m4.Mat4} [dst] matrix to hold result. If none new one is created..
@return {module:twgl/m4.Mat4} The perspective matrix.
@memberOf module:twgl/m4
Computes a 4 - by - 4 perspective transformation matrix given the angular height of the frustum the aspect ratio and the near and far clipping planes . The arguments define a frustum extending in the negative z direction . The given angle is the vertical angle of the frustum and the horizontal angle is determined to produce the given aspect ratio . The arguments near and far are the distances to the near and far clipping planes . Note that near and far are not z coordinates but rather they are distances along the negative z - axis . The matrix generated sends the viewing frustum to the unit box . We assume a unit box extending from - 1 to 1 in the x and y dimensions and from 0 to 1 in the z dimension .