Matrix4

Core.Matrix4 exported from @manycore/aholo-viewer.

Core Class

Constructors

Properties

isMatrix4: boolean

Check the type whether it belongs to Matrix4. This value should not be changed by user.

Accessors

  • get elements(): Float32Array

    A column-major list of matrix values.

    Returns Float32Array

  • set elements(v: Float32Array): void

    Parameters

    • v: Float32Array

    Returns void

    use fromArray instead;

Methods

  • Set the elements of this matrix to the supplied row-major values n11, n12, ... n44.

    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

  • Returns Readonly<
    Pick<
    ReadonlyMarked,
    | "_readonly_mark"
    | "cloneReadonly"
    | "clone"
    | "equals"
    | "getSerializeData"
    | "getNumberCount"
    | "toArray"
    | "elements"
    | "applyToBufferAttribute"
    | "determinant"
    | "applyToArray"
    | "decompose"
    | "extractBasis"
    | "getPosition"
    | "getMaxScaleOnAxis"
    | "decompose2D",
    >,
    >

  • Copies the translation component of the supplied matrix m into this matrix's translation component.

    Parameters

    Returns Matrix4

  • Set this to the basis matrix consisting of the three provided basis vectors:

    xAxis.x, yAxis.x, zAxis.x, 0,
    xAxis.y, yAxis.y, zAxis.y, 0,
    xAxis.z, yAxis.z, zAxis.z, 0,
    0,       0,       0,       1
    

    Parameters

    Returns Matrix4

  • Extracts the rotation component of the supplied matrix m into this matrix's rotation component.

    Parameters

    Returns Matrix4

  • Sets the rotation component (the upper left 3x3 matrix) of this matrix to the rotation specified by the given euler. The rest of the matrix is set to the identity. Depending on the order of the euler, there are six possible outcomes.

    Parameters

    Returns Matrix4

    See this page for a complete list.

  • Sets the rotation component of this matrix to the rotation specified by q, as outlined here. The rest of the matrix is set to the identity. So, given q = w + xi + yj + zk, the resulting matrix will be:

    1-2y²-2z²    2xy-2zw    2xz+2yw    0
    2xy+2zw      1-2x²-2z²  2yz-2xw    0
    2xz-2yw      2yz+2xw    1-2x²-2y²  0
    0            0          0          1
    

    Parameters

    Returns Matrix4

  • Multiplies every component of the matrix by a scalar value s.

    Parameters

    • s: number

    Returns Matrix4

  • Apply this matrix on given array. Each vector item of array should hold three elements.

    Parameters

    • array: Float32Array

    Returns Float32Array

  • Computes and returns the determinant of this matrix. Based on the method outlined here.

    Returns number

  • Sets the position component for this matrix from vector v, without affecting the rest of the matrix - i.e. if the matrix is currently:

    a, b, c, d,
    e, f, g, h,
    i, j, k, l,
    m, n, o, p
    

    This becomes:

    a, b, c, v.x,
    e, f, g, v.y,
    i, j, k, v.z,
    m, n, o, p
    

    Parameters

    Returns Matrix4

  • Change this matrix to inverse.

    Parameters

    • m: Matrix4
    • throwOnDegenerate: boolean

    Returns Matrix4

  • Apply a translation to this matrix.

    Parameters

    • tx: number

      translate first row by tx.

    • ty: number

      translate second row by ty.

    • tz: number

    Returns Matrix4

  • Gets the maximum scale value of the 3 axes.

    Returns number

  • Sets this matrix as a translation transform:

    1, 0, 0, x,
    0, 1, 0, y,
    0, 0, 1, z,
    0, 0, 0, 1
    

    Parameters

    • x: number

      the amount to translate in the X axis.

    • y: number

      the amount to translate in the Y axis.

    • z: number

      the amount to translate in the Z axis.

    Returns Matrix4

  • Sets this matrix as a rotational transformation around the X axis by Float| theta (θ) radians. The resulting matrix will be:

    1      0             0        0
    0 cos(θ) -sin(θ)  0
    0 sin(θ) cos(θ)   0
    0      0             0        1
    

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns Matrix4

  • Sets this matrix as a rotational transformation around the Y axis by Float| theta (θ) radians. The resulting matrix will be:

    cos(θ)  0 sin(θ) 0
         0        1      0       0
    -sin(θ) 0 cos(θ) 0
         0        0      0       1
    

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns Matrix4

  • Sets this matrix as a rotational transformation around the Z axis by Float| theta (θ) radians. The resulting matrix will be:

    cos(θ) -sin(θ) 0 0
    sin(θ) cos(θ)  0 0
          0            0       1 0
          0            0       0 1
    

    Parameters

    • theta: number

      Rotation angle in radians.

    Returns Matrix4

  • Sets this matrix as rotation transform around axis by Float| theta radians.
    This is a somewhat controversial but mathematically sound alternative to rotating via Quaternions| Quaternions.

    Parameters

    • axis: Vector3

      Rotation axis, should be normalized.

    • angle: number

    Returns Matrix4

    See the discussion here.

  • Parameters

    • x: number

      the amount to scale in the X axis.

    • y: number

      the amount to scale in the Y axis.

    • z: number

      the amount to scale in the Z axis. Sets this matrix as scale transform:

      x, 0, 0, 0,
      0, y, 0, 0,
      0, 0, z, 0,
      0, 0, 0, 1
      

    Returns Matrix4

  • Parameters

    • x: number

      the amount to shear in the X axis.

    • y: number

      the amount to shear in the Y axis.

    • z: number

      the amount to shear in the Z axis. Sets this matrix as a shear transform:

      1, y, z, 0,
      x, 1, z, 0,
      x, y, 1, 0,
      0, 0, 0, 1
      

    Returns Matrix4

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

    Parameters

    Returns Matrix4

    Not all matrices are decomposable in this way. For example, if an object has a non-uniformly scaled parent, then the object's world matrix may not be decomposable, and this method may not be appropriate.

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

    This matrix. Good for chaining method calls.

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

    Returns {
    x: number;
    y: number;
    scaleX: number;
    scaleY: number;
    rotation: number;
    skewX: number;
    skewY: number;
    }

    The transform with the newly applied properties.

  • Creates a perspective projection matrix. This is used internally by PerspectiveCamera.updateProjectionMatrix| PerspectiveCamera.updateProjectionMatrix()

    Parameters

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

    Returns Matrix4

  • Creates an orthographic projection matrix. This is used internally by OrthographicCamera.updateProjectionMatrix| OrthographicCamera.updateProjectionMatrix().

    Parameters

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

    Returns Matrix4

  • Apply this matrix to a 2D vector, z and w will set to 1 and 0.

    Parameters

    • vIn: { x: number; y: number }
    • vOut: Vector2

    Returns Vector2

  • Return true if this matrix and matrix are equal.

    Parameters

    Returns boolean

  • Sets the elements of this matrix based on an array in column-major format.

    Parameters

    • array: ArrayLike<number>

      the array to read the elements from.

    • offset: number

      ( optional ) offset into the array.

    Returns Matrix4

  • There are 16 elements in this matrix.

    Returns number

  • Writes the elements of this matrix to an array in column-major format.

    Parameters

    • array: number[]

      (optional) array to store the resulting vector in.

    • offset: number

      (optional) offset in the array at which to put the result.

    Returns number[]