Skip to content

Latest commit

 

History

History
651 lines (285 loc) · 7.93 KB

File metadata and controls

651 lines (285 loc) · 7.93 KB

Home > server > Matrix4

Matrix4 class

Represents a 4x4 matrix.

Signature:

export default class Matrix4 extends Float32Array 

Extends: Float32Array

Remarks

All matrix methods result in mutation of the matrix instance. This class extends Float32Array to provide an efficient way to create and manipulate a 4x4 matrix. Various convenience methods are provided for common matrix operations.

Constructors

Constructor

Modifiers

Description

(constructor)(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

Constructs a new instance of the Matrix4 class

Properties

Property

Modifiers

Type

Description

determinant

readonly

number

The determinant of the matrix.

frobeniusNorm

readonly

number

The frobenius norm of the matrix.

Methods

Method

Modifiers

Description

add(matrix4)

Adds a matrix to the current matrix.

adjoint()

Sets the adjugate of the current matrix.

clone()

Clones the current matrix.

copy(matrix4)

Copies a matrix to the current matrix.

create()

static

Creates a new Matrix4 instance.

equals(matrix4)

Checks if the current matrix is approximately equal to another matrix.

exactEquals(matrix4)

Checks if the current matrix is exactly equal to another matrix.

fromQuaternion(quaternion)

static

Creates a new Matrix4 instance from a Quaternion object.

fromRotation(angle, axis)

static

Creates a new Matrix4 instance from an angle and axis.

fromRotationTranslation(rotation, translation)

static

Creates a new Matrix4 instance from a rotation and translation.

fromRotationTranslationScale(rotation, translation, scale)

static

Creates a new Matrix4 instance from a rotation, translation, and scale.

fromRotationTranslationScaleOrigin(rotation, translation, scale, origin)

static

Creates a new Matrix4 instance from a rotation, translation, scale, and origin.

fromScaling(scale)

static

Creates a new Matrix4 instance from a scale of identity matrix.

fromTranslation(translation)

static

Creates a new Matrix4 instance from a translation of identity matrix.

fromXRotation(angle)

static

Creates a new Matrix4 instance from an x-rotation of identity matrix.

fromYRotation(angle)

static

Creates a new Matrix4 instance from a y-rotation of identity matrix.

fromZRotation(angle)

static

Creates a new Matrix4 instance from a z-rotation of identity matrix.

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

Sets the current matrix to a frustrum matrix with the given bounds.

identity()

Sets the current matrix to the identity matrix.

invert()

Inverts the current matrix.

lookAt(eye, center, up)

Sets the current matrix to a look-at matrix with the given eye, center, and up vectors.

multiply(matrix4)

Multiplies the current matrix by another matrix.

multiplyScalar(scalar)

Multiplies each element of the current matrix by a scalar value.

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

Sets the current matrix to an orthographic projection matrix with the given bounds.

perspective(fovy, aspect, near, far)

Sets the current matrix to a perspective matrix with the given field of view, aspect ratio, and near and far bounds.

rotate(angle, axis)

Rotates the current matrix by an angle in radians around an axis.

rotateX(angle)

Rotates the current matrix by an angle in radians around the x-axis.

rotateY(angle)

Rotates the current matrix by an angle in radians around the y-axis.

rotateZ(angle)

Rotates the current matrix by an angle in radians around the z-axis.

scale(vector3)

Scales the current matrix by a vector.

subtract(matrix4)

Subtracts a matrix from the current matrix.

targetTo(eye, center, up)

Sets the current matrix to a matrix that looks at a target.

toString()

Returns a string representation of the current matrix.

translate(vector3)

Translates the current matrix by a vector.

transpose()

Transposes the current matrix.