Dispose() does not work in some cases

if you add a sphere immediately, then it is removed through the dispose(), if the box is created by pressing a button, then the dispose() does not work

Hello and welcome!

this is because you are using a var box INSIDE a function so your box variable is not available outside. The fix: create/dispose mesh | Babylon.js Playground (babylonjs-playground.com)


Thanks a lot! In one case, even with the declaration of a variable in advance, it did not work for me, but now, looking at the full code, I see that I declared the variable “box” before the scene was declared. You helped me a lot, racked my brains for a day :slight_smile:

1 Like

My pleasure