Class Matrix
Implements
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
Creates an empty matrix (filled with zeros)
Returns Matrix
Properties
Readonlydimension
Readonlyrank
update Flag
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
-
get m(): DeepImmutableArray<number>
Gets the internal data of the matrix
Returns DeepImmutableArray<number>
StaticIdentity Read Only
-
Gets an identity matrix that must not be updated
Returns DeepImmutable<Matrix>
StaticUse64 Bits
-
get Use64Bits(): boolean
Gets the precision of matrix computations
Returns boolean
Methods
add
-
Adds the current matrix with a second one Example Playground - https://playground.babylonjs.com/#AV9X17#44
Parameters
- other: DeepImmutable<Matrix>
defines the matrix to add
Returns Matrix
a new matrix as the addition of the current matrix and the given one
- other: DeepImmutable<Matrix>
add At Index
-
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 this
the current updated matrix
- index: number
add In Place
-
Set the instance coordinates by adding the given instance coordinates
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
the current updated instance
- other: DeepImmutable<Matrix>
add In Place From Floats
-
addInPlaceFromFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisAdds the given coordinates to the current instance
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]the floats to add
Returns this
the current updated instance
- ...floats: [
add To Ref
-
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
Parameters
- other: DeepImmutable<Matrix>
defines the matrix to add
- result: T
defines the target matrix
Returns T
result input
add To Self
-
Adds in place the given matrix to the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#46
Parameters
- other: DeepImmutable<Matrix>
defines the second operand
Returns this
the current updated matrix
- other: DeepImmutable<Matrix>
add Translation From Floats
-
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 this
the current updated matrix
- x: number
as Array
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]
Returns [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]
the matrix underlying array.
clone
-
Clone the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#18
Returns Matrix
a new matrix from the current matrix
copy From
-
Copy the current matrix from the given one Example Playground - https://playground.babylonjs.com/#AV9X17#21
Parameters
- other: DeepImmutable<Matrix>
defines the source matrix
Returns this
the current updated matrix
- other: DeepImmutable<Matrix>
copy From Floats
-
copyFromFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisSets all the matrix values from a float array
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]the 16 float values to set
Returns this
the current updated matrix
- ...floats: [
copy To Array
-
Populates the given array from the starting index with the current matrix values
Parameters
- array: number[] | Float32Array<ArrayBufferLike>
defines the target array
- offset: number = 0
defines the offset in the target array where to start storing values
Returns this
the current matrix
- array: number[] | Float32Array<ArrayBufferLike>
decompose
-
decompose(
scale?: Vector3,
rotation?: Quaternion,
translation?: Vector3,
preserveScalingNode?: TransformNode,
useAbsoluteScaling?: boolean,
): booleanDecomposes the current Matrix into a translation, rotation and scaling components Example Playground - https://playground.babylonjs.com/#AV9X17#12
Parameters
Optionalscale: Vector3defines the scale vector3 given as a reference to update
Optionalrotation: Quaterniondefines the rotation quaternion given as a reference to update
Optionaltranslation: Vector3defines the translation vector3 given as a reference to update
OptionalpreserveScalingNode: TransformNodeUse scaling sign coming from this node. Otherwise scaling sign might change.
- useAbsoluteScaling: boolean = true
Use scaling sign coming from this absoluteScaling when true or scaling otherwise.
Returns boolean
true if operation was successful
decompose To Transform Node
-
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
- node: TransformNode
determinant
-
Gets the determinant of the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#34
Returns number
the matrix determinant
divide
-
Returns a new instance set with the instance coordinates divided by the given one coordinates
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns Matrix
a new instance
- other: DeepImmutable<Matrix>
divide In Place
-
Divides the current instance coordinates by the given ones
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
the current updated instance
- other: DeepImmutable<Matrix>
divide To Ref
-
Sets the "result" coordinates with the instance coordinates divided by the given one coordinates
Type Parameters
- T extends Matrix
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
- result: T
defines the target instance
Returns T
result input
equals
-
Check equality between this matrix and a second one
Parameters
- value: DeepImmutable<Matrix>
defines the second matrix to compare
Returns boolean
true is the current matrix and the given one values are strictly equal
- value: DeepImmutable<Matrix>
equals To Floats
-
equalsToFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): booleanReturns true if the current Vectoe coordinates equals the given floats
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]defines the coordinates to compare against
Returns boolean
true if both instances are equal
- ...floats: [
equals With Epsilon
-
Gets a boolean if two instances are equals (using an epsilon value)
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
- epsilon: number = 0
defines the minimal distance to consider equality
Returns boolean
true if the given instance coordinates are close to the current ones by a distance of epsilon.
- other: DeepImmutable<Matrix>
floor
-
Gets a new instance from current instance floored values eg (1.2, 2.31) returns (1, 2)
Returns Matrix
a new instance
floor To Ref
fract
-
Gets a new instance from current instance fractional values eg (1.2, 2.31) returns (0.2, 0.31)
Returns Matrix
a new instance
fract To Ref
from Array
-
Update the current instance from an array
Parameters
- array: FloatArray
defines the destination array
- index: number = 0
defines the offset in the destination array
Returns this
the current instance
- array: FloatArray
get Class Name
-
Returns the name of the current matrix class
Returns string
the string "Matrix"
get Hash Code
-
Gets the hash code of the current matrix
Returns number
the hash code
get Rotation Matrix
-
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 Ref
get Row
-
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
- index: number
get Row To Ref
-
Gets specific row of the matrix to ref Example Playground - https://playground.babylonjs.com/#AV9X17#36
Type Parameters
- T extends Vector4
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 Translation
-
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 Ref
-
Fill a Vector3 with the extracted translation from the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#123
Type Parameters
- T extends Vector3
Parameters
- result: T
defines the Vector3 where to store the translation
Returns T
the current matrix
invert
-
Inverts the current matrix in place Example Playground - https://playground.babylonjs.com/#AV9X17#118
Returns this
the current inverted matrix
invert To Ref
-
Sets the given matrix to the current inverted Matrix Example Playground - https://playground.babylonjs.com/#AV9X17#119
Type Parameters
- T extends Matrix
Parameters
- other: T
defines the target matrix
Returns T
result input
is Identity
-
Check if the current matrix is identity
Returns boolean
true is the matrix is the identity matrix
is Identity As3x2
-
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 Updated
-
Update the updateFlag to indicate that the matrix has been updated
Returns void
maximize In Place
-
Updates the current instance with the maximal coordinate values between its and the given instance ones.
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
this current updated instance
- other: DeepImmutable<Matrix>
maximize In Place From Floats
-
maximizeInPlaceFromFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisUpdates the current instance with the maximal coordinate values between its and the given floats.
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]defines the floats to compare against
Returns this
this current updated instance
- ...floats: [
minimize In Place
-
Updates the current instance with the minmal coordinate values between its and the given instance ones.
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
this current updated instance
- other: DeepImmutable<Matrix>
minimize In Place From Floats
-
minimizeInPlaceFromFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisUpdates the current instance with the minmal coordinate values between its and the given floats.
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]defines the floats to compare against
Returns this
this current updated instance
- ...floats: [
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: DeepImmutable<Matrix>
defines the second operand
Returns Matrix
a new matrix set with the multiplication result of the current Matrix and the given one
- other: DeepImmutable<Matrix>
multiply At Index
-
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 this
the current updated matrix
- index: number
multiply By Floats
-
multiplyByFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisThis method performs a component-by-component multiplication of the current matrix with the array of transmitted numbers. Use multiply or multiplyToRef for matrix multiplication.
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]defines the array of numbers to multiply the matrix by
Returns this
the current updated matrix
- ...floats: [
multiply By Floats To Ref
-
multiplyByFloatsToRef<T extends Matrix>(
...args: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
T,
],
): TMultiples the current matrix by the given floats and stores them in the given ref
Type Parameters
- T extends Matrix
Parameters
- ...args: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
T,
]The floats and ref
Returns T
The updated ref
multiply In Place
-
This method performs component-by-component in-place multiplication, rather than true matrix multiplication. Use multiply or multiplyToRef for matrix multiplication.
Parameters
- other: DeepImmutable<Matrix>
defines the second operand
Returns this
the current updated matrix
- other: DeepImmutable<Matrix>
multiply To Array
-
multiplyToArray(
other: DeepImmutable<Matrix>,
result: number[] | Float32Array<ArrayBufferLike>,
offset: number,
): thisSets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
Parameters
- other: DeepImmutable<Matrix>
defines the second operand
- result: number[] | Float32Array<ArrayBufferLike>
defines the array where to store the multiplication
- offset: number
defines the offset in the target array where to start storing values
Returns this
the current matrix
- other: DeepImmutable<Matrix>
multiply To Ref
-
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
Parameters
- other: DeepImmutable<Matrix>
defines the second operand
- result: T
defines the matrix where to store the multiplication
Returns T
result input
negate
negate In Place
-
Negate this instance in place
Returns this
this
negate To Ref
remove Rotation And Scaling
-
Remove rotation and scaling part from the matrix
Returns this
the updated matrix
reset
-
Sets all the matrix elements to zero
Returns this
the current matrix
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: number
scale And Add To Ref
scale In Place
-
Multiply the instance coordinates by
Parameters
- scale: number
defines the scaling factor
Returns this
the current updated instance
- scale: number
scale To Ref
set
-
set(
...values: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): thisSets the matrix values
Parameters
- ...values: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]the 16 values to set
Returns this
the current updated matrix
- ...values: [
set All
-
Sets all the matrix values to the given value
Parameters
- value: number
the value to set
Returns this
the current updated matrix
- value: number
set Row
-
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 this
the updated current matrix
- index: number
set Row From Floats
-
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 this
the updated current matrix
- index: number
set Translation
-
Inserts the translation vector in the current matrix Example Playground - https://playground.babylonjs.com/#AV9X17#121
Parameters
- vector3: DeepImmutable<Vector3>
defines the translation to insert
Returns this
the current updated matrix
- vector3: DeepImmutable<Vector3>
set Translation From Floats
-
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 this
the current updated matrix
- x: number
subtract
-
Returns a new instance set with the subtracted coordinates of other's coordinates from the current coordinates.
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
a new instance
- other: DeepImmutable<Matrix>
subtract From Floats
-
subtractFromFloats(
...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
],
): MatrixReturns a new instance set with the subtraction of the given floats from the current instance coordinates
Parameters
- ...floats: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
]the coordinates to subtract
Returns Matrix
the resulting instance
- ...floats: [
subtract From Floats To Ref
-
subtractFromFloatsToRef<T extends Matrix>(
...args: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
T,
],
): TSubtracts the given floats from the current instance coordinates and set the given instance "result" with this result Note: Implementation uses array magic so types may be confusing.
Type Parameters
- T extends Matrix
Parameters
- ...args: [
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
T,
]the coordinates to subtract with the last element as the result
Returns T
the result
subtract In Place
-
Sets the current instance coordinates by subtracting from it the given one coordinates
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
Returns this
the current updated instance
- other: DeepImmutable<Matrix>
subtract To Ref
-
Sets the "result" coordinates with the subtraction of the other's coordinates from the current coordinates.
Type Parameters
- T extends Matrix
Parameters
- other: DeepImmutable<Matrix>
defines the other instance
- result: T
defines the target instance
Returns T
result input
to Array
Returns FloatArray
Parameters
- array: FloatArray
The destination array
- index: number
The destination index to start ay
Returns this
the matrix
toggle Model Matrix Hand In Place
-
Toggles model matrix from being right handed to left handed in place and vice versa
Returns this
the current updated matrix
toggle Projection Matrix Hand In Place
-
Toggles projection matrix from being right handed to left handed in place and vice versa
Returns this
the current updated matrix
to Normal Matrix
-
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
Parameters
- ref: T
matrix to store the result
Returns T
the reference matrix
to String
-
Gets a string with the Matrix values
Returns string
a string with the Matrix values
transpose
-
Compute the transpose of the matrix Example Playground - https://playground.babylonjs.com/#AV9X17#40
Returns Matrix
the new transposed matrix
transpose To Ref
-
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
Parameters
- result: T
defines the target matrix
Returns T
result input
StaticCompose
-
Compose(
scale: DeepImmutable<Vector3>,
rotation: DeepImmutable<Quaternion>,
translation: DeepImmutable<Vector3>,
): MatrixCreates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3) Example Playground - https://playground.babylonjs.com/#AV9X17#24
Parameters
- scale: DeepImmutable<Vector3>
defines the scale vector3
- rotation: DeepImmutable<Quaternion>
defines the rotation quaternion
- translation: DeepImmutable<Vector3>
defines the translation vector3
Returns Matrix
a new matrix
- scale: DeepImmutable<Vector3>
StaticCompose To Ref
-
ComposeToRef<T extends Matrix>(
scale: DeepImmutable<Vector3>,
rotation: DeepImmutable<Quaternion>,
translation: DeepImmutable<Vector3>,
result: T,
): TSets 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
Parameters
- scale: DeepImmutable<Vector3>
defines the scale vector3
- rotation: DeepImmutable<Quaternion>
defines the rotation quaternion
- translation: DeepImmutable<Vector3>
defines the translation vector3
- result: T
defines the target matrix
Returns T
result input
StaticDecompose Lerp
-
DecomposeLerp(
startValue: DeepImmutable<Matrix>,
endValue: DeepImmutable<Matrix>,
gradient: number,
): MatrixBuilds 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
Parameters
- startValue: DeepImmutable<Matrix>
defines the first matrix
- endValue: DeepImmutable<Matrix>
defines the second matrix
- gradient: number
defines the gradient between the two matrices
Returns Matrix
the new matrix
StaticDecompose Lerp To Ref
-
DecomposeLerpToRef<T extends Matrix>(
startValue: DeepImmutable<Matrix>,
endValue: DeepImmutable<Matrix>,
gradient: number,
result: T,
): TUpdate 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
Parameters
- startValue: DeepImmutable<Matrix>
defines the first matrix
- endValue: DeepImmutable<Matrix>
defines the second matrix
- gradient: number
defines the gradient between the two matrices
- result: T
defines the target matrix
Returns T
result input
StaticFrom Array
-
Creates a matrix from an array Example Playground - https://playground.babylonjs.com/#AV9X17#42
Parameters
- array: DeepImmutable<ArrayLike<number>>
defines the source array
- offset: number = 0
defines an offset in the source array
Returns Matrix
a new Matrix set from the starting index of the given array
- array: DeepImmutable<ArrayLike<number>>
StaticFrom Array To Ref
-
FromArrayToRef<T extends Matrix>(
array: DeepImmutable<ArrayLike<number>>,
offset: number,
result: T,
): TCopy the content of an array into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#43
Type Parameters
- T extends Matrix
Parameters
- array: DeepImmutable<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
StaticFrom Float32 Array To Ref Scaled
-
FromFloat32ArrayToRefScaled<T extends Matrix>(
array: DeepImmutable<number[] | Float32Array<ArrayBufferLike>>,
offset: number,
scale: number,
result: T,
): TStores 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
Parameters
- array: DeepImmutable<number[] | Float32Array<ArrayBufferLike>>
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
StaticFrom Quaternion To Ref
-
Creates a rotation matrix from a quaternion and stores it in a target matrix
Type Parameters
- T extends Matrix
Parameters
- quat: DeepImmutable<Quaternion>
defines the quaternion to use
- result: T
defines the target matrix
Returns T
result input
StaticFrom Values
-
FromValues(
initialM11: number,
initialM12: number,
initialM13: number,
initialM14: number,
initialM21: number,
initialM22: number,
initialM23: number,
initialM24: number,
initialM31: number,
initialM32: number,
initialM33: number,
initialM34: number,
initialM41: number,
initialM42: number,
initialM43: number,
initialM44: number,
): MatrixCreates 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
- initialM11: number
StaticFrom Values To Ref
-
FromValuesToRef(
initialM11: number,
initialM12: number,
initialM13: number,
initialM14: number,
initialM21: number,
initialM22: number,
initialM23: number,
initialM24: number,
initialM31: number,
initialM32: number,
initialM33: number,
initialM34: number,
initialM41: number,
initialM42: number,
initialM43: number,
initialM44: number,
result: Matrix,
): voidStores 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
- initialM11: number
StaticFrom XYZ Axes To Ref
-
FromXYZAxesToRef<T extends Matrix>(
xaxis: DeepImmutable<Vector3>,
yaxis: DeepImmutable<Vector3>,
zaxis: DeepImmutable<Vector3>,
result: T,
): TSets the given matrix as a rotation matrix composed from the 3 left handed axes
Type Parameters
- T extends Matrix
Parameters
- xaxis: DeepImmutable<Vector3>
defines the value of the 1st axis
- yaxis: DeepImmutable<Vector3>
defines the value of the 2nd axis
- zaxis: DeepImmutable<Vector3>
defines the value of the 3rd axis
- result: T
defines the target matrix
Returns T
result input
StaticGet As Matrix2x2
-
Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
Parameters
- matrix: DeepImmutable<Matrix>
defines the matrix to use
Returns number[] | Float32Array<ArrayBufferLike>
a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
- matrix: DeepImmutable<Matrix>
StaticGet As Matrix3x3
-
Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
Parameters
- matrix: DeepImmutable<Matrix>
defines the matrix to use
Returns number[] | Float32Array<ArrayBufferLike>
a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
- matrix: DeepImmutable<Matrix>
StaticGet Final Matrix
-
GetFinalMatrix(
viewport: DeepImmutable<Viewport>,
world: DeepImmutable<Matrix>,
view: DeepImmutable<Matrix>,
projection: DeepImmutable<Matrix>,
zmin: number,
zmax: number,
): MatrixComputes a complete transformation matrix Example Playground - https://playground.babylonjs.com/#AV9X17#113
Parameters
- viewport: DeepImmutable<Viewport>
defines the viewport to use
- world: DeepImmutable<Matrix>
defines the world matrix
- view: DeepImmutable<Matrix>
defines the view matrix
- projection: DeepImmutable<Matrix>
defines the projection matrix
- zmin: number
defines the near clip plane
- zmax: number
defines the far clip plane
Returns Matrix
the transformation matrix
- viewport: DeepImmutable<Viewport>
StaticIdentity
StaticIdentity To Ref
StaticInvert
-
Creates a new matrix as the invert of a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#124
Parameters
- source: DeepImmutable<Matrix>
defines the source matrix
Returns Matrix
the new matrix
- source: DeepImmutable<Matrix>
StaticLerp
-
Lerp(
startValue: DeepImmutable<Matrix>,
endValue: DeepImmutable<Matrix>,
gradient: number,
): MatrixReturns 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
Parameters
- startValue: DeepImmutable<Matrix>
defines the start value
- endValue: DeepImmutable<Matrix>
defines the end value
- gradient: number
defines the gradient factor
Returns Matrix
the new matrix
- startValue: DeepImmutable<Matrix>
StaticLerp To Ref
-
LerpToRef<T extends Matrix>(
startValue: DeepImmutable<Matrix>,
endValue: DeepImmutable<Matrix>,
gradient: number,
result: T,
): TSet 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
Parameters
- startValue: DeepImmutable<Matrix>
defines the start value
- endValue: DeepImmutable<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
StaticLook At LH
-
LookAtLH(
eye: DeepImmutable<Vector3>,
target: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
): MatrixCreates 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: DeepImmutable<Vector3>
defines the final position of the entity
- target: DeepImmutable<Vector3>
defines where the entity should look at
- up: DeepImmutable<Vector3>
defines the up vector for the entity
Returns Matrix
the new matrix
- eye: DeepImmutable<Vector3>
StaticLook At LH To Ref
-
LookAtLHToRef(
eye: DeepImmutable<Vector3>,
target: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
result: Matrix,
): MatrixSets 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: DeepImmutable<Vector3>
defines the final position of the entity
- target: DeepImmutable<Vector3>
defines where the entity should look at
- up: DeepImmutable<Vector3>
defines the up vector for the entity
- result: Matrix
defines the target matrix
Returns Matrix
result input
- eye: DeepImmutable<Vector3>
StaticLook At RH
-
LookAtRH(
eye: DeepImmutable<Vector3>,
target: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
): MatrixCreates 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: DeepImmutable<Vector3>
defines the final position of the entity
- target: DeepImmutable<Vector3>
defines where the entity should look at
- up: DeepImmutable<Vector3>
defines the up vector for the entity
Returns Matrix
the new matrix
- eye: DeepImmutable<Vector3>
StaticLook At RH To Ref
-
LookAtRHToRef<T extends Matrix>(
eye: DeepImmutable<Vector3>,
target: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
result: T,
): TSets 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
Parameters
- eye: DeepImmutable<Vector3>
defines the final position of the entity
- target: DeepImmutable<Vector3>
defines where the entity should look at
- up: DeepImmutable<Vector3>
defines the up vector for the entity
- result: T
defines the target matrix
Returns T
result input
StaticLook Direction LH
-
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: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Matrix
the new matrix
- forward: DeepImmutable<Vector3>
StaticLook Direction LH To Ref
-
LookDirectionLHToRef<T extends Matrix>(
forward: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
result: T,
): TSets 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
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<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
StaticLook Direction RH
-
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: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<Vector3>
defines the up vector for the entity - Must be normalized and orthogonal to forward.
Returns Matrix
the new matrix
- forward: DeepImmutable<Vector3>
StaticLook Direction RH To Ref
-
LookDirectionRHToRef<T extends Matrix>(
forward: DeepImmutable<Vector3>,
up: DeepImmutable<Vector3>,
result: T,
): TSets 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
Parameters
- forward: DeepImmutable<Vector3>
defines the forward direction - Must be normalized and orthogonal to up.
- up: DeepImmutable<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
StaticOblique Off Center LH To Ref
-
ObliqueOffCenterLHToRef<T extends Matrix>(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
length: number,
angle: number,
distance: number,
result: T,
halfZRange?: boolean,
): TStores a left-handed oblique projection into a given matrix
Type Parameters
- T extends Matrix
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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
StaticOblique Off Center RH To Ref
-
ObliqueOffCenterRHToRef<T extends Matrix>(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
length: number,
angle: number,
distance: number,
result: T,
halfZRange?: boolean,
): TStores a right-handed oblique projection into a given matrix
Type Parameters
- T extends Matrix
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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
StaticOrtho LH
-
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
OptionalhalfZRange: booleantrue 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
- width: number
StaticOrtho LH To Ref
-
OrthoLHToRef<T extends Matrix>(
width: number,
height: number,
znear: number,
zfar: number,
result: T,
halfZRange?: boolean,
): TStore a left-handed orthographic projection to a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#71
Type Parameters
- T extends Matrix
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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
StaticOrtho Off Center LH
-
OrthoOffCenterLH(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
halfZRange?: boolean,
): MatrixCreate 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
OptionalhalfZRange: booleantrue 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
- left: number
StaticOrtho Off Center LH To Ref
-
OrthoOffCenterLHToRef<T extends Matrix>(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
result: T,
halfZRange?: boolean,
): TStores a left-handed orthographic projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#73
Type Parameters
- T extends Matrix
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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
StaticOrtho Off Center RH
-
OrthoOffCenterRH(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
halfZRange?: boolean,
): MatrixCreates 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
OptionalhalfZRange: booleantrue 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
- left: number
StaticOrtho Off Center RH To Ref
-
OrthoOffCenterRHToRef<T extends Matrix>(
left: number,
right: number,
bottom: number,
top: number,
znear: number,
zfar: number,
result: T,
halfZRange?: boolean,
): TStores a right-handed orthographic projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#77
Type Parameters
- T extends Matrix
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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
Returns T
result input
StaticPerspective Fov LH
-
PerspectiveFovLH(
fov: number,
aspect: number,
znear: number,
zfar: number,
halfZRange?: boolean,
projectionPlaneTilt?: number,
reverseDepthBufferMode?: boolean,
): MatrixCreates 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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
- reverseDepthBufferMode: boolean = false
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
- fov: number
StaticPerspective Fov LH To Ref
-
PerspectiveFovLHToRef<T extends Matrix>(
fov: number,
aspect: number,
znear: number,
zfar: number,
result: T,
isVerticalFovFixed?: boolean,
halfZRange?: boolean,
projectionPlaneTilt?: number,
reverseDepthBufferMode?: boolean,
): TStores a left-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#81
Type Parameters
- T extends Matrix
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
- isVerticalFovFixed: boolean = true
defines it the fov is vertically fixed (default) or horizontally
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
- reverseDepthBufferMode: boolean = false
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
StaticPerspective Fov Reverse LH To Ref
-
PerspectiveFovReverseLHToRef<T extends Matrix>(
fov: number,
aspect: number,
znear: number,
zfar: number,
result: T,
isVerticalFovFixed?: boolean,
halfZRange?: boolean,
projectionPlaneTilt?: number,
): TStores 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
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
- isVerticalFovFixed: boolean = true
defines it the fov is vertically fixed (default) or horizontally
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
Returns T
result input
StaticPerspective Fov Reverse RH To Ref
-
PerspectiveFovReverseRHToRef<T extends Matrix>(
fov: number,
aspect: number,
znear: number,
zfar: number,
result: T,
isVerticalFovFixed?: boolean,
halfZRange?: boolean,
projectionPlaneTilt?: number,
): TStores a right-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#90
Type Parameters
- T extends Matrix
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
- isVerticalFovFixed: boolean = true
defines it the fov is vertically fixed (default) or horizontally
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
Returns T
result input
StaticPerspective Fov RH
-
PerspectiveFovRH(
fov: number,
aspect: number,
znear: number,
zfar: number,
halfZRange?: boolean,
projectionPlaneTilt?: number,
reverseDepthBufferMode?: boolean,
): MatrixCreates 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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
- reverseDepthBufferMode: boolean = false
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
- fov: number
StaticPerspective Fov RH To Ref
-
PerspectiveFovRHToRef<T extends Matrix>(
fov: number,
aspect: number,
znear: number,
zfar: number,
result: T,
isVerticalFovFixed?: boolean,
halfZRange?: boolean,
projectionPlaneTilt?: number,
reverseDepthBufferMode?: boolean,
): TStores a right-handed perspective projection into a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#84
Type Parameters
- T extends Matrix
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
- isVerticalFovFixed: boolean = true
defines it the fov is vertically fixed (default) or horizontally
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
- reverseDepthBufferMode: boolean = false
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
StaticPerspective LH
-
PerspectiveLH(
width: number,
height: number,
znear: number,
zfar: number,
halfZRange?: boolean,
projectionPlaneTilt?: number,
): MatrixCreates 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
OptionalhalfZRange: booleantrue to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
- projectionPlaneTilt: number = 0
optional tilt angle of the projection plane around the X axis (horizontal)
Returns Matrix
a new matrix as a left-handed perspective projection matrix
- width: number
StaticReflection
-
Computes a reflection matrix from a plane Example Playground - https://playground.babylonjs.com/#AV9X17#87
Parameters
- plane: DeepImmutable<IPlaneLike>
defines the reflection plane
Returns Matrix
a new matrix
- plane: DeepImmutable<IPlaneLike>
StaticReflection To Ref
-
Computes a reflection matrix from a plane Example Playground - https://playground.babylonjs.com/#AV9X17#88
Type Parameters
- T extends Matrix
Parameters
- plane: DeepImmutable<IPlaneLike>
defines the reflection plane
- result: T
defines the target matrix
Returns T
result input
StaticRotation Align To Ref
-
RotationAlignToRef<T extends Matrix>(
from: DeepImmutable<Vector3>,
to: DeepImmutable<Vector3>,
result: T,
useYAxisForCoplanar?: boolean,
): TTakes 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
Parameters
- from: DeepImmutable<Vector3>
defines the vector to align
- to: DeepImmutable<Vector3>
defines the vector to align to
- result: T
defines the target matrix
- useYAxisForCoplanar: boolean = false
defines a boolean indicating that we should favor Y axis for coplanar vectors (default is false)
Returns T
result input
StaticRotation Axis
-
Creates a new rotation matrix for "angle" radians around the given axis Example Playground - https://playground.babylonjs.com/#AV9X17#96
Parameters
- axis: DeepImmutable<Vector3>
defines the axis to use
- angle: number
defines the angle (in radians) to use
Returns Matrix
the new matrix
- axis: DeepImmutable<Vector3>
StaticRotation Axis To Ref
-
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
Parameters
- axis: DeepImmutable<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
StaticRotation X
-
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
- angle: number
StaticRotation X To Ref
-
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
Parameters
- angle: number
defines the angle (in radians) to use
- result: T
defines the target matrix
Returns T
result input
StaticRotation Y
-
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
- angle: number
StaticRotation Yaw Pitch Roll
-
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
- yaw: number
StaticRotation Yaw Pitch Roll To Ref
-
RotationYawPitchRollToRef<T extends Matrix>(
yaw: number,
pitch: number,
roll: number,
result: T,
): TCreates a rotation matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#104
Type Parameters
- T extends Matrix
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
StaticRotation Y To Ref
-
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
Parameters
- angle: number
defines the angle (in radians) to use
- result: T
defines the target matrix
Returns T
result input
StaticRotation Z
-
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
- angle: number
StaticRotation Z To Ref
-
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
Parameters
- angle: number
defines the angle (in radians) to use
- result: T
defines the target matrix
Returns T
result input
StaticScaling
-
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
- x: number
StaticScaling To Ref
-
Creates a scaling matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#108
Type Parameters
- T extends Matrix
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
StaticTranslation
-
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
- x: number
StaticTranslation To Ref
-
Creates a translation matrix and stores it in a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#110
Type Parameters
- T extends Matrix
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
StaticTranspose
-
Compute the transpose of a given matrix Example Playground - https://playground.babylonjs.com/#AV9X17#111
Parameters
- matrix: DeepImmutable<Matrix>
defines the matrix to transpose
Returns Matrix
the new matrix
- matrix: DeepImmutable<Matrix>
StaticTranspose To Ref
-
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
Parameters
- matrix: DeepImmutable<Matrix>
defines the matrix to transpose
- result: T
defines the target matrix
Returns T
result input
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