Matrix3
Phaser.Math.Matrix3
A 3x3 column-major matrix stored as a Float32Array of 9 values. Used for 2D affine transformations, extracting the upper-left 3x3 portion of a Matrix4, and computing normal matrices for lighting calculations. Values are stored in column-major order to match WebGL conventions.
Defaults to the identity matrix when instantiated.
Constructor
new Matrix3([m])
Parameters
| name | type | optional | description |
|---|---|---|---|
| m | Phaser.Math.Matrix3 | Yes | Optional Matrix3 to copy values from. |
Scope: static
Source: src/math/Matrix3.js#L12
Since: 3.0.0
Public Members
val
val: Float32Array
Description:
The matrix values.
Source: src/math/Matrix3.js#L34
Since: 3.0.0
Public Methods
adjoint
instanceadjoint()
Description:
Calculate the adjoint, or adjugate, of this Matrix.
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L268
Since: 3.0.0
clone
instanceclone()
Description:
Make a clone of this Matrix3.
Returns: Phaser.Math.Matrix3 - A clone of this Matrix3.
Source: src/math/Matrix3.js#L55
Since: 3.0.0
copy
instancecopy(src)
Description:
Copy the values of a given Matrix into this Matrix.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| src | Phaser.Math.Matrix3 | No | The Matrix to copy the values from. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L83
Since: 3.0.0
determinant
instancedeterminant()
Description:
Calculate the determinant of this Matrix.
Returns: number - The determinant of this Matrix.
Source: src/math/Matrix3.js#L303
Since: 3.0.0
fromArray
instancefromArray(a)
Description:
Set the values of this Matrix from the given array.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| a | array | No | The array to copy the values from. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L141
Since: 3.0.0
fromMat4
instancefromMat4(m)
Description:
Copies the upper-left 3x3 values of a Matrix4 into this Matrix3, discarding the fourth row and column. This is useful when you need the rotation and scale portion of a transformation matrix without its translation component.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| m | Phaser.Math.Matrix4 | No | The Matrix4 to copy the values from. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L111
Since: 3.0.0
fromQuat
instancefromQuat(q)
Description:
Set the values of this Matrix from the given Quaternion.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| q | Phaser.Math.Quaternion | No | The Quaternion to set the values of this Matrix from. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L466
Since: 3.0.0
identity
instanceidentity()
Description:
Reset this Matrix to an identity (default) matrix.
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L168
Since: 3.0.0
invert
instanceinvert()
Description:
Invert this Matrix. Returns null if the matrix is not invertible (i.e. its determinant is zero).
Returns: Phaser.Math.Matrix3 - This Matrix3, or null if the matrix cannot be inverted.
Source: src/math/Matrix3.js#L218
Since: 3.0.0
multiply
instancemultiply(src)
Description:
Multiply this Matrix by the given Matrix.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| src | Phaser.Math.Matrix3 | No | The Matrix to multiply this Matrix by. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L328
Since: 3.0.0
normalFromMat4
instancenormalFromMat4(m)
Description:
Derives a normal matrix from the given Matrix4. The normal matrix is the transpose of the inverse of the Matrix4, and is used in lighting calculations to correctly transform surface normals when non-uniform scaling is applied. Returns null if the Matrix4 is not invertible (i.e. its determinant is zero).
Parameters:
| name | type | optional | description |
|---|---|---|---|
| m | Phaser.Math.Matrix4 | No | The Matrix4 to derive the normal matrix from. |
Returns: Phaser.Math.Matrix3 - This Matrix3, or null if the Matrix4 cannot be inverted.
Source: src/math/Matrix3.js#L516
Since: 3.0.0
rotate
instancerotate(rad)
Description:
Apply a rotation transformation to this Matrix.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| rad | number | No | The angle in radians to rotate by. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L402
Since: 3.0.0
scale
instancescale(v)
Description:
Apply a scale transformation to this Matrix.
Uses the x and y components of the given Vector to scale the Matrix.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| v | Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4 | No |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L437
Since: 3.0.0
set
instanceset(src)
Description:
This method is an alias for Matrix3.copy.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| src | Phaser.Math.Matrix3 | No | The Matrix to set the values of this Matrix from. |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L68
Since: 3.0.0
translate
instancetranslate(v)
Description:
Translate this Matrix using the given Vector.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| v | Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4 | No |
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L379
Since: 3.0.0
transpose
instancetranspose()
Description:
Transpose this Matrix.
Returns: Phaser.Math.Matrix3 - This Matrix3.
Source: src/math/Matrix3.js#L193
Since: 3.0.0