Render two scenes at the same time

Hello I am using the Unity exporter and I want to load two scenes at the same time. I am using the runRenderLoop(handler); every time I add a scene, and I have set the autoClear = false; in the new scenes.
The result you can see in the image two scenes loaded but one is rendering on top of other and just can see the shadow because the light is common (global).


I have tried reversing the order in the runRenderLoop calls and then I see like two geometries at the same time but not drawing in correct order.
What can I do to see two scenes at the same time? the goal is to load unload scenes at runtime and with ‘aditive’ mode (load one, load two, load three, unload one)
I don’t have much knowledge about rendering. Any help would be appreciated. Thank you

I believe that is would be easier to use just one scene and Asset Containers to add/remove everything what you need from/to the scene.
Here are some docs - Asset Containers | Babylon.js Documentation

Thank you, for the suggestion, but as I am using the Unity exporter I want to load all the scripts I have created with Unity to my scenes. Do you think Asset Containers will have those scripts ( I think they are in the metadata) ?

The scene seems does contain all of these.

Adding @MackeyK24 to the thread, but depending on the effects you use and such, it might be really hard to impossible to do.

Yes using AssetContainer to load additively will still run scripts you made in Unity … that is the heart of my runtime Instantiate for prefabs

Also toolkit relies on gltf extensions to run the flow of scripts … so all the loaders of gltf will parse toolkit scripts

Like ImportMeshes and LoadScene

Sorry, but I added rotation to a cube and isn’t rotating when I import it as AssetContainer

Seems the metadata is json and when I import as scene the metada is [Object Object]

Here is my code for adding the gtlf file as AssetContainer:

BABYLON.SceneLoader.LoadAssetContainerAsync(this.ServerRootURL + serverScene.SceneFolder + "/", serverScene.SceneName,this.scene).then((container) => {
                    container.meshes.forEach((mesh)=>{
                        mesh.setEnabled(true);
                    });
                    container.addAllToScene();

I am not sure how to use the SM (Scene Manager) methods from the exporter, should I use SM.RegisterAssetContainer ?

Seems like LoadAssetContainerAsync doesn’t works but ImportMeshes works!

1 Like