How to get correctly sized rotation gizmo in main scene rather than utility layer?

I’m trying to get an invisible custom rotation gizmo on an object that is sized to encompass the object’s bounding sphere.

Here it’s working on the utility layer but I’m unsure how to dynamically update the gizmo proxy mesh diameter to match the object’s bounding sphere in screen space:

I tried to place gizmo in main scene but it didn’t work:
Results in error: When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)

Having the gizmo in the main scene rather than an overlay would be preferable in my use case as I’m likely to have other clickable 3D objects between the rotatable object and the camera/utility layer i.e. I don’t want the rotation gizmo proxy to block other clickable objects in the main scene.

Related to my last post: User rotatable object TS class?

Pinging the Gizmo master @cedric

Hi @inteja

To disable the gizmo screenspace size update, use

rotationGizmo.updateScale = false;

Then use just have to set the gizmo size once with the size of the object:

rotationGizmo.scaleRatio = 8;

And here it is in action in a PG:


Thanks @Cedric. That works great for the utility layer. Is it possible to use gizmos in the main scene rather than the utility layer?

I think you have to use the same layer that’s used for rendering the meshes.
I couldnt find anything in the documentation.
Maybe @sebavan knows how to find the layer for solid meshes?

The meshes are actually straight on the scene and not on a special layer. The gizmos are always rendered in a utility layer at the moment but you could inspire from their code maybe ?

Hi @Cedric. Although working in the PG I’m getting a “Property ‘updateScale’ does not exist on type ‘PlaneRotationGizmo’” tsc error. scaleRatio works fine. I’m using the latest npm package 4.0.3.

Those properties may have been introduced after, could you try with our latest preview ?

The change for updateScale was introduced after 4.0.3 (it was protected at that time)
It’s available as public since 4.1.0-beta.6

1 Like