Class Matrix4

A 4x4 Matrix.

// Simple rig for rotating around 3 axes
const m = new THREE.Matrix4();
const m1 = new THREE.Matrix4();
const m2 = new THREE.Matrix4();
const m3 = new THREE.Matrix4();
const alpha = 0;
const beta = Math.PI;
const gamma = Math.PI/2;
m1.makeRotationX( alpha );
m2.makeRotationY( beta );
m3.makeRotationZ( gamma );
m.multiplyMatrices( m1, m2 );
m.multiply( m3 );

Implements

Constructors

  • Creates an identity matrix.

    Returns Matrix4

  • Creates a 4x4 matrix with the given arguments in row-major order.

    Parameters

    • n11: number
    • n12: number
    • n13: number
    • n14: number
    • n21: number
    • n22: number
    • n23: number
    • n24: number
    • n31: number
    • n32: number
    • n33: number
    • n34: number
    • n41: number
    • n42: number
    • n43: number
    • n44: number

    Returns Matrix4

Properties

isMatrix4: true
elements: number[]

Array with matrix values.

[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]

Methods

  • Sets all fields of this matrix.

    Parameters

    • n11: number
    • n12: number
    • n13: number
    • n14: number
    • n21: number
    • n22: number
    • n23: number
    • n24: number
    • n31: number
    • n32: number
    • n33: number
    • n34: number
    • n41: number
    • n42: number
    • n43: number
    • n44: number

    Returns this

  • Resets this matrix to identity.

    Returns this

  • clone():T;

    Returns Matrix4

  • copy(m:T):T;

    Parameters

    Returns this

  • Parameters

    Returns this

  • Parameters

    Returns this

  • Parameters

    Returns this

  • Copies the rotation component of the supplied matrix m into this matrix rotation component.

    Parameters

    Returns this

  • Parameters

    Returns this

  • Parameters

    Returns this

  • Constructs a rotation matrix, looking from eye towards center with defined up vector.

    Parameters

    Returns this

  • Multiplies this matrix by m.

    Parameters

    Returns this

  • Parameters

    Returns this

  • Sets this matrix to a x b.

    Parameters

    Returns this

  • Sets this matrix to a x b and stores the result into the flat array r.
    r can be either a regular Array or a TypedArray.

    Parameters

    Returns Matrix4

    This method has been removed completely.

  • Multiplies this matrix by s.

    Parameters

    • s: number

    Returns this

  • Transposes this matrix.

    Returns this

  • Sets the position component for this matrix from vector v.

    Parameters

    Returns this

  • Parameters

    • x: number
    • y: number
    • z: number

    Returns this

  • Inverts this matrix.

    Returns this

  • Multiplies the columns of this matrix by vector v.

    Parameters

    Returns this

  • Returns number

  • Sets this matrix as translation transform.

    Parameters

    Returns this

  • Parameters

    • x: number
    • y: number
    • z: number

    Returns this

  • Sets this matrix as rotation transform around x axis by theta radians.

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns this

  • Sets this matrix as rotation transform around y axis by theta radians.

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns this

  • Sets this matrix as rotation transform around z axis by theta radians.

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns this

  • Sets this matrix as scale transform.

    Parameters

    • x: number
    • y: number
    • z: number

    Returns this

  • Sets this matrix as shear transform.

    Parameters

    • xy: number
    • xz: number
    • yx: number
    • yz: number
    • zx: number
    • zy: number

    Returns this

  • Sets this matrix to the transformation composed of translation, rotation and scale.

    Parameters

    Returns this

  • Decomposes this matrix into it's position, quaternion and scale components.

    Parameters

    Returns this

  • Creates a perspective projection matrix.

    Parameters

    • left: number
    • right: number
    • top: number
    • bottom: number
    • near: number
    • far: number
    • OptionalcoordinateSystem: CoordinateSystem

    Returns this

  • Creates an orthographic projection matrix.

    Parameters

    • left: number
    • right: number
    • top: number
    • bottom: number
    • near: number
    • far: number
    • OptionalcoordinateSystem: CoordinateSystem

    Returns this

  • Parameters

    Returns boolean

  • Sets the values of this matrix from the provided array or array-like.

    Parameters

    • array: number[] | ArrayLike<number>

      the source array or array-like.

    • Optionaloffset: number

      (optional) offset into the array-like. Default is 0.

    Returns this

  • Returns an array with the values of this matrix, or copies them into the provided array.

    Parameters

    • Optionalarray: number[]

      (optional) array to store the matrix to. If this is not provided, a new array will be created.

    • Optionaloffset: number

      (optional) optional offset into the array.

    Returns number[]

    The created or provided array.

  • Parameters

    Returns Matrix4Tuple

  • Copies he values of this matrix into the provided array-like.

    Parameters

    • Optionalarray: ArrayLike<number>

      array-like to store the matrix to.

    • Optionaloffset: number

      (optional) optional offset into the array-like.

    Returns ArrayLike<number>

    The provided array-like.

  • Set the upper 3x3 elements of this matrix to the values of the Matrix3 m.

    Parameters

    Returns this

  • Parameters

    • v: any

    Returns any

    Use vector.applyMatrix4( matrix ) instead.

  • Parameters

    • v: any

    Returns any

    Use vector.applyMatrix4( matrix ) instead.

  • Parameters

    • array: number[]

    Returns number[]

    This method has been removed completely.

  • Parameters

    • v: any

    Returns void

    Use vector.applyMatrix4( matrix ) instead.

  • Parameters

    • array: number[]
    • offset: number

    Returns number[]

    Use .toArray() instead.

  • Parameters

    Returns Matrix

    Use .invert() instead.