CLASSES
TagsA - Z

Matrix

Description

class Matrix

Creates a new 4 by 4 matrix

Constructor

new Matrix()

Members

updateFlag : number

m : Float32Array

The matrix, which is an array

Methods

isIdentity() → boolean

Boolean : True is the matrix is the identity matrix

determinant() → number

Returns the matrix determinant (float).

toArray() → Float32Array

Returns the matrix underlying array.

asArray() → Float32Array

Returns the matrix underlying array.

invert() → Matrix

Inverts in place the Matrix.

Returns the Matrix inverted.

reset() → Matrix

Sets all the matrix elements to zero.

Returns the Matrix.

add(other) → Matrix

Returns a new Matrix as the addition result of the current Matrix and the passed one.

Parameters

Name Type Description
other Matrix

addToRef(other, result) → Matrix

Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.

Returns the Matrix.

Parameters

Name Type Description
other Matrix
result Matrix the target matrix

addToSelf(other) → Matrix

Adds in place the passed matrix to the current Matrix.

Returns the updated Matrix.

Parameters

Name Type Description
other Matrix

invertToRef(other) → Matrix

Sets the passed matrix with the current inverted Matrix.

Returns the unmodified current Matrix.

Parameters

Name Type Description
other Matrix

setTranslationFromFloats(x, y, z) → Matrix

Inserts the translation vector (using 3 x floats) in the current Matrix.

Returns the updated Matrix.

Parameters

Name Type Description
x number The X translation value
y number The Y translation value
z number The Z translation value

setTranslation(vector3) → Matrix

Inserts the translation vector in the current Matrix.

Returns the updated Matrix.

Parameters

Name Type Description
vector3 Vector3 The translation to apply

getTranslation() → Vector3

Returns a new Vector3 as the extracted translation from the Matrix.

getTranslationToRef(result) → Matrix

Fill a Vector3 with the extracted translation from the Matrix.

Parameters

Name Type Description
result Vector3 the target matrix

removeRotationAndScaling() → Matrix

Remove rotation and scaling part from the Matrix.

Returns the updated Matrix.

multiply(other) → Matrix

Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.

Parameters

Name Type Description
other Matrix

copyFrom(other) → Matrix

Updates the current Matrix from the passed one values.

Returns the updated Matrix.

Parameters

Name Type Description
other Matrix

copyToArray(array, offset) → Matrix

Populates the passed array from the starting index with the Matrix values.

Returns the Matrix.

Parameters

Name Type Description
array Float32Array The array to copy
optional offset number The first index to copy from

multiplyToRef(other, result) → Matrix

Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.

Parameters

Name Type Description
other Matrix
result Matrix the target matrix

multiplyToArray(other, result, offset) → Matrix

Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.

Parameters

Name Type Description
other Matrix
result Float32Array the target matrix
offset number The first index to copy from

equals(value) → boolean

Boolean : True is the current Matrix and the passed one values are strictly equal.

Parameters

Name Type Description
value Matrix The matrix to test against

clone() → Matrix

Returns a new Matrix from the current Matrix.

getClassName() → string

Returns the string "Matrix"

getHashCode() → number

Returns the Matrix hash code.

decompose(scale, rotation, translation) → boolean

Decomposes the current Matrix into :

Returns the boolean true.

Parameters

Name Type Description
scale Vector3
rotation Quaternion
translation Vector3

getRotationMatrix() → Matrix

Returns a new Matrix as the extracted rotation matrix from the current one.

getRotationMatrixToRef(result) → Matrix

Extracts the rotation matrix from the current one and sets it as the passed "result".

Returns the current Matrix.

Parameters

Name Type Description
result Matrix the target matrix

static FromArray(array, offset) → Matrix

Returns a new Matrix set from the starting index of the passed array.

Parameters

Name Type Description
array ArrayLike<number> The array to copy
optional offset number The first index to copy from

static FromArrayToRef(array, offset, result) → void

