manidos
manidos

Reputation: 3464

How to chain matrix transformation operations?

Why doesn't chaining makeTranslation methods on matrix object work?

      boxMesh.matrixAutoUpdate = false
      boxMesh.matrix.makeTranslation(30, 0, 0)
      boxMesh.matrix.makeTranslation(30, 0, 0)

the mesh moves only 30 units on x axis, not 60

but when I use applyMatrix method everything works as expected:

      boxMesh.applyMatrix(new THREE.Matrix4().makeTranslation(30, 0, 0))
      boxMesh.applyMatrix(new THREE.Matrix4().makeTranslation(30, 0, 0))

Upvotes: 0

Views: 195

Answers (1)

Mugen87
Mugen87

Reputation: 31026

Matrix4.makeTranslation() creates a pure translation matrix. All existing matrix elements are overwritten. Hence, the method is not intended to apply a translation to an existing transformation matrix.

Object3D.applyMatrix() works different since it multiplies the given matrix with the object's local transformation matrix. This leads to a combination of the given and the existing transformation.

three.js R104

Upvotes: 2

Related Questions