Fallen at the last obstacle - Need help 'dosposing' of cloned meshes (glb)

Hi there, would someone be kind enough to help me finish my project. I have been working on it for a while now and falling at the last obstacle.

I want to delete, via a trash can button, a series of cloned (2 meshed) spheres that are generated by right clicking on the red roof space of a room. I would like for any sphere that is generated to be deleted. So, if sphere 2 out of 5 spheres generated is not needed any more it can be deleted (disposed of). At present only the last sphere generated can be deleted, the others won’t budge.

Other things you should know: if you select a sphere, that is when the gizmo is showing, you can change the color of the sphere by clicking the grey sphere or cube icons (these are just placeholder images for now)

I did get some great help from Evgeni_Popov (and others) seen here, but due to my inexperience with programming I found the code beyond me. I did try for several hours to figure it out.

So, if anyone could help me finish my project it would be greatly appreciate it (and I can finally think of other things). The latest version of my Playground is here

Many thanks.

I see no spheres at all but in the UI

Doing what I described in the other thread:


Hi Evgeni_Popov, thank you very much for doing this for me. I appreciate you taking the time to do it.

Unfortunately, this isn’t quite what I am after. I had an inkling that your code may delete all spheres. I really need the spheres to be deleted one at a time, and in any order of production. So, if a decision is made to delete the third sphere out of seven, then you can.

This one will delete the currently selected mesh:


If it is not what you want, you should update the deleteButton.onPointerClickObservable and change the selectedMesh variable with the mesh you want to remove.

1 Like

Hi Evgeni_Popov…you’re a star!..thank you very much…I can now enjoy my weekend, and relax a bit.

I am looking forward to viewing your code…to see how you did it.

Cheers. :smile: