Class Matrix
Hierarchy
- Matrix
Index
Constructors
Properties
Accessors
Methods
- add
- add
At Index - add
To Ref - add
To Self - add
Translation From Floats - as
Array - clone
- copy
From - copy
To Array - decompose
- decompose
To Transform Node - determinant
- equals
- get
Class Name - get
Hash Code - get
Rotation Matrix - get
Rotation Matrix To Ref - get
Row - get
Row To Ref - get
Translation - get
Translation To Ref - invert
- invert
To Ref - is
Identity - is
Identity As3x2 - mark
As Updated - multiply
- multiply
At Index - multiply
To Array - multiply
To Ref - remove
Rotation And Scaling - reset
- scale
- scale
And Add To Ref - scale
To Ref - set
Row - set
Row From Floats - set
Translation - set
Translation From Floats - to
Array - to
Normal Matrix - to
String - toggle
Model Matrix Hand In Place - toggle
Projection Matrix Hand In Place - transpose
- transpose
To Ref - Compose
- Compose
To Ref - Decompose
Lerp - Decompose
Lerp To Ref - From
Array - From
Array To Ref - From
Float32 Array To Ref Scaled - From
Quaternion To Ref - From
Values - From
Values To Ref - FromXYZAxes
To Ref - Get
As Matrix2x2 - Get
As Matrix3x3 - Get
Final Matrix - Identity
- Identity
To Ref - Invert
- Lerp
- Lerp
To Ref - Look
AtLH - Look
AtLHTo Ref - Look
AtRH - Look
AtRHTo Ref - Look
DirectionLH - Look
DirectionLHTo Ref - Look
DirectionRH - Look
DirectionRHTo Ref - Oblique
Off CenterLHTo Ref - Oblique
Off CenterRHTo Ref - OrthoLH
- OrthoLHTo
Ref - Ortho
Off CenterLH - Ortho
Off CenterLHTo Ref - Ortho
Off CenterRH - Ortho
Off CenterRHTo Ref - Perspective
FovLH - Perspective
FovLHTo Ref - Perspective
FovRH - Perspective
FovRHTo Ref - Perspective
Fov ReverseLHTo Ref - Perspective
Fov ReverseRHTo Ref - PerspectiveLH
- Reflection
- Reflection
To Ref - Rotation
Align To Ref - Rotation
Axis - Rotation
Axis To Ref - RotationX
- RotationXTo
Ref - RotationY
- RotationYTo
Ref - Rotation
Yaw Pitch Roll - Rotation
Yaw Pitch Roll To Ref - RotationZ
- RotationZTo
Ref - Scaling
- Scaling
To Ref - Translation
- Translation
To Ref - Transpose
- Transpose
To Ref - Zero
Constructors
constructor
Creates an empty matrix (filled with zeros)
Returns Matrix
Properties
update FlagSearch playground for updateFlag
Gets the update flag of the matrix which is an unique number for the matrix. It will be incremented every time the matrix data change. You can use it to speed the comparison between two versions of the same matrix.
Accessors
m
Gets the internal data of the matrix
Returns DeepImmutableArray<number> | DeepImmutableObject<Float32Array>
Static Identity Read Only
Gets an identity matrix that must not be updated
Returns DeepImmutableObject<Matrix>
Static Use64 Bits
Gets the precision of matrix computations
Returns boolean
Methods
addSearch playground for add
Adds the current matrix with a second one Example Playground - https://playground.babylonjs.com/#AV9X17#44
Parameters
other: DeepImmutableObject<Matrix>
defines the matrix to add
Returns Matrix
a new matrix as the addition of the current matrix and the given one
add At IndexSearch playground for addAtIndex
add a value at the specified position in the current Matrix Example Playground - https://playground.babylonjs.com/#AV9X17#47
Parameters
index: number
the index of the value within the matrix. between 0 and 15.
value: number
the value to be added
Returns Matrix
the current updated matrix
add To RefSearch playground for addToRef
Sets the given matrix "result" to the addition of the current matrix and the given one Example Playground - https://playground.babylonjs.com/#AV9X17#45
Type Parameters
T extends Matrix<T>
Parameters
other: DeepImmutableObject<Matrix>
defines the matrix to add
result: T
defines the target matrix
Returns T
result input
add To SelfSearch playground for addToSelf
Adds in place the given matrix to the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#46
Parameters
other: DeepImmutableObject<Matrix>
defines the second operand
Returns Matrix
the current updated matrix
add Translation From FloatsSearch playground for addTranslationFromFloats
Adds the translation vector (using 3 floats) in the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#20 Example Playground - https://playground.babylonjs.com/#AV9X17#48
Parameters
x: number
defines the 1st component of the translation
y: number
defines the 2nd component of the translation
z: number
defines the 3rd component of the translation
Returns Matrix
the current updated matrix
as Array
Returns DeepImmutableArray<number> | DeepImmutableObject<Float32Array>
the matrix underlying array.
cloneSearch playground for clone
Clone the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#18
Returns Matrix
a new matrix from the current matrix
copy FromSearch playground for copyFrom
Copy the current matrix from the given one Example Playground - https://playground.babylonjs.com/#AV9X17#21
Parameters
other: DeepImmutableObject<Matrix>
defines the source matrix
Returns Matrix
the current updated matrix
copy To ArraySearch playground for copyToArray
Populates the given array from the starting index with the current matrix values
Parameters
array: number[] | Float32Array
defines the target array
Optional offset: number
defines the offset in the target array where to start storing values
Returns Matrix
the current matrix
decomposeSearch playground for decompose
Decomposes the current Matrix into a translation, rotation and scaling components Example Playground - https://playground.babylonjs.com/#AV9X17#12
Parameters
Optional scale: Vector3
defines the scale vector3 given as a reference to update
Optional rotation: Quaternion
defines the rotation quaternion given as a reference to update
Optional translation: Vector3
defines the translation vector3 given as a reference to update
Optional preserveScalingNode: TransformNode
Use scaling sign coming from this node. Otherwise scaling sign might change.
Optional useAbsoluteScaling: boolean
Use scaling sign coming from this absoluteScaling when true or scaling otherwise.
Returns boolean
true if operation was successful
decompose To Transform NodeSearch playground for decomposeToTransformNode
Decomposes the current Matrix into a translation, rotation and scaling components of the provided node Example Playground - https://playground.babylonjs.com/#AV9X17#13
Parameters
node: TransformNode
the node to decompose the matrix to
Returns boolean
true if operation was successful
determinantSearch playground for determinant
Gets the determinant of the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#34
Returns number
the matrix determinant
equalsSearch playground for equals
Check equality between this matrix and a second one
Parameters
value: DeepImmutableObject<Matrix>
defines the second matrix to compare
Returns boolean
true is the current matrix and the given one values are strictly equal
get Class NameSearch playground for getClassName
Returns the name of the current matrix class
Returns string
the string "Matrix"
get Hash CodeSearch playground for getHashCode
Gets the hash code of the current matrix
Returns number
the hash code
get Rotation MatrixSearch playground for getRotationMatrix
Gets only rotation part of the current matrix
Returns Matrix
a new matrix sets to the extracted rotation matrix from the current one
get Rotation Matrix To RefSearch playground for getRotationMatrixToRef
Extracts the rotation matrix from the current one and sets it as the given "result"
Type Parameters
T extends Matrix<T>
Parameters
result: T
defines the target matrix to store data to
Returns T
result input
get RowSearch playground for getRow
Gets specific row of the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#36
Parameters
index: number
defines the number of the row to get
Returns Nullable<Vector4>
the index-th row of the current matrix as a new Vector4
get Row To RefSearch playground for getRowToRef
Gets specific row of the matrix to ref Example Playground - https://playground.babylonjs.com/#AV9X17#36
Type Parameters
T extends Vector4<T>
Parameters
index: number
defines the number of the row to get
rowVector: T
vector to store the index-th row of the current matrix
Returns T
result input
get TranslationSearch playground for getTranslation
Gets the translation value of the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#122
Returns Vector3
a new Vector3 as the extracted translation from the matrix
get Translation To RefSearch playground for getTranslationToRef
Fill a Vector3 with the extracted translation from the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#123
Type Parameters
T extends Vector3<T>
Parameters
result: T
defines the Vector3 where to store the translation
Returns T
the current matrix
invertSearch playground for invert
Inverts the current matrix in place Example Playground - https://playground.babylonjs.com/#AV9X17#118
Returns Matrix
the current inverted matrix
invert To RefSearch playground for invertToRef
Sets the given matrix to the current inverted Matrix Example Playground - https://playground.babylonjs.com/#AV9X17#119
Type Parameters
T extends Matrix<T>
Parameters
other: T
defines the target matrix
Returns T
result input
is IdentitySearch playground for isIdentity
Check if the current matrix is identity
Returns boolean
true is the matrix is the identity matrix
is Identity As3x2Search playground for isIdentityAs3x2
Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
Returns boolean
true is the matrix is the identity matrix
mark As UpdatedSearch playground for markAsUpdated
Update the updateFlag to indicate that the matrix has been updated
Returns void
multiplySearch playground for multiply
Multiply two matrices Example Playground - https://playground.babylonjs.com/#AV9X17#15 A.multiply(B) means apply B to A so result is B x A
Parameters
other: DeepImmutableObject<Matrix>
defines the second operand
Returns Matrix
a new matrix set with the multiplication result of the current Matrix and the given one
multiply At IndexSearch playground for multiplyAtIndex
mutiply the specified position in the current Matrix by a value
Parameters
index: number
the index of the value within the matrix. between 0 and 15.
value: number
the value to be added
Returns Matrix
the current updated matrix
multiply To ArraySearch playground for multiplyToArray
Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
Parameters
other: DeepImmutableObject<Matrix>
defines the second operand
result: number[] | Float32Array
defines the array where to store the multiplication
offset: number
defines the offset in the target array where to start storing values
Returns Matrix
the current matrix
multiply To RefSearch playground for multiplyToRef
Sets the given matrix "result" with the multiplication result of the current Matrix and the given one A.multiplyToRef(B, R) means apply B to A and store in R and R = B x A Example Playground - https://playground.babylonjs.com/#AV9X17#16
Type Parameters
T extends Matrix<T>
Parameters
other: DeepImmutableObject<Matrix>
defines the second operand
result: T
defines the matrix where to store the multiplication
Returns T
result input
remove Rotation And ScalingSearch playground for removeRotationAndScaling
Remove rotation and scaling part from the matrix
Returns Matrix
the updated matrix
resetSearch playground for reset
Sets all the matrix elements to zero
Returns Matrix
the current matrix
scaleSearch playground for scale
Compute a new matrix set with the current matrix values multiplied by scale (float)
Parameters
scale: number
defines the scale factor
Returns Matrix
a new matrix
scale And Add To RefSearch playground for scaleAndAddToRef
Scale the current matrix values by a factor and add the result to a given matrix
Type Parameters
T extends Matrix<T>
Parameters
scale: number
defines the scale factor
result: T
defines the Matrix to store the result
Returns T
result input
scale To RefSearch playground for scaleToRef
Scale the current matrix values by a factor to a given result matrix
Type Parameters
T extends Matrix<T>
Parameters
scale: number
defines the scale factor
result: T
defines the matrix to store the result
Returns T
result input
set RowSearch playground for setRow
Sets the index-th row of the current matrix to the vector4 values Example Playground - https://playground.babylonjs.com/#AV9X17#36
Parameters
index: number
defines the number of the row to set
row: Vector4
defines the target vector4
Returns Matrix
the updated current matrix
set Row From FloatsSearch playground for setRowFromFloats
Sets the index-th row of the current matrix with the given 4 x float values Example Playground - https://playground.babylonjs.com/#AV9X17#36
Parameters
index: number
defines the row index
x: number
defines the x component to set
y: number
defines the y component to set
z: number
defines the z component to set
w: number
defines the w component to set
Returns Matrix
the updated current matrix
set TranslationSearch playground for setTranslation
Inserts the translation vector in the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#121
Parameters
vector3: DeepImmutableObject<Vector3>
defines the translation to insert
Returns Matrix
the current updated matrix
set Translation From FloatsSearch playground for setTranslationFromFloats
Inserts the translation vector (using 3 floats) in the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#120
Parameters
x: number
defines the 1st component of the translation
y: number
defines the 2nd component of the translation
z: number
defines the 3rd component of the translation
Returns Matrix
the current updated matrix
to Array
Returns DeepImmutableArray<number> | DeepImmutableObject<Float32Array>
the matrix underlying array
to Normal MatrixSearch playground for toNormalMatrix
Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column). Example Playground - https://playground.babylonjs.com/#AV9X17#17
Type Parameters
T extends Matrix<T>
Parameters
ref: T
matrix to store the result
Returns T
to StringSearch playground for toString
Gets a string with the Matrix values
Returns string
a string with the Matrix values
toggle Model Matrix Hand In PlaceSearch playground for toggleModelMatrixHandInPlace
Toggles model matrix from being right handed to left handed in place and vice versa
Returns Matrix
toggle Projection Matrix Hand In PlaceSearch playground for toggleProjectionMatrixHandInPlace
Toggles projection matrix from being right handed to left handed in place and vice versa
Returns Matrix
transposeSearch playground for transpose
Compute the transpose of the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#40
Returns Matrix
the new transposed matrix
transpose To RefSearch playground for transposeToRef
Compute the transpose of the matrix and store it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#41
Type Parameters
T extends Matrix<T>
Parameters
result: T
defines the target matrix
Returns T
result input
Static ComposeSearch playground for Compose
Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3) Example Playground - https://playground.babylonjs.com/#AV9X17#24
Parameters
scale: DeepImmutableObject<Vector3>
defines the scale vector3
rotation: DeepImmutableObject<Quaternion>
defines the rotation quaternion
translation: DeepImmutableObject<Vector3>
defines the translation vector3
Returns Matrix
a new matrix
Static Compose To RefSearch playground for ComposeToRef
Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3) Example Playground - https://playground.babylonjs.com/#AV9X17#25
Type Parameters
T extends Matrix<T>
Parameters
scale: DeepImmutableObject<Vector3>
defines the scale vector3
rotation: DeepImmutableObject<Quaternion>
defines the rotation quaternion
translation: DeepImmutableObject<Vector3>
defines the translation vector3
result: T
defines the target matrix
Returns T
result input
Static Decompose LerpSearch playground for DecomposeLerp
Builds a new matrix whose values are computed by:
- decomposing the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
- interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
- recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices Example Playground - https://playground.babylonjs.com/#AV9X17#22 Example Playground - https://playground.babylonjs.com/#AV9X17#51
Type Parameters
T extends Matrix<T>
Parameters
startValue: DeepImmutable<T>
defines the first matrix
endValue: DeepImmutableObject<Matrix>
defines the second matrix
gradient: number
defines the gradient between the two matrices
Returns T
the new matrix
Static Decompose Lerp To RefSearch playground for DecomposeLerpToRef
Update a matrix to values which are computed by:
- decomposing the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
- interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
- recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices Example Playground - https://playground.babylonjs.com/#AV9X17#23 Example Playground - https://playground.babylonjs.com/#AV9X17#53
Type Parameters
T extends Matrix<T>
Parameters
startValue: DeepImmutableObject<Matrix>
defines the first matrix
endValue: DeepImmutableObject<Matrix>
defines the second matrix
gradient: number
defines the gradient between the two matrices
result: T
defines the target matrix
Returns T
result input
Static From ArraySearch playground for FromArray
Creates a matrix from an array Example Playground - https://playground.babylonjs.com/#AV9X17#42
Parameters
array: DeepImmutableObject<ArrayLike<number>>
defines the source array
Optional offset: number
defines an offset in the source array
Returns Matrix
a new Matrix set from the starting index of the given array
Static From Array To RefSearch playground for FromArrayToRef
Copy the content of an array into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#43
Type Parameters
T extends Matrix<T>
Parameters
array: DeepImmutableObject<ArrayLike<number>>
defines the source array
offset: number
defines an offset in the source array
result: T
defines the target matrix
Returns T
result input
Static From Float32 Array To Ref ScaledSearch playground for FromFloat32ArrayToRefScaled
Stores an array into a matrix after having multiplied each component by a given factor Example Playground - https://playground.babylonjs.com/#AV9X17#50
Type Parameters
T extends Matrix<T>
Parameters
array: DeepImmutableArray<number> | DeepImmutableObject<Float32Array>
defines the source array
offset: number
defines the offset in the source array
scale: number
defines the scaling factor
result: T
defines the target matrix
Returns T
result input
Static From Quaternion To RefSearch playground for FromQuaternionToRef
Creates a rotation matrix from a quaternion and stores it in a target matrix
Type Parameters
T extends Matrix<T>
Parameters
quat: DeepImmutableObject<Quaternion>
defines the quaternion to use
result: T
defines the target matrix
Returns T
result input
Static From ValuesSearch playground for FromValues
Creates new matrix from a list of values (16)
Parameters
initialM11: number
defines 1st value of 1st row
initialM12: number
defines 2nd value of 1st row
initialM13: number
defines 3rd value of 1st row
initialM14: number
defines 4th value of 1st row
initialM21: number
defines 1st value of 2nd row
initialM22: number
defines 2nd value of 2nd row
initialM23: number
defines 3rd value of 2nd row
initialM24: number
defines 4th value of 2nd row
initialM31: number
defines 1st value of 3rd row
initialM32: number
defines 2nd value of 3rd row
initialM33: number
defines 3rd value of 3rd row
initialM34: number
defines 4th value of 3rd row
initialM41: number
defines 1st value of 4th row
initialM42: number
defines 2nd value of 4th row
initialM43: number
defines 3rd value of 4th row
initialM44: number
defines 4th value of 4th row
Returns Matrix
the new matrix
Static From Values To RefSearch playground for FromValuesToRef
Stores a list of values (16) inside a given matrix
Parameters
initialM11: number
defines 1st value of 1st row
initialM12: number
defines 2nd value of 1st row
initialM13: number
defines 3rd value of 1st row
initialM14: number
defines 4th value of 1st row
initialM21: number
defines 1st value of 2nd row
initialM22: number
defines 2nd value of 2nd row
initialM23: number
defines 3rd value of 2nd row
initialM24: number
defines 4th value of 2nd row
initialM31: number
defines 1st value of 3rd row
initialM32: number
defines 2nd value of 3rd row
initialM33: number
defines 3rd value of 3rd row
initialM34: number
defines 4th value of 3rd row
initialM41: number
defines 1st value of 4th row
initialM42: number
defines 2nd value of 4th row
initialM43: number
defines 3rd value of 4th row
initialM44: number
defines 4th value of 4th row
result: Matrix
defines the target matrix
Returns void
result input
Static FromXYZAxes To RefSearch playground for FromXYZAxesToRef
Sets the given matrix as a rotation matrix composed from the 3 left handed axes
Type Parameters
T extends Matrix<T>
Parameters
xaxis: DeepImmutableObject<Vector3>
defines the value of the 1st axis
yaxis: DeepImmutableObject<Vector3>
defines the value of the 2nd axis
zaxis: DeepImmutableObject<Vector3>
defines the value of the 3rd axis
result: T
defines the target matrix
Returns T
result input
Static Get As Matrix2x2Search playground for GetAsMatrix2x2
Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
Parameters
matrix: DeepImmutableObject<Matrix>
defines the matrix to use
Returns number[] | Float32Array
a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
Static Get As Matrix3x3Search playground for GetAsMatrix3x3
Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
Parameters
matrix: DeepImmutableObject<Matrix>
defines the matrix to use
Returns number[] | Float32Array
a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
Static Get Final MatrixSearch playground for GetFinalMatrix
Computes a complete transformation matrix Example Playground - https://playground.babylonjs.com/#AV9X17#113
Type Parameters
T extends Matrix<T>
Parameters
viewport: DeepImmutableObject<Viewport>
defines the viewport to use
world: DeepImmutable<T>
defines the world matrix
view: DeepImmutableObject<Matrix>
defines the view matrix
projection: DeepImmutableObject<Matrix>
defines the projection matrix
zmin: number
defines the near clip plane
zmax: number
defines the far clip plane
Returns T
the transformation matrix
Static IdentitySearch playground for Identity
Creates a new identity matrix
Returns Matrix
a new identity matrix
Static Identity To RefSearch playground for IdentityToRef
Creates a new identity matrix and stores the result in a given matrix
Type Parameters
T extends Matrix<T>
Parameters
result: T
defines the target matrix
Returns T
result input
Static InvertSearch playground for Invert
Creates a new matrix as the invert of a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#124
Type Parameters
T extends Matrix<T>
Parameters
source: DeepImmutable<T>
defines the source matrix
Returns T
the new matrix
Static LerpSearch playground for Lerp
Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". Example Playground - https://playground.babylonjs.com/#AV9X17#55
Type Parameters
T extends Matrix<T>
Parameters
startValue: DeepImmutable<T>
defines the start value
endValue: DeepImmutableObject<Matrix>
defines the end value
gradient: number
defines the gradient factor
Returns T
the new matrix
Static Lerp To RefSearch playground for LerpToRef
Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". Example Playground - https://playground.babylonjs.com/#AV9X17#54
Type Parameters
T extends Matrix<T>
Parameters
startValue: DeepImmutableObject<Matrix>
defines the start value
endValue: DeepImmutableObject<Matrix>
defines the end value
gradient: number
defines the gradient factor
result: T
defines the Matrix object where to store data
Returns T
result input
Static Look AtLHSearch playground for LookAtLH
Creates a new matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera. This function generates a matrix suitable for a left handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#58 Example Playground - https://playground.babylonjs.com/#AV9X17#59
Parameters
eye: DeepImmutableObject<Vector3>
defines the final position of the entity
target: DeepImmutableObject<Vector3>
defines where the entity should look at
up: DeepImmutableObject<Vector3>
defines the up vector for the entity
Returns Matrix
the new matrix
Static Look AtLHTo RefSearch playground for LookAtLHToRef
Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera. This function generates a matrix suitable for a left handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#60 Example Playground - https://playground.babylonjs.com/#AV9X17#61
Parameters
eye: DeepImmutableObject<Vector3>
defines the final position of the entity
target: DeepImmutableObject<Vector3>
defines where the entity should look at
up: DeepImmutableObject<Vector3>
defines the up vector for the entity
result: Matrix
defines the target matrix
Returns Matrix
result input
Static Look AtRHSearch playground for LookAtRH
Creates a new matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera. This function generates a matrix suitable for a right handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#62 Example Playground - https://playground.babylonjs.com/#AV9X17#63
Parameters
eye: DeepImmutableObject<Vector3>
defines the final position of the entity
target: DeepImmutableObject<Vector3>
defines where the entity should look at
up: DeepImmutableObject<Vector3>
defines the up vector for the entity
Returns Matrix
the new matrix
Static Look AtRHTo RefSearch playground for LookAtRHToRef
Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera. This function generates a matrix suitable for a right handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#64 Example Playground - https://playground.babylonjs.com/#AV9X17#65
Type Parameters
T extends Matrix<T>
Parameters
eye: DeepImmutableObject<Vector3>
defines the final position of the entity
target: DeepImmutableObject<Vector3>
defines where the entity should look at
up: DeepImmutableObject<Vector3>
defines the up vector for the entity
result: T
defines the target matrix
Returns T
result input
Static Look DirectionLHSearch playground for LookDirectionLH
Creates a new matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0) This function generates a matrix suitable for a left handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#66
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Matrix
the new matrix
Static Look DirectionLHTo RefSearch playground for LookDirectionLHToRef
Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0) This function generates a matrix suitable for a left handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#67
Type Parameters
T extends Matrix<T>
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
result: T
defines the target matrix
Returns T
result input
Static Look DirectionRHSearch playground for LookDirectionRH
Creates a new matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0) This function generates a matrix suitable for a right handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#68
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Matrix
the new matrix
Static Look DirectionRHTo RefSearch playground for LookDirectionRHToRef
Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0) This function generates a matrix suitable for a right handed coordinate system Example Playground - https://playground.babylonjs.com/#AV9X17#69
Type Parameters
T extends Matrix<T>
Parameters
forward: DeepImmutableObject<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
up: DeepImmutableObject<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
result: T
defines the target matrix
Returns T
result input
Static Oblique Off CenterLHTo RefSearch playground for ObliqueOffCenterLHToRef
Stores a left-handed oblique projection into a given matrix
Type Parameters
T extends Matrix<T>
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
length: number
Length of the shear
angle: number
Angle (along X/Y Plane) to apply shear
distance: number
Distance from shear point
result: T
defines the target matrix
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
Static Oblique Off CenterRHTo RefSearch playground for ObliqueOffCenterRHToRef
Stores a right-handed oblique projection into a given matrix
Type Parameters
T extends Matrix<T>
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
length: number
Length of the shear
angle: number
Angle (along X/Y Plane) to apply shear
distance: number
Distance from shear point
result: T
defines the target matrix
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
Static OrthoLHSearch playground for OrthoLH
Create a left-handed orthographic projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#70
Parameters
width: number
defines the viewport width
height: number
defines the viewport height
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns Matrix
a new matrix as a left-handed orthographic projection matrix
Static OrthoLHTo RefSearch playground for OrthoLHToRef
Store a left-handed orthographic projection to a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#71
Type Parameters
T extends Matrix<T>
Parameters
width: number
defines the viewport width
height: number
defines the viewport height
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
result: T
defines the target matrix
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
Static Ortho Off CenterLHSearch playground for OrthoOffCenterLH
Create a left-handed orthographic projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#72
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns Matrix
a new matrix as a left-handed orthographic projection matrix
Static Ortho Off CenterLHTo RefSearch playground for OrthoOffCenterLHToRef
Stores a left-handed orthographic projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#73
Type Parameters
T extends Matrix<T>
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
result: T
defines the target matrix
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
Static Ortho Off CenterRHSearch playground for OrthoOffCenterRH
Creates a right-handed orthographic projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#76
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns Matrix
a new matrix as a right-handed orthographic projection matrix
Static Ortho Off CenterRHTo RefSearch playground for OrthoOffCenterRHToRef
Stores a right-handed orthographic projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#77
Type Parameters
T extends Matrix<T>
Parameters
left: number
defines the viewport left coordinate
right: number
defines the viewport right coordinate
bottom: number
defines the viewport bottom coordinate
top: number
defines the viewport top coordinate
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
result: T
defines the target matrix
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
Static Perspective FovLHSearch playground for PerspectiveFovLH
Creates a left-handed perspective projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#78
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
defines the far clip plane. If 0, assume we are in "infinite zfar" mode
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Optional reverseDepthBufferMode: boolean
true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
Returns Matrix
a new matrix as a left-handed perspective projection matrix
Static Perspective FovLHTo RefSearch playground for PerspectiveFovLHToRef
Stores a left-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#81
Type Parameters
T extends Matrix<T>
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
defines the far clip plane. If 0, assume we are in "infinite zfar" mode
result: T
defines the target matrix
Optional isVerticalFovFixed: boolean
defines it the fov is vertically fixed (default) or horizontally
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Optional reverseDepthBufferMode: boolean
true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
Returns T
result input
Static Perspective FovRHSearch playground for PerspectiveFovRH
Creates a right-handed perspective projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#83
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
defines the far clip plane. If 0, assume we are in "infinite zfar" mode
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Optional reverseDepthBufferMode: boolean
true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
Returns Matrix
a new matrix as a right-handed perspective projection matrix
Static Perspective FovRHTo RefSearch playground for PerspectiveFovRHToRef
Stores a right-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#84
Type Parameters
T extends Matrix<T>
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
defines the far clip plane. If 0, assume we are in "infinite zfar" mode
result: T
defines the target matrix
Optional isVerticalFovFixed: boolean
defines it the fov is vertically fixed (default) or horizontally
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Optional reverseDepthBufferMode: boolean
true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
Returns T
result input
Static Perspective Fov ReverseLHTo RefSearch playground for PerspectiveFovReverseLHToRef
Stores a left-handed perspective projection into a given matrix with depth reversed Example Playground - https://playground.babylonjs.com/#AV9X17#89
Type Parameters
T extends Matrix<T>
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
not used as infinity is used as far clip
result: T
defines the target matrix
Optional isVerticalFovFixed: boolean
defines it the fov is vertically fixed (default) or horizontally
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Returns T
result input
Static Perspective Fov ReverseRHTo RefSearch playground for PerspectiveFovReverseRHToRef
Stores a right-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#90
Type Parameters
T extends Matrix<T>
Parameters
fov: number
defines the horizontal field of view
aspect: number
defines the aspect ratio
znear: number
defines the near clip plane
zfar: number
not used as infinity is used as far clip
result: T
defines the target matrix
Optional isVerticalFovFixed: boolean
defines it the fov is vertically fixed (default) or horizontally
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Returns T
result input
Static PerspectiveLHSearch playground for PerspectiveLH
Creates a left-handed perspective projection matrix Example Playground - https://playground.babylonjs.com/#AV9X17#85
Parameters
width: number
defines the viewport width
height: number
defines the viewport height
znear: number
defines the near clip plane
zfar: number
defines the far clip plane
Optional halfZRange: boolean
true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Optional projectionPlaneTilt: number
optional tilt angle of the projection plane around the X axis (horizontal)
Returns Matrix
a new matrix as a left-handed perspective projection matrix
Static ReflectionSearch playground for Reflection
Computes a reflection matrix from a plane Example Playground - https://playground.babylonjs.com/#AV9X17#87
Parameters
plane: DeepImmutableObject<IPlaneLike>
defines the reflection plane
Returns Matrix
a new matrix
Static Reflection To RefSearch playground for ReflectionToRef
Computes a reflection matrix from a plane Example Playground - https://playground.babylonjs.com/#AV9X17#88
Type Parameters
T extends Matrix<T>
Parameters
plane: DeepImmutableObject<IPlaneLike>
defines the reflection plane
result: T
defines the target matrix
Returns T
result input
Static Rotation Align To RefSearch playground for RotationAlignToRef
Takes normalised vectors and returns a rotation matrix to align "from" with "to". Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm Example Playground - https://playground.babylonjs.com/#AV9X17#93
Type Parameters
T extends Matrix<T>
Parameters
from: DeepImmutableObject<Vector3>
defines the vector to align
to: DeepImmutableObject<Vector3>
defines the vector to align to
result: T
defines the target matrix
Optional useYAxisForCoplanar: boolean
defines a boolean indicating that we should favor Y axis for coplanar vectors (default is false)
Returns T
result input
Static Rotation AxisSearch playground for RotationAxis
Creates a new rotation matrix for "angle" radians around the given axis Example Playground - https://playground.babylonjs.com/#AV9X17#96
Parameters
axis: DeepImmutableObject<Vector3>
defines the axis to use
angle: number
defines the angle (in radians) to use
Returns Matrix
the new matrix
Static Rotation Axis To RefSearch playground for RotationAxisToRef
Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#94
Type Parameters
T extends Matrix<T>
Parameters
axis: DeepImmutableObject<Vector3>
defines the axis to use
angle: number
defines the angle (in radians) to use
result: T
defines the target matrix
Returns T
result input
Static RotationXSearch playground for RotationX
Creates a new rotation matrix for "angle" radians around the X axis Example Playground - https://playground.babylonjs.com/#AV9X17#97
Parameters
angle: number
defines the angle (in radians) to use
Returns Matrix
the new matrix
Static RotationXTo RefSearch playground for RotationXToRef
Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#98
Type Parameters
T extends Matrix<T>
Parameters
angle: number
defines the angle (in radians) to use
result: T
defines the target matrix
Returns T
result input
Static RotationYSearch playground for RotationY
Creates a new rotation matrix for "angle" radians around the Y axis Example Playground - https://playground.babylonjs.com/#AV9X17#99
Parameters
angle: number
defines the angle (in radians) to use
Returns Matrix
the new matrix
Static RotationYTo RefSearch playground for RotationYToRef
Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#100
Type Parameters
T extends Matrix<T>
Parameters
angle: number
defines the angle (in radians) to use
result: T
defines the target matrix
Returns T
result input
Static Rotation Yaw Pitch RollSearch playground for RotationYawPitchRoll
Creates a rotation matrix Example Playground - https://playground.babylonjs.com/#AV9X17#103 Example Playground - https://playground.babylonjs.com/#AV9X17#105
Parameters
yaw: number
defines the yaw angle in radians (Y axis)
pitch: number
defines the pitch angle in radians (X axis)
roll: number
defines the roll angle in radians (Z axis)
Returns Matrix
the new rotation matrix
Static Rotation Yaw Pitch Roll To RefSearch playground for RotationYawPitchRollToRef
Creates a rotation matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#104
Type Parameters
T extends Matrix<T>
Parameters
yaw: number
defines the yaw angle in radians (Y axis)
pitch: number
defines the pitch angle in radians (X axis)
roll: number
defines the roll angle in radians (Z axis)
result: T
defines the target matrix
Returns T
result input
Static RotationZSearch playground for RotationZ
Creates a new rotation matrix for "angle" radians around the Z axis Example Playground - https://playground.babylonjs.com/#AV9X17#101
Parameters
angle: number
defines the angle (in radians) to use
Returns Matrix
the new matrix
Static RotationZTo RefSearch playground for RotationZToRef
Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#102
Type Parameters
T extends Matrix<T>
Parameters
angle: number
defines the angle (in radians) to use
result: T
defines the target matrix
Returns T
result input
Static ScalingSearch playground for Scaling
Creates a scaling matrix Example Playground - https://playground.babylonjs.com/#AV9X17#107
Parameters
x: number
defines the scale factor on X axis
y: number
defines the scale factor on Y axis
z: number
defines the scale factor on Z axis
Returns Matrix
the new matrix
Static Scaling To RefSearch playground for ScalingToRef
Creates a scaling matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#108
Type Parameters
T extends Matrix<T>
Parameters
x: number
defines the scale factor on X axis
y: number
defines the scale factor on Y axis
z: number
defines the scale factor on Z axis
result: T
defines the target matrix
Returns T
result input
Static TranslationSearch playground for Translation
Creates a translation matrix Example Playground - https://playground.babylonjs.com/#AV9X17#109
Parameters
x: number
defines the translation on X axis
y: number
defines the translation on Y axis
z: number
defines the translationon Z axis
Returns Matrix
the new matrix
Static Translation To RefSearch playground for TranslationToRef
Creates a translation matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#110
Type Parameters
T extends Matrix<T>
Parameters
x: number
defines the translation on X axis
y: number
defines the translation on Y axis
z: number
defines the translationon Z axis
result: T
defines the target matrix
Returns T
result input
Static TransposeSearch playground for Transpose
Compute the transpose of a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#111
Type Parameters
T extends Matrix<T>
Parameters
matrix: DeepImmutable<T>
defines the matrix to transpose
Returns T
the new matrix
Static Transpose To RefSearch playground for TransposeToRef
Compute the transpose of a matrix and store it in a target matrix Example Playground - https://playground.babylonjs.com/#AV9X17#112
Type Parameters
T extends Matrix<T>
Parameters
matrix: DeepImmutableObject<Matrix>
defines the matrix to transpose
result: T
defines the target matrix
Returns T
result input
Static ZeroSearch playground for Zero
Creates a new zero matrix
Returns Matrix
a new zero matrix
Class used to store matrix data (4x4) Note on matrix definitions in Babylon.js for setting values directly rather than using one of the methods available. Matrix size is given by rows x columns. A Vector3 is a 1 X 3 matrix [x, y, z].
In Babylon.js multiplying a 1 x 3 matrix by a 4 x 4 matrix is done using BABYLON.Vector4.TransformCoordinates(Vector3, Matrix). and extending the passed Vector3 to a Vector4, V = [x, y, z, 1]. Let M be a matrix with elements m(row, column), so that m(2, 3) is the element in row 2 column 3 of M.
Multiplication is of the form VM and has the resulting Vector4 VM = [xm(0, 0) + ym(1, 0) + zm(2, 0) + m(3, 0), xm(0, 1) + ym(1, 1) + zm(2, 1) + m(3, 1), xm(0, 2) + ym(1, 2) + zm(2, 2) + m(3, 2), xm(0, 3) + ym(1, 3) + zm(2, 3) + m(3, 3)]. On the web you will find many examples that use the opposite convention of MV, in which case to make use of the examples you will need to transpose the matrix.
Example Playground - Overview Linear Algebra - https://playground.babylonjs.com/#AV9X17 Example Playground - Overview Transformation - https://playground.babylonjs.com/#AV9X17#1 Example Playground - Overview Projection - https://playground.babylonjs.com/#AV9X17#2