GizmoManager - I can't get the position Gizmo to stick to a targeted mesh

Hi there, another day of work…one step forward, one back.
I hope you can help. I’m having a problem with a position gizmo using the gizmo manager Here is my playground. If you click on the upper part, you will see a spherical mesh stick to it. The problem is that the axis arrows aren’t appearing. They used to when the code below was used, but the problem was that the axis arrows appeared on other meshes too. I would like only the top roofTop mesh to have the position Gizmo.

From the documentation, if you use the Gizmo Manager, you can specify what mesh to attach the gizmo to. The nonworking Gizmo code in my playground starts at line 113.

Below - is the old code I had used but was adding the Gizmo to unwanted meshes:

var gizmoManager = new BABYLON.GizmoManager(scene);
gizmoManager.positionGizmoEnabled = true;

                    //*** ENTER (mesh) to attach to model
                    gizmoManager.attachToMesh(device);

adding @Cedric

Hi @Bov

You can specify the list of allowed mesh (or nodes) that can be picked with attachableMeshes or attachableNodesSearch

You create a gizmo manager with the array of allowed meshes and you are done!

I changed your PG
Room with attachments | Babylon.js Playground

see lines 14-16 for gizmomanager creation and line 45 for adding the roomtop meshes to the mesh array.

Hi Cedric, thank you for your response.

This technique using the GizmoManager is interesting and simple to use.

I had a go at using this method. Unfortunately, it was really the green spherical objects (Dev2) that I wanted the gizmo attached to, so I tried attaching the Gizmo to them using your described method. I have the Dev2 objects appearing again in my playground below but using your method the Gizmo isn’t attaching. I obviously must be doing something wrong…do you have any ideas?

Here is my new playground with the Dev2 objects showing, but no Gizmo

Cheers.

You can keep the attachableMeshes for picking but force another to be attached with onPointerUp happens. Only roomtop meshes are selectable but you can move the cloned sphere once 1 is selected.

Room with attachments - alts | Babylon.js Playground

Thanks again Cedric. I appreciate your help.

Sorry to be a nuisance…is there a way using this method so that if an earlier sphere is selected again the Gizmo appears? As the spheres may need to be adjusted slightly once placed. The code in my initial post seemed to do this (but was attaching the Gizmo to everything).

Cheers.

You can update the attachablemesh array by adding or removing meshes like your cloned spheres.