melonJS
    Preparing search index...

    Class Matrix3d

    a 4x4 Matrix3d Object

    Hierarchy (View Summary)

    Index
    val: Float32Array

    The matrix values

    • Set this matrix to a translation, a rotation and a scale, applied to a point scale first, then rotation, then translation: T · R · S. The way a glTF node, or a physics body's pose, is turned into a matrix.

      Parameters

      • translation: XYPoint & { z?: number }

        where the origin goes; a missing z is 0

      • rotation: Quaternion

        the orientation; normalized, a zero one is no turn

      • Optionalscale: XYPoint & { z?: number }

        the scale along each axis; default 1, and a missing z is 1

      Returns Matrix3d

      Reference to this object for method chaining

      const m = new Matrix3d().compose(
      new Vector3d(10, 0, -5),
      new Quaternion().rotate(Math.PI / 2, new Vector3d(0, 1, 0)),
      new Vector3d(2, 2, 2),
      );
    • generate an orthogonal projection matrix, with the result replacing the current matrix

      Parameters

      • left: number

        farthest left on the x-axis

      • right: number

        farthest right on the x-axis

      • bottom: number

        farthest down on the y-axis

      • top: number

        farthest up on the y-axis

      • near: number

        distance to the near clipping plane along the -Z axis

      • far: number

        distance to the far clipping plane along the -Z axis

      Returns Matrix3d

      Reference to this object for method chaining

    • generate a perspective projection matrix, with the result replacing the current matrix

      Parameters

      • fov: number

        vertical field of view in radians

      • aspect: number

        aspect ratio (width / height)

      • near: number

        distance to the near clipping plane along the -Z axis

      • far: number

        distance to the far clipping plane along the -Z axis

      Returns Matrix3d

      Reference to this object for method chaining

    • rotate this matrix (counter-clockwise) by the specified angle (in radians), or by the rotation a Quaternion holds.

      Parameters

      • angle: number

        Rotation angle in radians, or a quaternion. A quaternion need not be of unit length: its direction is the rotation. An angle, an axis or a quaternion that is not a finite number, or an axis or a quaternion of length 0, rotates nothing.

      • Optionalv: Vector3d

        the axis to rotate around (defaults to Z axis); not used with a quaternion

      Returns this

      Reference to this object for method chaining

      // turn a mesh's model matrix to an orientation from a physics body
      mesh.currentTransform.identity().rotate(adapter.getRotation(mesh));
    • rotate this matrix (counter-clockwise) by the specified angle (in radians), or by the rotation a Quaternion holds.

      Parameters

      Returns this

      Reference to this object for method chaining

      // turn a mesh's model matrix to an orientation from a physics body
      mesh.currentTransform.identity().rotate(adapter.getRotation(mesh));
    • scale the matrix

      Parameters

      • x: number

        a number representing the abscissa of the scaling vector.

      • Optionaly: number = x

        a number representing the ordinate of the scaling vector.

      • Optionalz: number = 1

        a number representing the depth vector

      Returns Matrix3d

      Reference to this object for method chaining

    • Multiplies the current transformation with a 2D affine matrix (a, b, c, d, e, f). The 2D matrix is promoted to 4x4 internally.

      Parameters

      • a: number

        a component (scale x / cos)

      • b: number

        b component (skew y / sin)

      • c: number

        c component (skew x / -sin)

      • d: number

        d component (scale y / cos)

      • e: number

        e component (translate x)

      • f: number

        f component (translate y)

      Returns this

      Reference to this object for method chaining

    • Multiplies the current transformation with a full 4x4 matrix specified as 16 individual values (column-major).

      Parameters

      • b00: number
      • b01: number
      • b02: number
      • b03: number
      • b10: number
      • b11: number
      • b12: number
      • b13: number
      • b20: number
      • b21: number
      • b22: number
      • b23: number
      • b30: number
      • b31: number
      • b32: number
      • b33: number

      Returns this

      Reference to this object for method chaining

    • translate the matrix position using the given vector

      Parameters

      • x: number

        a number representing the abscissa of the vector, or a vector object

      • Optionaly: number

        a number representing the ordinate of the vector.

      • Optionalz: number

        a number representing the depth of the vector

      Returns Matrix3d

      Reference to this object for method chaining

    • translate the matrix position using the given vector

      Parameters

      • vector: XYPoint & { z?: number }

      Returns Matrix3d

      Reference to this object for method chaining