Sets the passed "result" matrix from the starting index of the passed array.

Parameters

Name Type Description
array ArrayLike<number> The array to copy
offset number The first index to copy from
result Matrix the target matrix

static FromFloat32ArrayToRefScaled(array, offset, scale, result) → void

Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".

Parameters

Name Type Description
array Float32Array The array to copy
offset number The first index to copy from
scale number

static FromValuesToRef(initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) → void

Sets the passed matrix "result" with the 16 passed floats.

Parameters

Name Type Description
initialM11 number initial MM11 1,1 value
initialM12 number initial MM12 1,2 value
initialM13 number initial MM13 1,3 value
initialM14 number initial MM14 1,4 value
initialM21 number initial MM21 2.1 value
initialM22 number initial MM22 2,2 value
initialM23 number initial MM23 2,3 value
initialM24 number initial MM24 2,4 value
initialM31 number initial MM31 3,1 value
initialM32 number initial MM32 3,2 value
initialM33 number initial MM33 3,3 value
initialM34 number initial MM34 3,4 value
initialM41 number initial MM41 4,1 value
initialM42 number initial MM42 4,2 value
initialM43 number initial MM43 4,3 value
initialM44 number initial MM44 4,4 value

getRow(index) → Vector4

Returns the index-th row of the current matrix as a new Vector4.

Parameters

Name Type Description
index number

setRow(index, row) → Matrix

Sets the index-th row of the current matrix with the passed Vector4 values.

Returns the updated Matrix.

Parameters

Name Type Description
index number
row Vector4

setRowFromFloats(index, x, y, z, w) → Matrix

Sets the index-th row of the current matrix with the passed 4 x float values.

Returns the updated Matrix.

Parameters

Name Type Description
index number
x number The X translation value
y number The Y translation value
z number The Z translation value

static FromValues(initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) → Matrix

Returns a new Matrix set from the 16 passed floats.

Parameters

Name Type Description
initialM11 number initial MM11 1,1 value
initialM12 number initial MM12 1,2 value
initialM13 number initial MM13 1,3 value
initialM14 number initial MM14 1,4 value
initialM21 number initial MM21 2.1 value
initialM22 number initial MM22 2,2 value
initialM23 number initial MM23 2,3 value
initialM24 number initial MM24 2,4 value
initialM31 number initial MM31 3,1 value
initialM32 number initial MM32 3,2 value
initialM33 number initial MM33 3,3 value
initialM34 number initial MM34 3,4 value
initialM41 number initial MM41 4,1 value
initialM42 number initial MM42 4,2 value
initialM43 number initial MM43 4,3 value

static Compose(scale, rotation, translation) → Matrix

Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).

Parameters

Name Type Description
scale Vector3
rotation Quaternion
translation Vector3

static ComposeToRef(scale, rotation, translation, result) → void

Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).

Parameters

Name Type Description
scale Vector3
rotation Quaternion
translation Vector3

static Identity() → Matrix

Returns a new indentity Matrix.

static IdentityToRef(result) → void

Sets the passed "result" as an identity matrix.

Parameters

Name Type Description
result Matrix the target matrix

static Zero() → Matrix

Returns a new zero Matrix.

static RotationX(angle) → Matrix

Returns a new rotation matrix for "angle" radians around the X axis.

Parameters

Name Type Description
angle number angle of the rotation

static Invert(source) → Matrix

Returns a new Matrix as the passed inverted one.

Parameters

Name Type Description
source Matrix

static RotationXToRef(angle, result) → void

Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.

Parameters

Name Type Description
angle number angle of the rotation
result Matrix the target matrix

static RotationY(angle) → Matrix

Returns a new rotation matrix for "angle" radians around the Y axis.

Parameters

Name Type Description
angle number angle of the rotation

static RotationYToRef(angle, result) → void

Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.

Parameters

Name Type Description
angle number angle of the rotation
result Matrix the target matrix

static RotationZ(angle) → Matrix

Returns a new rotation matrix for "angle" radians around the Z axis.

