Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type Aliases

Matrix4: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]

A type alias representing a 4x4 column-major matrix.

The common use-case for 4x4 matrices in 3D computer graphics are for transformation matrices. This allows a point in 3D space to be projected onto a 2D screen using transformations such as translation, rotation and scale.

Functions

  • fromValues(m11: number, m12: number, m13: number, m14: number, m21: number, m22: number, m23: number, m24: number, m31: number, m32: number, m33: number, m34: number, m41: number, m42: number, m43: number, m44: number): Matrix4
  • Creates a 4x4 matrix from a set of row-major components.

    Parameters

    • m11: number
    • m12: number
    • m13: number
    • m14: number
    • m21: number
    • m22: number
    • m23: number
    • m24: number
    • m31: number
    • m32: number
    • m33: number
    • m34: number
    • m41: number
    • m42: number
    • m43: number
    • m44: number

    Returns Matrix4

  • isIdentity(matrix: Matrix4): boolean
  • isType(obj: unknown): obj is Matrix4
  • Returns a matrix that has the basis components (upper left 3x3 matrix) set to the following x, y, and z axis.

    x.x  y.x  z.x  0
    x.y y.y z.y 0
    x.z y.z z.z 0
    0 0 0 0

    Parameters

    Returns Matrix4

    A matrix with its basis components populated.

  • makeFrustum(left: number, right: number, top: number, bottom: number, near: number, far: number): Matrix4
  • Creates a matrix used for perspective projections.

    The viewing volume is frustum-shaped and defined by the six parameters. Left, right, top, and bottom specify coordinates in the near clipping plane where the frustum edges intersect it, and the near and far parameters define the forward distances of the view volume. The resulting volume can be vertically and horizontally asymmetrical around the center of the near plane.

    Parameters

    • left: number

      The left coordinate at the near plane.

    • right: number

      The right coordinate at the near plane.

    • top: number

      The top coordinate at the near plane.

    • bottom: number

      The bottom coordinate at the near plane.

    • near: number

      The near distance.

    • far: number

      The far distance.

    Returns Matrix4

    A matrix representing a view frustum.

  • Matrix becomes a combination of translation and rotation.

    Matrix becomes a combination of a translation to the position of 'eye' and a rotation matrix which orients an object to point towards 'center' along its z-axis. Use this function if you want an object to look at a point from another point in space.

    Parameters

    • position: Vector3

      The position of the object.

    • lookAt: Vector3

      The point which the object is looking at.

    • up: Vector3

      The direction which the object considers up.

    Returns Matrix4

    A matrix.

  • Matrix becomes a combination of an inverse translation and rotation.

    Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The matrix will be an opposite translation from the 'eye' position, and it will rotate things in the opposite direction of the eye-to-center orientation. This is definitely confusing, but the main reason to use this transform is to set up a view matrix for a camera that's looking at a certain point. To achieve the effect of moving the camera somewhere and rotating it so that it points at something, the rest of the world is moved in the opposite direction and rotated in the opposite way around the camera. This way, you get the same effect as moving the actual camera, but all the projection math can still be done with the camera positioned at the origin (which makes it way simpler).

    Parameters

    • position: Vector3

      The position of the object.

    • lookAt: Vector3

      The point which the object is looking at.

    • up: Vector3

      The direction which the object considers up.

    Returns Matrix4

    A matrix.

  • makeOrthographic(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4
  • Creates an orthographic projection matrix.

    Related to: gluOrtho. The viewing volume is cube-shaped and defined by the six parameters. The left and right values represent the coordinates of the vertical clipping planes, top and bottom values represent the coordinates of the horizontal clipping planes, and near and far values represent the coordinates of the depth clipping planes.

    Parameters

    • left: number

      The coordinate of the left horizontal clipping plane.

    • right: number

      The coordinate of the right horizontal clipping plane.

    • bottom: number

      The coordinate of the bottom vertical clipping plane.

    • top: number

      The coordinate of the top vertical clipping plane.

    • near: number

      The coordinate of the near depth clipping plane.

    • far: number

      The coordinate of the far depth clipping plane.

    Returns Matrix4

    A matrix.

  • makePerspective(near: number, far: number, fovY: number, aspect: number): Matrix4
  • Creates a perspective projection matrix.

    Related to: gluPerspective. The viewing volume is frustum-shaped amd defined by the four parameters. The fovy and aspect ratio are used to compute the positions of the left, right, top, and bottom sides of the viewing volume in the zNear plane. The fovy is the y field-of-view, the angle made by the top and bottom sides of frustum if they were to intersect. The aspect ratio is the width of the frustum divided by its height. Note that the resulting volume is both vertically and horizontally symmetrical around the center of the near plane.

    Parameters

    • near: number

      The near Z value.

    • far: number

      The far Z value.

    • fovY: number

      The field of view.

    • aspect: number

      The aspect ratio.

    Returns Matrix4

    A matrix.