Engine API Reference - v2.6.1
    Preparing search index...

    Class Mat3

    A 3x3 matrix.

    Index

    Constructors

    Properties

    data: Float32Array<ArrayBufferLike> = ...

    Matrix elements in the form of a flat array.

    IDENTITY: Mat3 = ...

    A constant matrix set to the identity.

    ZERO: Mat3 = ...

    A constant matrix with all elements set to 0.

    Methods

    • Creates a duplicate of the specified matrix.

      Returns Mat3

      A duplicate matrix.

      const src = new pc.Mat3().translate(10, 20, 30);
      const dst = src.clone();
      console.log("The two matrices are " + (src.equals(dst) ? "equal" : "different"));
    • Copies the contents of a source 3x3 matrix to a destination 3x3 matrix.

      Parameters

      • rhs: Mat3

        A 3x3 matrix to be copied.

      Returns Mat3

      Self for chaining.

      const src = new pc.Mat3().translate(10, 20, 30);
      const dst = new pc.Mat3();
      dst.copy(src);
      console.log("The two matrices are " + (src.equals(dst) ? "equal" : "different"));
    • Reports whether two matrices are equal.

      Parameters

      • rhs: Mat3

        The other matrix.

      Returns boolean

      True if the matrices are equal and false otherwise.

      const a = new pc.Mat3().translate(10, 20, 30);
      const b = new pc.Mat3();
      console.log("The two matrices are " + (a.equals(b) ? "equal" : "different"));
    • Extracts the x-axis from the specified matrix.

      Parameters

      • Optionalx: Vec3 = ...

        The vector to receive the x axis of the matrix.

      Returns Vec3

      The x-axis of the specified matrix.

    • Extracts the y-axis from the specified matrix.

      Parameters

      • Optionaly: Vec3 = ...

        The vector to receive the y axis of the matrix.

      Returns Vec3

      The y-axis of the specified matrix.

    • Extracts the z-axis from the specified matrix.

      Parameters

      • Optionalz: Vec3 = ...

        The vector to receive the z axis of the matrix.

      Returns Vec3

      The z-axis of the specified matrix.

    • Reports whether the specified matrix is the identity matrix.

      Returns boolean

      True if the matrix is identity and false otherwise.

      const m = new pc.Mat3();
      console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity"));
    • Copies the contents of a source array[9] to a destination 3x3 matrix.

      Parameters

      • src: number[]

        An array[9] to be copied.

      Returns Mat3

      Self for chaining.

      const dst = new pc.Mat3();
      dst.set([0, 1, 2, 3, 4, 5, 6, 7, 8]);
    • Sets this matrix to the given quaternion rotation.

      Parameters

      • r: Quat

        A quaternion rotation.

      Returns Mat3

      Self for chaining.

      const r = new pc.Quat(1, 2, 3, 4).normalize();

      const m = new pc.Mat4();
      m.setFromQuat(r);
    • Sets the matrix to the identity matrix.

      Returns Mat3

      Self for chaining.

      m.setIdentity();
      console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity"));
    • Converts the matrix to string form.

      Returns string

      The matrix in string form.

      const m = new pc.Mat3();
      // Outputs [1, 0, 0, 0, 1, 0, 0, 0, 1]
      console.log(m.toString());
    • Transforms a 3-dimensional vector by a 3x3 matrix.

      Parameters

      • vec: Vec3

        The 3-dimensional vector to be transformed.

      • Optionalres: Vec3 = ...

        An optional 3-dimensional vector to receive the result of the transformation.

      Returns Vec3

      The input vector v transformed by the current instance.

    • Generates the transpose of the specified 3x3 matrix.

      Parameters

      • Optionalsrc: Mat3 = ...

        The matrix to transpose. If not set, the matrix is transposed in-place.

      Returns Mat3

      Self for chaining.

      const m = new pc.Mat3();

      // Transpose in place
      m.transpose();