Remove the environment on box uncheck


I am calling a function on check box to add the environment

I would like to stop(uncall this function and remove the environment) on uncheck

So far I have the code below

//function to set the Environment after checking the box
var setEnvironment = function (isChecked) {
if (isChecked) {

//calls function to create the environment



If you use the environment helper, then it’s just a matter of calling dispose on it: Create/Dispose environment | Babylon.js Playground (

1 Like

I replaced with the loadedscene but it doesnt seem to dispose thanks

This is a Javascript issue not a babylon one per se. You are checking if the environment is defined before creating it but you never reset to undefine or null when disposing

1 Like