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 positionVector3 A vector representing a position in 3D space.
rotationQuaternion A quaternion representing a rotation.
scaleVector3 A vector representing a 3D scaling.
-
copy(m) → {Matrix4}
-
Copies all values from the given matrix to this matrix.
Parameters:
Name Type Description mMatrix4 The matrix to copy.
-
equals(m) → {Boolean}
-
Returns true if the given matrix is deep equal with this matrix.
Parameters:
Name Type Description mMatrix4 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 xAxisVector3 The first result vector for the x-axis.
yAxisVector3 The second result vector for the y-axis.
zAxisVector3 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 arrayArray.<Number> An array.
offsetNumber 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 mMatrix3 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 qQuaternion 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 mMatrix4 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 xAxisVector3 The first basis vector for the x-axis.
yAxisVector3 The second basis vector for the y-axis.
zAxisVector3 The third basis vector for the z-axis.
-
multiply(m) → {Matrix4}
-
Multiplies this matrix with the given matrix.
Parameters:
Name Type Description mMatrix4 The matrix to multiply.
-
multiplyMatrices(a, b) → {Matrix4}
-
Multiplies two given matrices and stores the result in this matrix.
Parameters:
Name Type Description aMatrix4 The first matrix of the operation.
bMatrix4 The second matrix of the operation.
-
multiplyScalar(s) → {Matrix4}
-
Multiplies the given scalar with this matrix.
Parameters:
Name Type Description sNumber 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 mMatrix4 The matrix to multiply.
-
scale(v) → {Matrix4}
-
Scales this matrix by the given 3D vector.
Parameters:
Name Type Description vVector3 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 n11Number An element of the matrix.
n12Number An element of the matrix.
n13Number An element of the matrix.
n14Number An element of the matrix.
n21Number An element of the matrix.
n22Number An element of the matrix.
n23Number An element of the matrix.
n24Number An element of the matrix.
n31Number An element of the matrix.
n32Number An element of the matrix.
n33Number An element of the matrix.
n34Number An element of the matrix.
n41Number An element of the matrix.
n42Number An element of the matrix.
n43Number An element of the matrix.
n44Number 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 vVector3 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 arrayArray.<Number> An array.
offsetNumber 0 An optional offset.
Returns:
Array.<Number> -The array with the elements of the matrix.
-
transpose() → {Matrix4}
-
Transposes this matrix.