Select and Delete Problem - how can I fix it?

Hi there, I am almost at the end of stage one of my project. This is the first Babylon.js coding project I have ever done. It has been hard going…but fun.

So, my problem is selecting and deleting meshes (2 that are contained in a glb).

In my playground you can create a spherical mesh by right clicking the red roof area of the room. You should then be able to select it: the gizmo appears. When selected, if you click the grey sphere icon at the bottom of the screen, the outer mesh of the object should turn blue, clicking the grey cube you’ll get an orange outer mesh. So, you should be able to lay down a series of coloured spheres around the roof area.

The problem is that only the last sphere placed gets deleted when the trash icon is clicked…I need to be able to delete all if needed. Any ideas what I am doing wrong?

The things that I think may be causing the issue.

  • Each sphere is made up of two meshes: a small inner core and a larger outer one. This really needs to be treated as 1 object (as I know that the small inner mesh gets selected by accident, it’s the large outer sphere I want to change the colour of). How do I merge the two?
  • Confusion of what is being selected. When the sphere is created the select should happen instantaneously, the Gizmo appearing. There should not be a need when the sphere is created to have to click it again.

Any help with this would be greatly appreciated. I am so close to finishing, yet still so far away.


Why don’t you keep track of selected/created meshes (in an array for eg), and when clicking the delete icon dispose all the meshes of the array?