How to make gizmo manager ignore certain meshes?

I made an immersive GUI menu attached to a plane. I can toggle ‘edit’ mode by clicking a control button on the GUI. When in ‘edit’ mode, I created a gizmo manager so that I can edit the scene by pointing at other meshes in the scene. The gizmo manager creates bounding box gizmos so that I can move, rotate, scale the selected mesh.

The problem is when I want to interact with the GUI menu again the entire plane is gizmo-fied by the gizmo manager due to the fact that the GUI menu lives on a mesh. I would like to be able to make the gizmo manager ignore the plane or planes that I use to make GUI menus.

Is there an easy way to achieve this?

The gizmo manager API has a way to add attachableMeshes, however I would like the opposite of that, where all the meshes are attachable except for the meshes I provide, like ‘unattachableMeshes’, or ‘ignoreableMeshes’.

Why don’t you just simply filter the array of the meshes you are passing to the attachableMeshes property? Maybe I don’t get something and an example would be cool.

EDIT: Let me make a test PG

1 Like

yes, that would technically work but my list of attachable meshes is dynamic and much larger than the one or 2 meshes I want to ignore.

I suppose I can maintain a list of meshes to ignore than deselect it as soon as I find out the selected mesh is on my list:

        gizmoManager.onAttachedToMeshObservable.add(mesh => {
            if (ignoreMeshNames.includes(mesh.name)) {
                gizmoManager.attachToMesh(null)
            }
        })

Why don’t you modify the gizmoManager.attachableMeshes in the click event? You can modify the list of attachable meshes dynamically anytime.

Yes, thank you. I know that would also work. My main hesitation is that I don’t want to maintain that list.
This concern is perhaps more a stylistic or philosophical preference, rather than a technical limitation. To me it is similar to preferring to keep a small list that is a restraining order against one or two people, rather than keeping an inclusive list of all the people on the planet that you are allowed to interact with. I would rather have a “reject list” than an “include list” for my particular scenario.

Hello @owen just checking in, was your question answered?

Thanks for following up! It wasn’t answered here, but I discovered if I need to use my own predicate function / criteria for selecting only certain meshes, it’s best to just disable the automatic selecting meshes using gizmo manager and listen on scene pointer pick and attach gizmo manually. Then I can filter by whatever criteria I want.

1 Like