Hi! As the title says, if I try to use go.get_world_rotation() on an object with a scale factor different from 1, the value of the quaternion is incorrect.
Is this a bug or a limitation of having to decompose the final model matrix of the object? Is there any way to get the world rotation on a scaled object?
EDIT: To be more precise, I’m working in pure 2D with uniform scales and my goal is to get to sin(alpha) and cos(alpha) where alpha is the global rotation-around-Z angle of a sprite. I need this to do manual picking (because when working with game objects, you don’t have gui.pick_node()).
I just ran into this bug myself. It’s a deal-breaker for doing world-to-local transforms (and vice versa) with game objects.
Here’s a minimal example demonstrating it: Defold Get World Rotation Bug.zip (2.6 KB)
And even a gif!
The line is drawn with a vector rotated with the normalized result of go.get_world_rotation(), so you can see that you get a wildly different rotation depending on the scale of the object. (If you don’t normalize the quaternion the vector also gets scaled when you rotate it.)
(Note: the result is very similar if you use a uniform scale as well.)
I would actually be happier if we could get the entire world transform matrix of an object. It’s much more useful if you want to transform between coordinate spaces.
Would be nice to be able to use go.get(component, 'mtx_view') to retrieve needed matrices.
At the moment this thing return a zero vector(4) for some reason. And trying to specify game object instead of a component results in a crash, heh.