Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a 4x4 matrix.

Hierarchy

  • Matrix
    • Matrix4x4

Implements

  • TransformId

Index

Constructors

constructor

  • new Matrix4x4(array?: ArrayLike<number>): Matrix4x4
  • Creates a new transform matrix using the specified matrix array.

    Parameters

    • Optional array: ArrayLike<number>

      The matrix array, expected length is 16. If empty, an identity matrix is used by default.

    Returns Matrix4x4

Properties

a

a: number
default

1

array

array: Float32Array

The array containing the matrix data.

b

b: number
default

0

c

c: number
default

0

d

d: number
default

1

tx

tx: number
default

0

ty

ty: number
default

0

Accessors

backward

down

forward

left

position

right

rotation

scaling

transformId

  • get transformId(): number

up

Static IDENTITY

  • get IDENTITY(): Matrix
  • A default (identity) matrix

    readonly

    Returns Matrix

Static TEMP_MATRIX

  • get TEMP_MATRIX(): Matrix
  • A temp matrix

    readonly

    Returns Matrix

Methods

append

  • Appends the given Matrix to this Matrix.

    Parameters

    • matrix: Matrix

      The matrix to append.

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

apply

  • apply<P>(pos: IPointData, newPos?: P): P
  • Get a new position with the current transformation applied. Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)

    Type parameters

    • P: IPointData = Point

    Parameters

    • pos: IPointData

      The origin

    • Optional newPos: P

    Returns P

    The new point, transformed through this matrix

applyInverse

  • applyInverse<P>(pos: IPointData, newPos?: P): P
  • Get a new position with the inverse of the current transformation applied. Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)

    Type parameters

    • P: IPointData = Point

    Parameters

    • pos: IPointData

      The origin

    • Optional newPos: P

    Returns P

    The new point, inverse-transformed through this matrix

clone

  • clone(): Matrix
  • Creates a new Matrix object with the same values as this one.

    Returns Matrix

    A copy of this matrix. Good for chaining method calls.

copyFrom

copyTo

  • copyTo(matrix: Matrix): Matrix
  • Changes the values of the given matrix to be the same as the ones in this matrix

    Parameters

    • matrix: Matrix

      The matrix to copy to.

    Returns Matrix

    The matrix given in parameter with its values updated.

decompose

  • decompose(transform: Transform): Transform
  • Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.

    Parameters

    • transform: Transform

      The transform to apply the properties to.

    Returns Transform

    The transform with the newly applied properties

fromArray

  • fromArray(array: number[]): void
  • Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:

    a = array[0] b = array[1] c = array[3] d = array[4] tx = array[2] ty = array[5]

    Parameters

    • array: number[]

      The array that the matrix will be populated from.

    Returns void

identity

  • Resets this Matrix to an identity (default) matrix.

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

invert

  • Inverts this matrix

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

multiply

prepend

  • Prepends the given Matrix to this Matrix.

    Parameters

    • matrix: Matrix

      The matrix to prepend

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

rotate

  • Applies a rotation transformation to the matrix.

    Parameters

    • angle: number

      The angle in radians.

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

scale

  • Applies a scale transformation to the matrix.

    Parameters

    • x: number

      The amount to scale horizontally

    • y: number

      The amount to scale vertically

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

set

  • set(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix4x4
  • Sets the matrix properties.

    Parameters

    • a: number

      Matrix component

    • b: number

      Matrix component

    • c: number

      Matrix component

    • d: number

      Matrix component

    • tx: number

      Matrix component

    • ty: number

      Matrix component

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

setFrom

setFromRotationPositionScale

setTransform

  • setTransform(x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number): Matrix4x4
  • Sets the matrix based on all the available properties

    Parameters

    • x: number

      Position on the x axis

    • y: number

      Position on the y axis

    • pivotX: number

      Pivot on the x axis

    • pivotY: number

      Pivot on the y axis

    • scaleX: number

      Scale on the x axis

    • scaleY: number

      Scale on the y axis

    • rotation: number

      Rotation in radians

    • skewX: number

      Skew on the x axis

    • skewY: number

      Skew on the y axis

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

toArray

  • toArray(transpose: boolean, out?: Float32Array): Float32Array
  • Parameters

    • transpose: boolean
    • Optional out: Float32Array

    Returns Float32Array

toString

  • toString(): string
  • Returns string

translate

  • Translates the matrix on the x and y.

    Parameters

    • x: number

      How much to translate x by

    • y: number

      How much to translate y by

    Returns Matrix4x4

    This matrix. Good for chaining method calls.

Static fromQuaternion

Static fromRotation

  • Creates a matrix from a given angle around a given axis.

    Parameters

    • rad: number

      The angle in radians to rotate the matrix by.

    • axis: Point3D

      The axis to rotate around.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static fromRotationTranslationScale

Static fromScaling

Static fromTranslation

Static identity

Static invert

Static lookAt

  • Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.

    Parameters

    • eye: Point3D

      The position of the viewer.

    • center: Point3D

      The point the viewer is looking at.

    • up: Point3D

      The vector pointing up.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static ortho

  • ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, out?: Matrix4x4): Matrix4x4
  • Parameters

    • 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.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static perspective

  • perspective(fovy: number, aspect: number, near: number, far: number, out?: Matrix4x4): Matrix4x4
  • Parameters

    • fovy: number

      The vertical field of view in radians.

    • aspect: number

      The aspect ratio, typically viewport width/height.

    • near: number

      The near bound of the frustum.

    • far: number

      The far bound of the frustum.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static rotate

  • Rotates a matrix by the given angle around the given axis.

    Parameters

    • a: Matrix4x4

      The matrix to rotate.

    • rad: number

      The angle in radians to rotate the matrix by.

    • axis: Point3D

      The axis to rotate around.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static rotateX

  • Rotates a matrix by the given angle around the x-axis.

    Parameters

    • a: Matrix4x4

      The matrix to rotate.

    • rad: number

      The angle in radians to rotate the matrix by.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static rotateY

  • Rotates a matrix by the given angle around the y-axis.

    Parameters

    • a: Matrix4x4

      The matrix to rotate.

    • rad: number

      The angle in radians to rotate the matrix by.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static rotateZ

  • Rotates a matrix by the given angle around the z-axis.

    Parameters

    • a: Matrix4x4

      The matrix to rotate.

    • rad: number

      The angle in radians to rotate the matrix by.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static scale

Static targetTo

  • Generates a matrix that makes something look at something else.

    Parameters

    • eye: Point3D

      The position of the viewer.

    • target: Point3D

      The point the viewer is looking at.

    • up: Point3D

      The vector pointing up.

    • out: Matrix4x4 = ...

      The receiving matrix. If not supplied, a new matrix will be created.

    Returns Matrix4x4

Static translate

Static transpose

Generated using TypeDoc