Jump to content

Proper use of BABYLON.Engine and Scene objects


Recommended Posts

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 ?


Link to comment
Share on other sites

@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();});


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...