A 3x3 matrix.
Create a new Mat3 instance. It is initialized to the identity matrix.
Matrix elements in the form of a flat array.
Static
Readonly
A constant matrix set to the identity.
A constant matrix with all elements set to 0.
Creates a duplicate of the specified matrix.
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")); Copy
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.
A 3x3 matrix to be copied.
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")); Copy
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.
The other matrix.
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")); Copy
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.
Optional
The vector to receive the x axis of the matrix.
The x-axis of the specified matrix.
Extracts the y-axis from the specified matrix.
The vector to receive the y axis of the matrix.
The y-axis of the specified matrix.
Extracts the z-axis from the specified matrix.
The vector to receive the z axis of the matrix.
The z-axis of the specified matrix.
Reports whether the specified matrix is the identity matrix.
True if the matrix is identity and false otherwise.
const m = new pc.Mat3();console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity")); Copy
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.
An array[9] to be copied.
const dst = new pc.Mat3();dst.set([0, 1, 2, 3, 4, 5, 6, 7, 8]); Copy
const dst = new pc.Mat3();dst.set([0, 1, 2, 3, 4, 5, 6, 7, 8]);
Converts the specified 4x4 matrix to a Mat3.
The 4x4 matrix to convert.
Sets this matrix to the given quaternion rotation.
A quaternion rotation.
const r = new pc.Quat(1, 2, 3, 4).normalize();const m = new pc.Mat4();m.setFromQuat(r); Copy
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.
m.setIdentity();console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity")); Copy
m.setIdentity();console.log("The matrix is " + (m.isIdentity() ? "identity" : "not identity"));
Converts the matrix to string form.
The matrix in string form.
const m = new pc.Mat3();// Outputs [1, 0, 0, 0, 1, 0, 0, 0, 1]console.log(m.toString()); Copy
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.
The 3-dimensional vector to be transformed.
An optional 3-dimensional vector to receive the result of the transformation.
The input vector v transformed by the current instance.
Generates the transpose of the specified 3x3 matrix.
The matrix to transpose. If not set, the matrix is transposed in-place.
const m = new pc.Mat3();// Transpose in placem.transpose(); Copy
const m = new pc.Mat3();// Transpose in placem.transpose();
A 3x3 matrix.