A 3x3 matrix.
new Mat3(): Mat3
Create a new Mat3 instance. It is initialized to the identity matrix.
data: Float32Array<ArrayBufferLike>
Matrix elements in the form of a flat array.
readonly static IDENTITY: Mat3;
A constant matrix set to the identity.
readonly static ZERO: Mat3;
A constant matrix with all elements set to 0.
clone(): Mat3
Creates a duplicate of the specified matrix.
A duplicate matrix.
const src = new Mat3().translate(10, 20, 30)
const dst = src.clone()
console.log('The two matrices are ' + (src.equals(dst) ? 'equal' : 'different'))
copy(rhs: Mat3): Mat3
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 Mat3().translate(10, 20, 30)
const dst = new Mat3()
dst.copy(src)
console.log('The two matrices are ' + (src.equals(dst) ? 'equal' : 'different'))
equals(rhs: Mat3): boolean
Reports whether two matrices are equal.
The other matrix.
boolean
True if the matrices are equal and false otherwise.
const a = new Mat3().translate(10, 20, 30)
const b = new Mat3()
console.log('The two matrices are ' + (a.equals(b) ? 'equal' : 'different'))
getX(x?: Vec3): Vec3
Extracts the x-axis from the specified matrix.
Vec3 = ...
The vector to receive the x axis of the matrix.
The x-axis of the specified matrix.
getY(y?: Vec3): Vec3
Extracts the y-axis from the specified matrix.
Vec3 = ...
The vector to receive the y axis of the matrix.
The y-axis of the specified matrix.
getZ(z?: Vec3): Vec3
Extracts the z-axis from the specified matrix.
Vec3 = ...
The vector to receive the z axis of the matrix.
The z-axis of the specified matrix.
isIdentity(): boolean
Reports whether the specified matrix is the identity matrix.
boolean
True if the matrix is identity and false otherwise.
const m = new Mat3()
console.log('The matrix is ' + (m.isIdentity() ? 'identity' : 'not identity'))
set(src: number[]): Mat3
Copies the contents of a source array9 to a destination 3x3 matrix.
number
An array9 to be copied.
Self for chaining.
const dst = new Mat3()
dst.set([
0,
1,
2,
3,
4,
5,
6,
7,
8
])
setFromMat4(m: Mat4): Mat3
Converts the specified 4x4 matrix to a Mat3.
The 4x4 matrix to convert.
Self for chaining.
setFromQuat(r: Quat): Mat3
Sets this matrix to the given quaternion rotation.
A quaternion rotation.
Self for chaining.
const r = new Quat(1, 2, 3, 4).normalize()
const m = new Mat4()
m.setFromQuat(r)
setIdentity(): Mat3
Sets the matrix to the identity matrix.
Self for chaining.
m.setIdentity()
console.log('The matrix is ' + (m.isIdentity() ? 'identity' : 'not identity'))
toString(): string
Converts the matrix to string form.
string
The matrix in string form.
const m = new Mat3()
// Outputs [1, 0, 0, 0, 1, 0, 0, 0, 1]
console.log(m.toString())
transformVector(vec: Vec3, res?: Vec3): Vec3
Transforms a 3-dimensional vector by a 3x3 matrix.
The 3-dimensional vector to be transformed.
Vec3 = ...
An optional 3-dimensional vector to receive the result of the transformation.
The input vector v transformed by the current instance.
transpose(src?: Mat3): Mat3
Generates the transpose of the specified 3x3 matrix.
Mat3 = ...
The matrix to transpose. If not set, the matrix is transposed in-place.
Self for chaining.
const m = new Mat3()
// Transpose in place
m.transpose()