HoloLite Posted December 21, 2017 Share Posted December 21, 2017 Hello, I have newbie questions: If I have multiple scenes in my app, I wonder if we should keep 1 global singleton BABYLON.Engine object which alternates between scene objects or having one engine object for each scene. I did try the latter (1 engine per 1 scene) which seems to work, but I don't know if this is the proper/efficient use of the engine object. Also, what's the most appropriate way/api to use to switch between scenes ? Do I need to manually dispose the scene object if it's no longer used ? Is BJS smart enough to garbage-collect those unused objects ? Thanks. Quote Link to comment Share on other sites More sharing options...
HoloLite Posted December 21, 2017 Author Share Posted December 21, 2017 Another related questions: Is it possible to have 2 different canvases, each with its own scene, and render both scenes at the same time ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 21, 2017 Share Posted December 21, 2017 Hello, the best is to keep one engine and multiple scenes as the engine can share resources between scenes Switching between scenes can be done inside the engine.runRenderLoop() where you decide which scene you want to render (thus no need to dispose anything) No problem to have multiple canvases Quote Link to comment Share on other sites More sharing options...
HoloLite Posted December 21, 2017 Author Share Posted December 21, 2017 @deltakosh, thanks for the answer. Do I need to worry about calling engine.stopRenderLoop() when switching scene ? Let's say I have 3 scene objects: scene1, scene2, scene3 and want to render them in that order. Then should the following samples work ? engine.runRenderLoop(() => {scene1.render();}); ... engine.runRenderLoop(() => {scene2.render();}); ... engine.runRenderLoop(() => {scene3.render();}); Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 21, 2017 Share Posted December 21, 2017 Nope this is perfectly fine! 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.