Rotation Gizmo on meshes with parents

Hello all,
This question may be quite simple for the experts.
I am trying to use the gizmo on meshes that belong to a hierarchy. The meshes are to be positioned and rotated in local space. Since only some meshes are to be allowed for manipulation, the are made part of the attachableMeshes array.

While positiongizmo seems to work in this way, rotationgizmo seems to do something unexpected. Instead of rotating on its own axis, it seems to be doing something else.

Here is the playground example. https://playground.babylonjs.com/indexStable.html#QJK8FK#1.
(woodplank needs to be moved / rotated on its own axis)

Any help will be appreciated.
Regards,
Balu

Pinging the gizmo’s author: @trevordev

I don’t see any issues with your scene. By the way, nice reflection mapping and skybox. Can you specify the function that doesn’t appear to work?

Galen

I think I am able to repro on latest instead of stable and I think this is a bug, ill see if I can find a fix.

PR containing a fix: unparent attached mesh before rotation by TrevorDev · Pull Request #6226 · BabylonJS/Babylon.js · GitHub

Hi Galen,
The scene is not mine :grin:. Copied from another standard example from PG.

You can just press “e” to enable rotation and click the box to rotate. That should rotate it about some strange axis.

Thanks trevor. I had tested this with both stable and latest and the behaviour was similar.

Regards,
Balu

OK, I understand a bit better now. It appears you’re working in Euler space and not in quaternion space. Just rotate in quaternions and you’ll avoid the limit of 180 degrees vs. -180 degrees. It’s a bit of math, but a skill which is always valuable.

Galen

Thanks Galen,
It was a tough one, but I have managed to move to quaternions a while ago. :slight_smile:

This specific issue was part of the built in gizmo itself.

Regards,
Balu

I’ve actually ignored gizmos in my code, and simply parented every object I need to manipulate. If you discard Gizmos, does your scene work? Sometimes we need to take a step back. Not fun, but saves more time than looking for the tools that might work for the masses.

Galen

:slight_smile: The scene works perfectly. Very happy with babylonjs. I am using babylonjs for engineering applications and prefer to use built in functions as I am not really a developer. I had my own code for translation and rotation (Euler angles though), however moved to gizmos for the looks and consistent behaviour and ease of use.

Regards,
Balu

3 Likes

Hi,

I am using Babylonjs 3.3.0 and have the same issue. I saw that the solution is in a PR. How can I update my babylonjs without using version 4 (since this version is breaking many things)?

I could solve some of the problems when migrating from 3.3.0 to 4.0.3, but now I cannot see the gizmo, even though I am copying the code from here, and in there, it is working properly. Can someone help me?

Thanks

It seems to be working when using CDN, but when using Webpack in React it doesn’t work!!

EDIT: Solved, just remove all babylonjs dependencies, and install it again using npm install --save babylonjs

2 Likes