Mat4 is the class used for all 4 dimensions matrices manipulations.
To create a new Mat4, just use its constructor.
If used without parameters, it will create a 4 dimensions identity matrix.
Since most of the Mat4 methods return the matrix itself, you can use chaining:
- elements array of length 16, optional values to use for that matrix. Default to 4 dimensions identity matrix.
elements (Float32Array): v7.0
A Float32Array of length 16 representing that matrix.
Clone this matrix.
returns: new cloned matrix.
composeFromOrigin(translation, quaternion, scale, origin): v7.0
Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin.
Equivalent for applying translation, rotation and scale matrices but much faster.
- translation Vec3 class object translation vector
- quaternion Quat class object rotation quaternion
- scale Vec3 class object scale vector
- origin Vec3 class object origin vector around which to scale and rotate
returns: this matrix after transformations.
Copy a matrix into this matrix.
- matrix Mat4 class object matrix to copy
returns: this matrix after copy.
Creates a new matrix inverse from this matrix.
returns: a new matrix inverse of this matrix.
Multiply this matrix by the matrix passed as parameter.
- matrix Mat4 class object matrix to multiply with.
returns: this matrix after multiplication.
Scale this matrix by the vector passed as parameter.
- vector Vec3 class object vector to use for scaling
returns: this matrix after scaling.
Sets the matrix values from an array.
- array array an array of at least 16 elements
returns: this matrix after being set.