getWorldScale and getWorldQuaternion return incorrect values when object scale has three negative components
See original GitHub issueDescribe the bug
mesh.getWorldScale
and mesh.getWorldQuaternion
return incorrect values for a mesh with negative x, y, and z scale components.
If mesh.scale
is (-1, -1, -1), getWorldScale
returns (-1, 1, 1), losing two minus signs. If mesh.quaternion
is (0, 0, 0, 1), getWorldQuaternion
returns (1, 0, 0, 0).
To Reproduce
Steps to reproduce the behavior:
- Go to https://codepen.io/bennlich/pen/NWXyLKm
- Click anywhere on the canvas
- Notice how the image texture flips, and look at the console to see how the values of mesh.scale differ before and after.
- Go to https://codepen.io/bennlich/pen/MWrQPWE to see the analogous bug with getWorldQuaternion
Expected behavior
In the live example above, I would not expect the mesh to flip. I would expect getWorldScale
to return the same value as the mesh’s current local scale. Same with getWorldQuaternion
.
Platform:
- Device: Desktop
- OS: Linux
- Browser: Chrome
- Three.js version: 0.139.2
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
Object3D#getWorldQuaternion – three.js docs
When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property....
Read more >Three.js object returns wrong values for position/rotation/scale
I'm having a three.js object in my scene, which you can rotate/scale/move with the THREE.TransformControls. After positioning the object in ...
Read more >three.js - Apple Open Source
isInteger = function ( value ) { return typeof value === 'number' && isFinite( value ) && Math.floor( value ) === value; };...
Read more >Transformations, Coordinate Systems, and the Scene Graph
Moving objects around in 3D space is a fundamental skill on your path of learning three.js. We'll break this skill down into two...
Read more >UNPKG - @google/model-viewer
node_modules/has/src/index.js",". ... lib/three-components/CachingGLTFLoader.js",". ... '[object Symbol]') { return false; }\n\n\t// temp disabled per ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Scaling by ( - 1, - 1, 1 ), for example, is equivalent to a rotation-only around the z-axis.
quaternion
andscale
are coupled in such cases and you can’t consider them individually.Related:
https://gamedev.stackexchange.com/questions/117528/calculate-matrix-transformation-components-separately
Matrix decomposition (or higher-level methods like getWorldScale) cannot be guaranteed to return the same translation/rotation/scale (TRS) components as the originals. Repeated round-trip conversions between matrixes and TRS components should be avoided.