Parameters

Name Type Description
angle number angle of the rotation

static RotationZToRef(angle, result) → void

Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.

Parameters

Name Type Description
angle number angle of the rotation
result Matrix the target matrix

static RotationAxis(axis, angle) → Matrix

Returns a new rotation matrix for "angle" radians around the passed axis.

Parameters

Name Type Description
axis Vector3 Vector3 axis of the rotation
angle number angle of the rotation

static RotationAxisToRef(axis, angle, result) → void

Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.

Parameters

Name Type Description
axis Vector3 Vector3 axis of the rotation
angle number angle of the rotation
result Matrix the target matrix

static RotationYawPitchRoll(yaw, pitch, roll) → Matrix

Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).

Parameters

Name Type Description
yaw number The yaw rotation value
pitch number The pitch rotation value
roll number The roll rotation value

static RotationYawPitchRollToRef(yaw, pitch, roll, result) → void

Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).

Parameters

Name Type Description
yaw number The yaw rotation value
pitch number The pitch rotation value
roll number The roll rotation value

static Scaling(x, y, z) → Matrix

Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).

Parameters

Name Type Description
x number The X translation value
y number The Y translation value
z number The Z translation value

static ScalingToRef(x, y, z, result) → void

Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).

Parameters

Name Type Description
x number The X translation value
y number The Y translation value
z number The Z translation value

static Translation(x, y, z) → Matrix

Returns a new Matrix as a translation matrix from the passed floats (x, y, z).

Parameters

Name Type Description
x number The X translation value
y number The Y translation value
z number The Z translation value

static TranslationToRef(x, y, z, result) → void

Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).

Parameters

Name Type Description
x number The X translation value
y number The Y translation value
z number The Z translation value

static Lerp(startValue, endValue, gradient) → Matrix

Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".

Parameters

Name Type Description
startValue Matrix
endValue Matrix
gradient number

static DecomposeLerp(startValue, endValue, gradient) → Matrix

Returns a new Matrix whose values are computed by :

Parameters

Name Type Description
startValue Matrix
endValue Matrix
gradient number

static LookAtLH(eye, target, up) → Matrix

Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".

This methods works for a Left-Handed system.

Parameters

Name Type Description
eye Vector3 The Vector3 that defines the camera point
target Vector3 The Vector3 that defines the camera look-at target
up Vector3 The Vector3 that defines the up direction

static LookAtLHToRef(eye, target, up, result) → void

Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".

This methods works for a Left-Handed system.

Parameters

Name Type Description
eye Vector3 The Vector3 that defines the camera point
target Vector3 The Vector3 that defines the camera look-at target
up Vector3 The Vector3 that defines the up direction

static LookAtRH(eye, target, up) → Matrix

Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".

This methods works for a Right-Handed system.

Parameters

Name Type Description
eye Vector3 The Vector3 that defines the camera point
target Vector3 The Vector3 that defines the camera look-at target
up Vector3 The Vector3 that defines the up direction

static LookAtRHToRef(eye, target, up, result) → void

Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".

This methods works for a Left-Handed system.

Parameters

Name Type Description
eye Vector3 The Vector3 that defines the camera point
target Vector3 The Vector3 that defines the camera look-at target
up Vector3 The Vector3 that defines the up direction

static OrthoLH(width, height, znear, zfar) → Matrix

Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.

Parameters

Name Type Description
width number The width of the view volume at the near view plane
height number The height of the view volume at the near view plane
znear number Z-value of the near view plane.

static OrthoLHToRef(width, height, znear, zfar, result) → void

Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.

Parameters

Name Type Description
width number The width of the view volume at the near view plane
height number The height of the view volume at the near view plane
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.

static OrthoOffCenterLH(left, right, bottom, top, znear, zfar) → Matrix

Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.

Parameters

Name Type Description
left number The minimum x value of the view volume
right number The maximum x value of the view volume
bottom number The minimum y value of the view volume
top number The maximum y value of the view volume
znear number Z-value of the near view plane.

static OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result) → void

Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.

Parameters

Name Type Description
left number The minimum x value of the view volume
right number The maximum x value of the view volume
bottom number The minimum y value of the view volume
top number The maximum y value of the view volume
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.

static OrthoOffCenterRH(left, right, bottom, top, znear, zfar) → Matrix

Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.

Parameters

Name Type Description
left number The minimum x value of the view volume
right number The maximum x value of the view volume
bottom number The minimum y value of the view volume
top number The maximum y value of the view volume
znear number Z-value of the near view plane.

static OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, result) → void

Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.

Parameters

Name Type Description
left number The minimum x value of the view volume
right any The maximum x value of the view volume
bottom number The minimum y value of the view volume
top number The maximum y value of the view volume
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.

static PerspectiveLH(width, height, znear, zfar) → Matrix

Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.

Parameters

Name Type Description
width number The width of the view volume at the near view plane
height number The height of the view volume at the near view plane
znear number Z-value of the near view plane.

static PerspectiveFovLH(fov, aspect, znear, zfar) → Matrix

Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.

Parameters

Name Type Description
fov number Field of view in the y direction, in radians.
aspect number Aspect ratio, defined as the view space width divided by height.
znear number Z-value of the near view plane.

static PerspectiveFovLHToRef(fov, aspect, znear, zfar, result, isVerticalFovFixed) → void

Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.

Parameters

Name Type Description
fov number Field of view in the y direction, in radians.
aspect number Aspect ratio, defined as the view space width divided by height.
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.
result Matrix the target matrix

static PerspectiveFovRH(fov, aspect, znear, zfar) → Matrix

Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.

Parameters

Name Type Description
fov number Field of view in the y direction, in radians.
aspect number Aspect ratio, defined as the view space width divided by height.
znear number Z-value of the near view plane.

static PerspectiveFovRHToRef(fov, aspect, znear, zfar, result, isVerticalFovFixed) → void

Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.

Parameters

Name Type Description
fov number Field of view in the y direction, in radians.
aspect number Aspect ratio, defined as the view space width divided by height.
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.
result Matrix the target matrix

static PerspectiveFovWebVRToRef(fov, znear, zfar, result, rightHanded) → void

Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.

Parameters

Name Type Description
fov any Field of view in the y direction, in radians.
znear number Z-value of the near view plane.
zfar number Z-value of the far view plane.
result Matrix the target matrix

static GetFinalMatrix(viewport, world, view, projection, zmin, zmax) → Matrix

Returns the final transformation matrix : world view projection * viewport

Parameters

Name Type Description
viewport Viewport The Viewport structure representing the viewport
world Matrix The Matrix structure representing the world
view Matrix The Matrix structure representing the view
projection Matrix The Matrix structure representing the projection
zmin number The minumum z value of the viewport

static GetAsMatrix2x2(matrix) → Float32Array

Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.

Parameters

Name Type Description
matrix Matrix The matrix to transpose

static GetAsMatrix3x3(matrix) → Float32Array

Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.

Parameters

Name Type Description
matrix Matrix The matrix to transpose

static Transpose(matrix) → Matrix

Compute the transpose of the passed Matrix.

Returns a new Matrix.

Parameters

Name Type Description
matrix Matrix The matrix to transpose

static Reflection(plane) → Matrix

Returns a new Matrix as the reflection matrix across the passed plane.

Parameters

Name Type Description
plane Plane The given plane

static ReflectionToRef(plane, result) → void

Sets the passed matrix "result" as the reflection matrix across the passed plane.

Parameters

Name Type Description
plane Plane The given plane
result Matrix the target matrix

static FromXYZAxesToRef(xaxis, yaxis, zaxis, result) → void

Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.

Parameters

Name Type Description
xaxis Vector3
yaxis Vector3
zaxis Vector3

static FromQuaternionToRef(quat, result) → void

Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.

Parameters

Name Type Description
quat Quaternion
result Matrix the target matrix