Sign in to follow this  
dbawel

load and dispose multiple scenes

Recommended Posts

Hello,

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.

Share this post


Link to post
Share on other sites

What happens if you do something like:
 

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

setTimeout(()=>{
activeScene.dispose();
activeScene = sceneArr[1]},timeChunk);
setTimeout(()=>{
activeScene.dispose();
activeScene = sceneArr[2]},timeChunk*2);
setTimeout(()=>{
activeScene.dispose();
activeScene = sceneArr[3]},timeChunk*3);


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

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

Share this post


Link to post
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.

Share this post


Link to post
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;
};

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.