frustum function

List<double> frustum(
  1. List<double> out,
  2. double left,
  3. double right,
  4. double bottom,
  5. double top,
  6. double near,
  7. double far,
)

Generates a frustum matrix with the given bounds

@param {mat4} out mat4 frustum matrix will be written into @param {Number} left Left bound of the frustum @param {Number} right Right bound of the frustum @param {Number} bottom Bottom bound of the frustum @param {Number} top Top bound of the frustum @param {Number} near Near bound of the frustum @param {Number} far Far bound of the frustum @returns {mat4} out

Implementation

List<double> frustum(List<double> out, double left, double right, double bottom, double top, double near, double far) {
  final rl = 1 / (right - left);
  final tb = 1 / (top - bottom);
  final nf = 1 / (near - far);
  out[0] = near * 2 * rl;
  out[1] = 0;
  out[2] = 0;
  out[3] = 0;
  out[4] = 0;
  out[5] = near * 2 * tb;
  out[6] = 0;
  out[7] = 0;
  out[8] = (right + left) * rl;
  out[9] = (top + bottom) * tb;
  out[10] = (far + near) * nf;
  out[11] = -1;
  out[12] = 0;
  out[13] = 0;
  out[14] = far * near * 2 * nf;
  out[15] = 0;
  return out;
}