Seamless switch between environments/scenes in XR/VR

I’m currently working on a VR (/XR) project that I’d like to seamlessly jump between different scenes. That is - at the press of a button, a user will be able to transport from one environment to another and stay in VR the whole time. They won’t need to return to the webpage in between. The most important part is that the transition is seamless.

Without VR, this can be done pretty easily by having two scenes share the same engine/canvas, then only rendering the scene the user has selected in the runRenderLoop. However, this configuration doesn’t work in XR. When the experience is launched from an XR device, any command that would trigger swapping between the scenes on the browser doesn’t change the scene that the user is in. My guess is that XR management is tied to a scene rather than some global/static object, and a scene in XR is viewed/rendered/operated independently from a scene on a canvas.

Is there any way to implement the seamless scene swapping in XR?


I’ve considered the naïve solution of loading in all of the models/textures/functionality into one scene, then splitting them up into separate “environments” that are to distant from each other for a user to see. Currently my project is finished and the environments are split into several scenes - if converting it to this solution is the best way to implement seamless XR environment swapping - I’d appreciate any tips that would generally help performance. At the moment my project simultaneously loads all scenes with meshes, then loads textures when a user visits those scenes, and if I switch to loading everything into one scene, I’d like to avoid a noticeable difference in performance.

Adding @JCPalmer who I think did smthg along those lines ? and @RaananW

1 Like

There is always a way. Not sure you want to go down the current working path, since it would have the side effect of forking.

I have a branch on a fork, GitHub - Palmer-JC/Babylon.js at XR. There is a whole topic on this from about 2 mos ago. There is a one line change additional commit, that did not get moved up. Let me know it you need it.

I just took those 5 classes and made a separate repo for them to avoid using a fork. I made a UMD with the module name changed to XXX (for patch :grinning:).

5 Likes

Code looks good, thanks a ton!

2 Likes