Matrix4

4x4 matrix class.

Constructor

new Matrix4()

Create a 4x4 matrix.

Methods

clone() → {Matrix4}

Creates a new Matrix4 with identical elements to this one.

Returns:
Type: 
Matrix4

copy(m) → {Matrix4}

Copies the elements of matrix m into this matrix.

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
Matrix4

decompose(position, quaternion, scale) → {Matrix4}

Decomposes this matrix into it's position, quaternion and scale components.

Parameters:
NameTypeDescription
positionVector3
quaternionQuaternion
scaleVector3
Returns:
Type: 
Matrix4

determinant() → {number}

Computes and returns the determinant of this matrix.

Returns:
Type: 
number

equals(m) → {boolean}

Return true if this matrix and m are equal.

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
boolean

extractRotation(m) → {Matrix4}

Extracts the rotation component of the supplied matrix m into this matrix's rotation component.

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
Matrix4

fromArray(array, offsetopt) → {Matrix4}

Sets the elements of this matrix based on an array in column-major format.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number>
offsetnumber<optional>
0
Returns:
Type: 
Matrix4

getInverse(m) → {Matrix4}

Take the inverse of the matrix

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
Matrix4

getMaxScaleOnAxis() → {number}

Gets the maximum scale value of the 3 axes.

Returns:
Type: 
number

identity() → {Matrix4}

Resets this matrix to the identity matrix.

Returns:
Type: 
Matrix4

inverse() → {Matrix4}

Take the inverse of this matrix

Returns:
Type: 
Matrix4

isIdentity() → {boolean}

Checks if the matrix is an identity matrix.

Returns:
  • True if the matrix is an identity matrix, false otherwise.
Type: 
boolean

lerpMatrices(m1, m2, ratio) → {Matrix4}

Linearly interpolates between two matrix4.

Parameters:
NameTypeDescription
m1Matrix4
m2Matrix4
rationumber
Returns:
Type: 
Matrix4

lookAtRH(eye, target, up) → {Matrix4}

Constructs a rotation matrix, looking from eye towards center oriented by the up vector.

Parameters:
NameTypeDescription
eyeVector3
targetVector3
upVector3
Returns:
Type: 
Matrix4

makeRotationAxis(axis, angle) → {Matrix4}

Sets this matrix as rotation transform around axis by theta radians.

Parameters:
NameTypeDescription
axisVector3
anglenumber
Returns:
Type: 
Matrix4

makeRotationFromQuaternion(q) → {Matrix4}

Sets the rotation component of this matrix to the rotation specified by q, as outlined here.

Parameters:
NameTypeDescription
qQuaternion
Returns:
Type: 
Matrix4

makeScale(x, y, z) → {Matrix4}

Sets this matrix as a scaling transform.

Parameters:
NameTypeDescription
xnumber

The amount to scale in the X axis.

ynumber

The amount to scale in the Y axis.

znumber

The amount to scale in the Z axis.

Returns:
Type: 
Matrix4

makeTranslation(x, y, z) → {Matrix4}

Sets this matrix as a translation transform.

Parameters:
NameTypeDescription
xnumber

the amount to translate in the X axis.

ynumber

the amount to translate in the Y axis.

znumber

the amount to translate in the Z axis.

Returns:
Type: 
Matrix4

multiply(m) → {Matrix4}

Post-multiplies this matrix by m.

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
Matrix4

multiplyMatrices(a, b) → {Matrix4}

Sets this matrix to a x b.

Parameters:
NameTypeDescription
aMatrix4
bMatrix4
Returns:
Type: 
Matrix4

premultiply(m) → {Matrix4}

Pre-multiplies this matrix by m.

Parameters:
NameTypeDescription
mMatrix4
Returns:
Type: 
Matrix4

set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) → {Matrix4}

Set the elements of this matrix to the supplied row-major values n11, n12, ... n44.

Parameters:
NameTypeDescription
n11number
n12number
n13number
n14number
n21number
n22number
n23number
n24number
n31number
n32number
n33number
n34number
n41number
n42number
n43number
n44number
Returns:
Type: 
Matrix4

setFromMatrix3(m) → {Matrix4}

Set the upper 3x3 elements of this matrix to the values of the Matrix3 m.

Parameters:
NameTypeDescription
mMatrix3
Returns:
Type: 
Matrix4

toArray(arrayopt, offsetopt) → {Array.<number>}

Writes the elements of this matrix to an array in column-major format.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number><optional>
offsetnumber<optional>
0
Returns:
Type: 
Array.<number>

transform(position, scale, quaternion) → {Matrix4}

Make transform from position&scale&quaternion(Quaternion).

Parameters:
NameTypeDescription
positionVector3
scaleVector3
quaternionQuaternion
Returns:
Type: 
Matrix4

transpose() → {Matrix4}

Transposes this matrix.

Returns:
Type: 
Matrix4