How to rotate camera while keeping gizmo on a mesh?

  • I have ArcRotateCamera in scene
  • I have positionGizmo enabled for various meshes in scene, ie. when I click any mesh, I want to have the gizmo attached on it
  • I want to rotate the camera while keeping the gizmo attached to the mesh which has it already attached (eg. the sphere in the PG example below)
  • however when I start the camera rotation by clicking on any other mesh, the gizmo is swapped to given mesh (eg. the ground in the PG example). Starting the drag on the active mesh only is not really an option due to small size of some meshes in the real scene, and generally bad/unintuitive UX.

So my question is:

  • Is there any way how to keep the gizmo attached to given mesh no matter where I start the camera rotation?

  • a possible solution could be attaching gizmos only with LMB click, while camera rotation would work with middle click. But I cant find a way how to restrict the gizmo attaching to LMB click only. Is there such option?

Thanks.

The logic behind it:
gizmoManager.usePointerToAttachGizmos = false; to disable gizmo manager picking.

If you press and release the mouse button at the same mouse position it’s considered as an pick action and it does an explicit scene.pick call and picks the mesh.

If you release the mouse at another position it’s not considered as a pick and you can freely move the camera w/o loosing the picked object.

3 Likes

ok, usePointerToAttachGizmos does the trick. Thank you.

Instead of saving and comparing the click position, I use onPointerObservable (already using it for other things) with PointerEventTypes.POINTERTAP as its second parameter, and that does the click/drag evaluation for me.

1 Like