Get the rotation value from rotation gizmo

Hi everyone,

I want to know how can i get the value of the rotation of a rotation gizmo when dragging, like the delta value for a position gizmo (PG example : https://www.babylonjs-playground.com/#7CBW04#968)

For more informations my objective is to make a 2nd box rotate when 1 rotate the 1st one.

Thanks by advance.

Pinging @Cedric when he finds the time

1 Like

You can get the relative angle from the PlaneRotationGizmo:

And get the PlaneRotationGizmo from a rotationGizmo:

2 Likes

thanks, I did this to pass the rotation on the other meshes :

rotationGizmo.xGizmo.dragBehavior.onDragObservable.add(() => {
  objClick.filter(mesh => mesh != rotationGizmo.attachedMesh).forEach(mesh => {
    mesh.rotation.x += rotationGizmo.xGizmo.angle;
  });
  rotationGizmo.xGizmo.angle = 0;
});

PG updated : https://www.babylonjs-playground.com/#7CBW04#969

it works but can you confirm that i did right ?

1 Like

I don’t understand why you changing the mesh rotation manually. it’s automatic once a mesh got attached to the gizmo.

Like this :

Drag Demo | Babylon.js Playground (babylonjs-playground.com)

I change the mesh rotation manually for all meshes that i selected who is not the attached mesh of the gizmo (by the filter on the objClick array).

My objective is to rotate all the selected meshes at the same time with a single gizmo.

To see what i explain, check my PG https://www.babylonjs-playground.com/#7CBW04#969, click on 2 or more box and try to rotate.

I see!
May I suggest you to create a parent transform node that will be parent of the selected meshes and attach a gizmo to that transform. It depends on your need. You may have more control on your transformations the way you are doing it.
Also, be careful when adding scaling. it must be local to meshes.

I need to reproduce a rotation on all selected objects and perform this rotation on themselves, not on an axis but from what i saw a transformNode will rotate all its children around the pivotPoint of the transform, and no longer around themselves. Maybe what you mean is that I have to create a transform, rotate it and reproduce the rotation on all selected meshes and no longer rotate one of the selected objects then reproduce the rotation on all the meshes?

I need to reproduce a rotation on all selected objects and perform this rotation on themselves, not on an axis but from what i saw a transformNode will rotate all its children around the pivotPoint of the transform, and no longer around themselves. Maybe what you mean is that I have to create a transform, rotate it and reproduce the rotation on all selected meshes and no longer rotate one of the selected objects then reproduce the rotation on all the meshes?

yes, that on calling setParent to parent meshes to the transform.

I keep my method to reproduce the rotation but i now use a rotate function. https://www.babylonjs-playground.com/#7CBW04#974

thanks for help

3 Likes