Three.js: Matrix4.compose wrong order?

Created on 10 May 2020  路  4Comments  路  Source: mrdoob/three.js

Description of the problem

The documentation for Matrix4.compose states:

"Sets this matrix to the transformation composed of position, quaternion and scale. Internally this calls makeRotationFromQuaternion( quaternion ) followed by scale( scale ), then finally setPosition( position )."

My understanding was always that you should scale before doing the rotation otherwise you can end up with unusual scaling (skewing).

So it should be (IMHO): scale, rotation, translation

Three.js version
  • [ ] Dev
  • [x] r115
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Hardware Requirements (graphics card, VR Device, ...)
Documentation

Most helpful comment

Right. The docs are not the place to describe how the code is implemented.

All 4 comments

The documentation is outdated. Matrix4.compose() does not call the mentioned methods. The following sentence should be completely removed:

Internally this calls makeRotationFromQuaternion( quaternion ) followed by scale( scale ), then finally setPosition( position ).

Do you want to make a PR with this change?

Right. The docs are not the place to describe how the code is implemented.

Thanks for the info @Mugen87 and agree with the docs not describing how the code works.
I may still be getting a difference between doing .compose and doing the matrix multiplication manually (as scale, orientation, translation) but I need to do a bit more digging before I raise that as a bug since it might very well be a PICNIC (Problem In Chair, Not In Computer). 馃ぃ

Raised PR with documentation update so closing this issue.

Was this page helpful?
0 / 5 - 0 ratings