Scenes not disposing despite having the dispose method called

So this is the loop I am doing to clear all scenes:

for(var i=0;i<this.engine.scenes.length;i++) 
    this.engine.scenes[0].dispose();
console.log(this.engine.scenes.length);`

However even after clearing the scenes the scenes.length value is still not 0, it is late which is why I don’t have time to make a playground demo right now, and will tomorrow, but was just posting this anyway to see if there was a common cause to this and anyone already knows why this would be happening.

EDIT: I realized it may be a bug with removing scenes when using multiple scenes. I’m fairly sure it may be a bug with babylon itself since the dispose function didn’t actually dispose under seemingly normal circumstances but idk, if this does seem like a new bug that you can’t reproduce let me know and I will take a crack at creating a playground with my code to reproduce it. Although I realized since my fore-scene only consisted of a text overlay I just slapped that on top of the background and got rid of the multiple scenes and the dispose function on just one one scene worked fine for transitioning between level scenes so I don’t desperately need an answer to this question anymore…

This should work:

for(var i=0;i<this.engine.scenes.length;i++) 
    this.engine.scenes[i=0].dispose();

or

while (this.engine.scenes.length) {
    this.engine.scenes[0].dispose();
}
1 Like