mat4 library

Constants

mul → const List<double> Function(List<double> out, List<double> a, List<double> b)
Alias for {@link mat4.multiply} @function
ortho → const List<double> Function(List<double> out, double left, double right, double bottom, double top, double near, double far)
Alias for {@link mat4.orthoNO} @function
perspective → const List<double> Function(List<double> out, double fovy, double aspect, double near, double? far)
Alias for {@link mat4.perspectiveNO} @function
sub → const List<double> Function(List<double> out, List<double> a, dynamic b)
Alias for {@link mat4.subtract} @function

Functions

add(List<double> out, List<double> a, List<double> b) List<double>
Adds two mat4's
adjoint(List<double> out, List<double> a) List<double>
Calculates the adjugate of a mat4
clone(List<double> a) List<double>
Creates a new mat4 initialized with values from an existing matrix
copy(List<double> out, List<double> a) List<double>
Copy the values from one mat4 to another
create() → dynamic
Creates a new identity mat4
decompose(List<double> outR, List<double> outT, List<double> outS, List<double> mat) List<double>
Decomposes a transformation matrix into its rotation, translation and scale components. Returns only the rotation component @param {quat} out_r Quaternion to receive the rotation component @param {vec3} out_t Vector to receive the translation vector @param {vec3} out_s Vector to receive the scaling factor @param {ReadonlyMat4} mat Matrix to be decomposed (input) @returns {quat} out_r
determinant(List<double> a) double
Calculates the determinant of a mat4
equals(List<double> a, List<double> b) bool
Returns whether or not the matrices have approximately the same elements in the same position.
exactEquals(List<double> a, List<double> b) bool
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
frob(List<double> a) double
Returns Frobenius norm of a mat4
fromQuat(List<double> out, List<double> q) List<double>
Calculates a 4x4 matrix from the given quaternion
fromQuat2(List<double> out, List<double> a) List<double>
Creates a new mat4 from a dual quat.
fromRotation(List<double> out, double rad, List<double> axis) List<double>?
Creates a matrix from a given angle around a given axis This is equivalent to (but much faster than):
fromRotationTranslation(List<double> out, List<double> q, List<double> v) List<double>
Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than):
fromRotationTranslationScale(List<double> out, List<double> q, List<double> v, List<double> s) List<double>
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than):
fromRotationTranslationScaleOrigin(List<double> out, List<double> q, List<double> v, List<double> s, List<double> o) List<double>
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):
fromScaling(List<double> out, List<double> v) List<double>
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
fromTranslation(List<double> out, List<double> v) List<double>
Creates a matrix from a vector translation This is equivalent to (but much faster than):
fromValues(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) List<double>
Create a new mat4 with the given values
fromXRotation(List<double> out, double rad) List<double>
Creates a matrix from the given angle around the X axis This is equivalent to (but much faster than):
fromYRotation(List<double> out, double rad) List<double>
Creates a matrix from the given angle around the Y axis This is equivalent to (but much faster than):
fromZRotation(List<double> out, double rad) List<double>
Creates a matrix from the given angle around the Z axis This is equivalent to (but much faster than):
frustum(List<double> out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a frustum matrix with the given bounds
getRotation(List<double> out, List<double> mat) List<double>
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. @param {quat} out Quaternion to receive the rotation component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {quat} out
getScaling(List<double> out, List<double> mat) List<double>
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. @param {vec3} out Vector to receive scaling factor component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {vec3} out
getTranslation(List<double> out, List<double> mat) List<double>
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. @param {vec3} out Vector to receive translation component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {vec3} out
identity(List<double> out) List<double>
Set a mat4 to the identity matrix
invert(List<double> out, List<double> a) List<double>?
Inverts a mat4
lookAt(List<double> out, List<double> eye, List<double> center, List<double> up) List<double>
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.
multiply(List<double> out, List<double> a, List<double> b) List<double>
Multiplies two mat4s
multiplyScalar(List<double> out, List<double> a, dynamic b) List<double>
Multiply each element of the matrix by a scalar.
multiplyScalarAndAdd(List<double> out, List<double> a, dynamic b, dynamic scale) List<double>
Adds two mat4's after multiplying each element of the second operand by a scalar value.
orthoNO(List<double> out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a orthogonal projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of -1, 1, which matches WebGL/OpenGL's clip volume.
orthoZO(List<double> out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a orthogonal projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of 0, 1, which matches WebGPU/Vulkan/DirectX/Metal's clip volume.
perspectiveFromFieldOfView(List<double> out, dynamic fov, dynamic near, dynamic far) List<double>
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.
perspectiveNO(List<double> out, double fovy, double aspect, double near, double? far) List<double>
Generates a perspective projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of -1, 1, which matches WebGL/OpenGL's clip volume. Passing null/undefined/no value for far will generate infinite projection matrix.
perspectiveZO(List<double> out, double fovy, double aspect, double near, double? far) List<double>
Generates a perspective projection matrix suitable for WebGPU with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of 0, 1, which matches WebGPU/Vulkan/DirectX/Metal's clip volume. Passing null/undefined/no value for far will generate infinite projection matrix.
rotate(List<double> out, List<double> a, double rad, dynamic axis) List<double>?
Rotates a mat4 by the given angle around the given axis
rotateX(List<double> out, List<double> a, double rad) List<double>
Rotates a matrix by the given angle around the X axis
rotateY(List<double> out, List<double> a, double rad) List<double>
Rotates a matrix by the given angle around the Y axis
rotateZ(List<double> out, List<double> a, double rad) List<double>
Rotates a matrix by the given angle around the Z axis
scale(List<double> out, List<double> a, dynamic v) List<double>
Scales the mat4 by the dimensions in the given vec3 not using vectorization
set(List<double> out, double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) List<double>
Set the components of a mat4 to the given values
str(List<double> a) String
Returns a string representation of a mat4
subtract(List<double> out, List<double> a, dynamic b) List<double>
Subtracts matrix b from matrix a
targetTo(List<double> out, List<double> eye, List<double> target, List<double> up) List<double>
Generates a matrix that makes something look at something else.
translate(List<double> out, List<double> a, dynamic v) List<double>
Translate a mat4 by the given vector
transpose(List<double> out, List<double> a) List<double>
Transpose the values of a mat4