Class: Matrix4

Phaser.Math. Matrix4

A four-dimensional matrix.


new Matrix4( [m])

Parameters:
Name Type Argument Description
m Phaser.Math.Matrix4 <optional>

Optional Matrix4 to copy values from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 14)

Members


val :Float32Array

The matrix values.

Type:
  • Float32Array
Since: 3.0.0
Source: src/math/Matrix4.js (Line 31)

Methods


adjoint()

Calculate the adjoint, or adjugate, of this Matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 380)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

clone()

Make a clone of this Matrix4.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 52)
Returns:

A clone of this Matrix4.

Type
Phaser.Math.Matrix4

copy(src)

Copy the values of a given Matrix into this Matrix.

Parameters:
Name Type Description
src Phaser.Math.Matrix4

The Matrix to copy the values from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 82)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

determinant()

Calculate the determinant of this Matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 432)
Returns:

The determinant of this Matrix.

Type
number

fromArray(a)

Set the values of this Matrix from the given array.

Parameters:
Name Type Description
a array

The array to copy the values from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 117)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

fromQuat(q)

Set the values of this Matrix from the given Quaternion.

Parameters:
Name Type Description
q Phaser.Math.Quaternion

The Quaternion to set the values of this Matrix from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 951)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

fromRotationTranslation(q, v)

Set the values of this Matrix from the given rotation Quaternion and translation Vector.

Parameters:
Name Type Description
q Phaser.Math.Quaternion

The Quaternion to set rotation from.

v Phaser.Math.Vector3

The Vector to set translation from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 891)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

frustum(left, right, bottom, top, near, far)

Generate a frustum matrix with the given bounds.

Parameters:
Name Type Description
left number

The left bound of the frustum.

right number

The right bound of the frustum.

bottom number

The bottom bound of the frustum.

top number

The top bound of the frustum.

near number

The near bound of the frustum.

far number

The far bound of the frustum.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1009)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

identity()

Reset this Matrix to an identity (default) matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 236)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

invert()

Invert this Matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 303)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

lookAt(eye, center, up)

Generate a look-at matrix with the given eye position, focal point, and up axis.

Parameters:
Name Type Description
eye Phaser.Math.Vector3

Position of the viewer

center Phaser.Math.Vector3

Point the viewer is looking at

up Phaser.Math.Vector3

vec3 pointing up.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1187)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

makeRotationAxis(axis, angle)

Derive a rotation matrix around the given axis.

Parameters:
Name Type Description
axis Phaser.Math.Vector3 | Phaser.Math.Vector4

The rotation axis.

angle number

The rotation angle in radians.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 662)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

multiply(src)

Multiply this Matrix by the given Matrix.

Parameters:
Name Type Description
src Phaser.Math.Matrix4

The Matrix to multiply this Matrix by.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 481)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

multiplyLocal(src)

[description]

Parameters:
Name Type Description
src Phaser.Math.Matrix4

[description]

Since: 3.0.0
Source: src/math/Matrix4.js (Line 561)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

ortho(left, right, bottom, top, near, far)

Generate an orthogonal projection matrix with the given bounds.

Parameters:
Name Type Description
left number

The left bound of the frustum.

right number

The right bound of the frustum.

bottom number

The bottom bound of the frustum.

top number

The top bound of the frustum.

near number

The near bound of the frustum.

far number

The far bound of the frustum.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1137)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

perspective(fovy, aspect, near, far)

Generate a perspective projection matrix with the given bounds.

Parameters:
Name Type Description
fovy number

Vertical field of view in radians

aspect number

Aspect ratio. Typically viewport width /height.

near number

Near bound of the frustum.

far number

Far bound of the frustum.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1055)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

perspectiveLH(width, height, near, far)

Generate a perspective projection matrix with the given bounds.

Parameters:
Name Type Description
width number

The width of the frustum.

height number

The height of the frustum.

near number

Near bound of the frustum.

far number

Far bound of the frustum.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1097)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

rotate(rad, axis)

Apply a rotation transformation to this Matrix.

Parameters:
Name Type Description
rad number

The angle in radians to rotate by.

axis Phaser.Math.Vector3

The axis to rotate upon.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 696)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

rotateX(rad)

Rotate this matrix on its X axis.

Parameters:
Name Type Description
rad number

The angle in radians to rotate by.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 774)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

rotateY(rad)

Rotate this matrix on its Y axis.

Parameters:
Name Type Description
rad number

The angle to rotate by, in radians.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 813)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

rotateZ(rad)

Rotate this matrix on its Z axis.

Parameters:
Name Type Description
rad number

The angle to rotate by, in radians.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 852)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

scale(v)

Apply a scale transformation to this Matrix.

Uses the x, y and z components of the given Vector to scale the Matrix.

Parameters:
Name Type Description
v Phaser.Math.Vector3 | Phaser.Math.Vector4

The Vector to scale this Matrix with.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 625)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

scaling(x, y, z)

Set the scaling values of this Matrix.

Parameters:
Name Type Description
x number

The x scaling value.

y number

The y scaling value.

z number

The z scaling value.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 210)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

set(src)

This method is an alias for Matrix4.copy.

Parameters:
Name Type Description
src Phaser.Math.Matrix4

The Matrix to set the values of this Matrix's from.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 67)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

setWorldMatrix(rotation, position, scale [, viewMatrix] [, projectionMatrix])

Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix.

Parameters:
Name Type Argument Description
rotation Phaser.Math.Vector3

The rotation of the world matrix.

position Phaser.Math.Vector3

The position of the world matrix.

scale Phaser.Math.Vector3

The scale of the world matrix.

viewMatrix Phaser.Math.Matrix4 <optional>

The view matrix.

projectionMatrix Phaser.Math.Matrix4 <optional>

The projection matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1356)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

translate(v)

Translate this Matrix using the given Vector.

Parameters:
Name Type Description
v Phaser.Math.Vector3 | Phaser.Math.Vector4

The Vector to translate this Matrix with.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 600)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

transpose()

Transpose this Matrix.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 268)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

xyz(x, y, z)

Set the x, y and z values of this Matrix.

Parameters:
Name Type Description
x number

The x value.

y number

The y value.

z number

The z value.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 185)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

yawPitchRoll(yaw, pitch, roll)

Set the values of this matrix from the given yaw, pitch and roll values.

Parameters:
Name Type Description
yaw number

[description]

pitch number

[description]

roll number

[description]

Since: 3.0.0
Source: src/math/Matrix4.js (Line 1295)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4

zero()

Reset this Matrix.

Sets all values to 0.

Since: 3.0.0
Source: src/math/Matrix4.js (Line 151)
Returns:

This Matrix4.

Type
Phaser.Math.Matrix4