Creates a new matrix with the specified elements. If no arguments are specified, an identity matrix is constructed.
Optionalm00: numberOptionalm01: numberOptionalm02: numberOptionalm03: numberOptionalm10: numberOptionalm11: numberOptionalm12: numberOptionalm13: numberOptionalm20: numberOptionalm21: numberOptionalm22: numberOptionalm23: numberOptionalm30: numberOptionalm31: numberOptionalm32: numberOptionalm33: numberStatic ReadonlyidentityIdentity matrix.
Static ReadonlyzeroA matrix with all zero values.
Calculates the determinant of the matrix.
Determinant of the matrix.
Clones this instance and returns a new Matrix4 with identical values.
Calculates the inverse of the matrix. If matrix is affine use invertAffine as it is faster.
Calculates the inverse of the matrix. Matrix must be affine.
Transposes the matrix (switched columns and rows).
Gets a specific column in the matrix.
Index of the column in range [0, 3].
The column as Vector4.
Gets a specific column in the matrix as a Vector3, discarding the fourth component.
Index of the column in range [0, 3].
The upper three rows of the column as Vector3.
Gets the value of the specified element in the matrix.
Row index of the element to retrieve.
Column index of the element to retrieve.
Value of the element.
Returns value of the specified element in the matrix using a linear index. Linear index can be calculated using the following formula: idx = row * 4 + column.
Linear index to get the value of.
Value of the element.
Decompose a matrix to translation, rotation and scale components. Matrix must consist only of translation, rotation and uniform scale transformations, otherwise accurate results are not guaranteed. Applying non-uniform scale guarantees results will not be accurate.
An object containing:
translation the translationrotation the rotationscale the scale.Calculates the inverse of the matrix.
Calculates the inverse of the matrix. Matrix must be affine.
Transform a 3D point by this matrix. w component of the vector is assumed to be 1. After transformation all
components are projected back so that w remains 1. If your matrix doesn't contain projection components use
multiplyAffineVector4 as it is faster.
Point transformed by this matrix.
Sets the value of the specified element in the matrix.
Row index of the element to retrieve.
Column index of the element to retrieve.
Value of the element.
Sets value of the specified element in the matrix using a linear index. Linear index can be calculated using the following formula: idx = row * 4 + column.
Linear index to gsetet the value of.
New value of the element.
Returns a transpose of the matrix (switched columns and rows).
StaticfromStaticisStaticmultiplyStatictoStaticwithCreates a new identity matrix.
StaticwithCreates a new matrix that performs inverse translation, rotation and scale.
Inverted matrix that performs scale, followed by rotation, followed by translation.
StaticwithCreates a new matrix that performs inverse translation, rotation, scale and skew.
Inverted matrix. Cheaper than withTRSS followed by inverse().
StaticwithReturns a 4x4 matrix with the upper-left 3x3 portion set from matrix and the translation column set from position.
4x4 matrix combining the rotation/scaling from the 3x3 matrix and the provided translation.
StaticwithStaticwithCreates a new matrix that performs translation, rotation, scale and skew.
Matrix that performs skew+scale, followed by rotation, followed by translation.
The Matrix4 implements a 4x4 matrix that can be used for homogenous transformations of three dimensional vectors and points.
The class follows the 'copy-on-write' pattern, which means that every operation such as Matrix4.multiply returns a copy of the matrix with updated values. It also implies that the values of the matrix cannot be directly modified.
The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.
Note
The matrix storage is "row-major" meaning that elements [0...3] represents the first row. The first column is represented by the elements[0, 4, 8, 12]