The premultipy
method of the Matrix4
class in three.js
is used to multiply a matrix with another matrix in the left-multiplication form.
premultiply(matrix: Matrix4): this
matrix
: The matrix to be multiplied with.The this
keyword, which refers to the Matrix4
object that is being modified.
The premultipy
method is used to multiply a matrix with another matrix in the left multiplication form. The matrix passed as an argument is multiplied in the order matrix * this
, where matrix
is the argument and this
refers to the current Matrix4
object.
This method updates the current object, and returns a reference to the same object. Therefore, this method can be chained with other methods on the Matrix4
object.
const matrix1 = new THREE.Matrix4().makeScale(2, 2, 2);
const matrix2 = new THREE.Matrix4().makeRotationY(Math.PI / 2);
matrix1.premultiply(matrix2);
console.log(matrix1.toArray());
// [ 0, 0, -2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1 ]
const matrix1 = new THREE.Matrix4().makeScale(2, 2, 2);
const matrix2 = new THREE.Matrix4().makeRotationY(Math.PI / 2);
const matrix3 = new THREE.Matrix4().makeTranslation(1, 2, 3);
matrix1.premultiply(matrix2).premultiply(matrix3);
console.log(matrix1.toArray());
// [ 0, 0, -2, 3, 0, 2, 0, 4, 2, 0, 0, 0, 0, 0, 0, 1 ]
Matrix4.multiply()
Matrix4.makeRotationY()
Matrix4.makeScale()