Dad72 Posted January 9, 2018 Share Posted January 9, 2018 When I want to have a scene and erase everything with scene.dispose(), nothing disappears and the scene froze. http://www.babylonjs-playground.com/#CDEGQD with just the sky. the camera freezes and the skybox too and nothing is erased http://www.babylonjs-playground.com/#CDEGQD#1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 9, 2018 Share Posted January 9, 2018 This happens when you call scene.dispose outside of a render loop (setTimeout does that). Maybe we should introduce a kind of "setTimeout" , but inside a render loop. Just to show that it does work when done in the right place - http://www.babylonjs-playground.com/#CDEGQD#2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 9, 2018 Author Share Posted January 9, 2018 Ok, I did not need to do this in previous versions, so I did not know that we had to do this now. this is not indicated or I need to re-read the documentation that can be updated. Thanks. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 9, 2018 Author Share Posted January 9, 2018 There is still a problem after disposing the scene. We can see in the console: Uncaught Error: No camera defined Why ? because then I can not recreate a new scene without refreshing the page with F5. Even if I use engine.stopRenderLoop(), this product always. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 9, 2018 Share Posted January 9, 2018 It has always be the case: if you dispose the only scene, then rendering has nothing to render (you can check with stable version on the PG) so the canvas is not updated and remains unchanged. The PG assumes that there is an active scene. Furthermore even outside of the PG, if there is no scene, there is no rendering and canvas remains unchanged (Meaning: it will keep the last generated image) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 9, 2018 Author Share Posted January 9, 2018 The problem is that I can not reload a new scene because of the fact that there is no defini camera. On my project if I reload a new scene to recreate a new camera I can not. I have to refresh my page for that. How to fix this? Must I disposed the engine too and recreate it? [edit] Yes I must have disposed the engine and recreate it, it works like that. So if we have disposed the scene, we must also have dispose the engine to be able to recreate a scene, is it what you should do or it is not normal? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 9, 2018 Share Posted January 9, 2018 Nope there are other ways: 1. first create a new scene and then dispose the previous one 2. You can also call stopRenderLoop first, then dispose the scene, then create the new one and call runRenderloop again Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 9, 2018 Author Share Posted January 9, 2018 As I mentioned earlier, with engine.stopRenderLoop () it produces the same thing, the scene then blocks because there is no camera. Solution 1 will not work for my project because the user can create a scene either empty or from made scene. I can not recreate a scene without knowing what the user wants to do. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 9, 2018 Share Posted January 9, 2018 engine.stopRenderLoop () will stop the render loop so obviously the render will be stopped And you can always create an empty scene with a dummy camera just while waiting for your user to choose Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 9, 2018 Author Share Posted January 9, 2018 I managed to do it by recreating the engine after disposing of it. Thank you DK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.