Creates a new mat4 initialized with values from an existing matrix
matrix to clone
a new 4x4 matrix
Creates a new identity mat4
a new 4x4 matrix
Calculates the determinant of a mat4
the source matrix
determinant of a
Returns whether or not the matrices have approximately the same elements in the same position.
The first matrix.
The second matrix.
True if the matrices are equal, false otherwise.
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
The first matrix.
The second matrix.
True if the matrices are equal, false otherwise.
Returns Frobenius norm of a mat4
the matrix to calculate Frobenius norm of
Frobenius norm
Creates a matrix from a given angle around a given axis This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.rotate(dest, dest, rad, axis);
mat4 receiving operation result
the angle to rotate the matrix by
the axis to rotate around
out
Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4 receiving operation result
Rotation quaternion
Translation vector
out
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
mat4 receiving operation result
Rotation quaternion
Translation vector
Scaling vector
out
Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin This is equivalent to (but much faster than):
mat4.identity(dest);
mat4.translate(dest, vec);
mat4.translate(dest, origin);
let quatMat = mat4.create();
quat4.toMat4(quat, quatMat);
mat4.multiply(dest, quatMat);
mat4.scale(dest, scale)
mat4.translate(dest, negativeOrigin);
mat4 receiving operation result
Rotation quaternion
Translation vector
Scaling vector
The origin vector around which to scale and rotate
out
Create a new mat4 with the given values
Component in column 0, row 0 position (index 0)
Component in column 0, row 1 position (index 1)
Component in column 0, row 2 position (index 2)
Component in column 0, row 3 position (index 3)
Component in column 1, row 0 position (index 4)
Component in column 1, row 1 position (index 5)
Component in column 1, row 2 position (index 6)
Component in column 1, row 3 position (index 7)
Component in column 2, row 0 position (index 8)
Component in column 2, row 1 position (index 9)
Component in column 2, row 2 position (index 10)
Component in column 2, row 3 position (index 11)
Component in column 3, row 0 position (index 12)
Component in column 3, row 1 position (index 13)
Component in column 3, row 2 position (index 14)
Component in column 3, row 3 position (index 15)
A new mat4
Generates a frustum matrix with the given bounds
mat4 frustum matrix will be written into
Left bound of the frustum
Right bound of the frustum
Bottom bound of the frustum
Top bound of the frustum
Near bound of the frustum
Far bound of the frustum
out
Returns a quaternion representing the rotational component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned quaternion will be the same as the quaternion originally supplied.
Quaternion to receive the rotation component
Matrix to be decomposed (input)
out
Returns the scaling factor component of a transformation matrix. If a matrix is built with fromRotationTranslationScale with a normalized Quaternion paramter, the returned vector will be the same as the scaling vector originally supplied.
Vector to receive scaling factor component
Matrix to be decomposed (input)
out
Returns the translation vector component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned vector will be the same as the translation vector originally supplied.
Vector to receive translation component
Matrix to be decomposed (input)
out
Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
mat4 frustum matrix will be written into
Position of the viewer
Point the viewer is looking at
vec3 pointing up
out
Generates a orthogonal projection matrix with the given bounds
mat4 frustum matrix will be written into
Left bound of the frustum
Right bound of the frustum
Bottom bound of the frustum
Top bound of the frustum
Near bound of the frustum
Far bound of the frustum
out
Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.
mat4 frustum matrix will be written into
Vertical field of view in radians
Aspect ratio. typically viewport width/height
Near bound of the frustum
Far bound of the frustum, can be null or Infinity
out
Generates a perspective projection matrix with the given field of view. This is primarily useful for generating projection matrices to be used with the still experiemental WebVR API.
mat4 frustum matrix will be written into
Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
Near bound of the frustum
Far bound of the frustum
out
Set the components of a mat4 to the given values
the receiving matrix
Component in column 0, row 0 position (index 0)
Component in column 0, row 1 position (index 1)
Component in column 0, row 2 position (index 2)
Component in column 0, row 3 position (index 3)
Component in column 1, row 0 position (index 4)
Component in column 1, row 1 position (index 5)
Component in column 1, row 2 position (index 6)
Component in column 1, row 3 position (index 7)
Component in column 2, row 0 position (index 8)
Component in column 2, row 1 position (index 9)
Component in column 2, row 2 position (index 10)
Component in column 2, row 3 position (index 11)
Component in column 3, row 0 position (index 12)
Component in column 3, row 1 position (index 13)
Component in column 3, row 2 position (index 14)
Component in column 3, row 3 position (index 15)
out
Returns a string representation of a mat4
matrix to represent as a string
string representation of the matrix
Adds two mat4's