Jump to content

load and dispose multiple scenes


Recommended Posts


I have a script due tomorrow morning, and have asked a question on a seperate post which is the ideal solution. The only other solution I could show have for tomorrow is to start the renderloop, load an OBJ, and then dispose of the scene - but then the scene needs to begin loading new meshes after it detects a new path and mesh in an array, and render without any client interaction.

I can't figure out how to load several scenes - lets say 5 scenes - and load scene 1 for 30 seconds, destroy scene one, on destroy scene two loads on it's own, and this process continues until scene 5 is loaded and then disposed.

Link to comment
Share on other sites

What happens if you do something like:

var sceneArr = [s1,s2,s3,s4];
var activeScene = sceneArr[0];
var timeChunk = 30000;

activeScene = sceneArr[1]},timeChunk);
activeScene = sceneArr[2]},timeChunk*2);
activeScene = sceneArr[3]},timeChunk*3);

engine.runRenderLoop(function () { // Register a render loop to repeatedly render the scene

Might work... there is way better logic for this, bit this should be simple to understand.

Link to comment
Share on other sites

You might wish to keep one scene.  All meshes for "scene 1" would have layermask of 1,  "scene 2" layermask of 4, "scene 3" layermask of 8.

If you added a point light on your camera (light follows camera) , and set the layermask of them for the scene to currently display, then the other "scenes" meshes would simply be in-active.  Disposing of scenes could be disruptive.

Link to comment
Share on other sites

@dbawel, had to walk the dog before it got nasty.  What I meant by camera light is:

var light = new BABYLON.PointLight("cam-light", new BABYLON.Vector3(0, 0, 0), scene);
light.intensity = 0.8;
scene.beforeCameraRender = function () {
    // move the light to match where the camera is
    light.position = scene.activeCamera.position;
    light.rotation = scene.activeCamera.rotation;


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...