Completely Clearing a Scene

As I said elsewhere, I’m trying to create more scenes for my Merlin and Morgana tale and that will involve deleting all my previous meshes, materials, textures and audio. On a previous attempt, some years back, I just used dispose.scene.(). Recently I found this thread from the old forum : Proper way to Clear entire scene. It seems that the recommended method is :

scene.dispose();
engine.dispose();

as I gather it will delete all textures and audio files.

Any thoughts and suggestions as that thread is from 6 years ago and a lot has changed with BJS since then?

cheers, gryff :slight_smile:

i recall recent discussion saying scene.dispose() is all that is needed and something about engine.dispose() not being needed ( im not sure why they have it then haha , maybe some backwards compatible reasoning )

For myself , to be on the safe side but perhaps not needed … I do obviously have my own dispose function in my app that tries to think of dereferening anything i can imagine in what ever way possible to the nth degree , calling dispose manually on every material and texture , calling scene dispose and engine dispose as well, just in case haha…

calling dispose manually on every material and texture , calling scene dispose and engine dispose as well, just in case haha…

@shaderbytes : Hmm. That seems like a lot of work to do. It would be nice to know what scene.dispose and engine.dispose are actually doing! What is not being deleted as well as what is. And are they browser sensitive.

cheers, gryff :slight_smile:

as said , thats me being paranoid lol

I believe I read they said scene.dispose() will call dispose on all those things inside the engine…

Yes, scene.dispose() should be all you need to do. You should do engine.dispose() only when exiting your application.

3 Likes

@Evgeni_Popov : I want to be sure that all the texture and audio files get removed. As the next scene will load more, as will the scene after that.

cheers, gryff :slight_smile: