new Matrix4()
Constructs a new 4x4 identity matrix.
Members
-
elements :Array.<Number>
-
The elements of the matrix in column-major order.
Methods
-
clone() → {Matrix4}
-
Creates a new matrix and copies all values from this matrix.
-
compose(position, rotation, scale) → {Matrix4}
-
Composes a matrix from the given position, quaternion and scale.
Parameters:
Name Type Description position
Vector3 A vector representing a position in 3D space.
rotation
Quaternion A quaternion representing a rotation.
scale
Vector3 A vector representing a 3D scaling.
-
copy(m) → {Matrix4}
-
Copies all values from the given matrix to this matrix.
Parameters:
Name Type Description m
Matrix4 The matrix to copy.
-
equals(m) → {Boolean}
-
Returns true if the given matrix is deep equal with this matrix.
Parameters:
Name Type Description m
Matrix4 The matrix to test.
Returns:
Boolean -The result of the equality test.
-
extractBasis(xAxis, yAxis, zAxis) → {Matrix4}
-
Extracts the basis vectors and stores them to the given vectors.
Parameters:
Name Type Description xAxis
Vector3 The first result vector for the x-axis.
yAxis
Vector3 The second result vector for the y-axis.
zAxis
Vector3 The third result vector for the z-axis.
-
fromArray(array, offset) → {Matrix4}
-
Sets the elements of this matrix from an array.
Parameters:
Name Type Default Description array
Array.<Number> An array.
offset
Number 0 An optional offset.
-
fromMatrix3(m) → {Matrix4}
-
Sets the upper-left 3x3 portion of this matrix by the given 3x3 matrix. Other parts of the matrix are equal to the identiy matrix.
Parameters:
Name Type Description m
Matrix3 A 3x3 matrix.
-
fromQuaternion(q) → {Matrix4}
-
Uses the given quaternion to transform the upper left 3x3 part to a rotation matrix. Other parts of the matrix are equal to the identiy matrix.
Parameters:
Name Type Description q
Quaternion A quaternion representing a rotation.
-
getInverse(m) → {Matrix4}
-
Computes the inverse of this matrix and stored the result in the given matrix.
You can not invert a matrix with a determinant of zero. If you attempt this, the method returns a zero matrix instead.
Parameters:
Name Type Description m
Matrix4 The result matrix.
-
getMaxScale() → {Number}
-
Computes the maximum scale value for all three axis.
Returns:
Number -The maximum scale value.
-
identity() → {Matrix4}
-
Transforms this matrix to an identity matrix.
-
makeBasis(xAxis, yAxis, zAxis) → {Matrix4}
-
Makes a basis from the given vectors.
Parameters:
Name Type Description xAxis
Vector3 The first basis vector for the x-axis.
yAxis
Vector3 The second basis vector for the y-axis.
zAxis
Vector3 The third basis vector for the z-axis.
-
multiply(m) → {Matrix4}
-
Multiplies this matrix with the given matrix.
Parameters:
Name Type Description m
Matrix4 The matrix to multiply.
-
multiplyMatrices(a, b) → {Matrix4}
-
Multiplies two given matrices and stores the result in this matrix.
Parameters:
Name Type Description a
Matrix4 The first matrix of the operation.
b
Matrix4 The second matrix of the operation.
-
multiplyScalar(s) → {Matrix4}
-
Multiplies the given scalar with this matrix.
Parameters:
Name Type Description s
Number The scalar to multiply.
-
premultiply(m) → {Matrix4}
-
Multiplies this matrix with the given matrix. So the order of the multiplication is switched compared to Matrix4#multiply.
Parameters:
Name Type Description m
Matrix4 The matrix to multiply.
-
scale(v) → {Matrix4}
-
Scales this matrix by the given 3D vector.
Parameters:
Name Type Description v
Vector3 A 3D vector representing a scaling.
-
set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) → {Matrix4}
-
Sets the given values to this matrix. The arguments are in row-major order.
Parameters:
Name Type Description n11
Number An element of the matrix.
n12
Number An element of the matrix.
n13
Number An element of the matrix.
n14
Number An element of the matrix.
n21
Number An element of the matrix.
n22
Number An element of the matrix.
n23
Number An element of the matrix.
n24
Number An element of the matrix.
n31
Number An element of the matrix.
n32
Number An element of the matrix.
n33
Number An element of the matrix.
n34
Number An element of the matrix.
n41
Number An element of the matrix.
n42
Number An element of the matrix.
n43
Number An element of the matrix.
n44
Number An element of the matrix.
-
setPosition(v) → {Matrix4}
-
Sets the translation part of the 4x4 matrix to the given position vector.
Parameters:
Name Type Description v
Vector3 A 3D vector representing a position.
-
toArray(array, offset) → {Array.<Number>}
-
Copies all elements of this matrix to the given array.
Parameters:
Name Type Default Description array
Array.<Number> An array.
offset
Number 0 An optional offset.
Returns:
Array.<Number> -The array with the elements of the matrix.
-
transpose() → {Matrix4}
-
Transposes this matrix.