How to switching scenes in vr glass

this is the page code, only two simple scene and a gui button for each scene:
https://github.com/issuebox/switch-babylon-scenes-vr/blob/main/index.html#L109

In browser it works fine,but I don’t know how to switch to another scen in vr glass through click the gui button.

should I use scene. createDefaultXRExperienceAsync() once for all scenes, or use it once for each scene?

How should I use it?

If you have two different websites that both serve XR content you can move between them using the native sessiongranted event. this event is already automatically integrated in the default UI of our webxr implementation, so all you need to do is make sure you are initializing XR when the scene is created.

This will enable entering XR automatically if you click the 2nd link.

2 Likes

I came across A requirement that: first enter the panoramic mode of scene A, and then directly switch to the panoramic mode of scene B by clicking an object or button in scene A ( scene A and scene B use the same canvas ). I tested some code today and it didn’t work. My requirements are similar to (https://playground.babylonjs.com/#MXCRPS#1
). can you help me modify the demo code to make it work in vr glasses?

There is currently no way of switching scenes while in XR. This is because the xr resources are attrached to the current scene, and XR will need to re-initialize in the new scene.

The one way is to have two different URLs, with their XR context initialized on page load. Otherwise you will need to deal with a single scene scenario and change the scene’s state.

1 Like

Hello @RaananW ,I am sorry I still don’t know how to use this method. Can you help me solve it again?

I create a git repo (GitHub - issuebox/scenes-switch: demo of how to switch scenes in vr mode), just have two simple pages:
the first-scene.html,created a simple sphere, the second-scene.html, created a simple box;

I plan to use these two pages to display two scenes. When in the VR mode on page one, by clicking on the GUI (the code is commented out by me) or other events, directly enter the VR mode in the scene on page two. How should I achieve it?

Have you tried your implementation? is something not working?

This is the right way of using it. On load you create a default WebXR experience, that integrates the event automatically for you.

When I want to click the gui in the VR mode of the first page to enter the second page, I will exit the VR mode, and then I need to manually enter the VR mode of the second page scene. Can I directly enter the vr mode on the second page without exiting the vr mode?

yes, if you set the window location to the new link while in XR it should automatically enter XR in the new scene.

But when I click on the gui, it jumps out of vr mode, and then enters the second page in flat mode. I used the version of v5.0.0-alpha.50 when test in glasses.

want to show me a live demo?

FYI, There is a tweet thread from Brandon Jones on changing actual pages while staying in immersive, from Nov 23. There are many exchanges / branches. There is no url. People are starting to see how this might work.

The babylon implementation is working on framevr, so it is already being used in production. Seeing a live example might help us understand why it doesn’t work in this specific use case

https://issuebox.github.io/scenes-switch/first-scene.html
That’s the code I used to test in glasses. When click the GUI in glasses xr mode,it quit out the xr mode, and then go to the second-scene.html.

The two raw page code:

Would also be important to know - what browser are you using to test with?

It will be great if you can deploy this somewhere for live testing as well.

test in firefox reality of vr glasses

firefox reality doesn’t support this, as this is a webxr feature that the browser needs to implement.

Is there any other browser I can use in vr glasses? I just find a firefox reality browser in the device.

I assume this is Pico, so sadly - no. Firefox reality has not been update in a year and is not compatible with the full webxr specs.

I asked a colleague to help me build the latest package from the git repository of firefox reality, but he said that the package was unsuccessful because of lack of a pico sdk. So, I don’t know if there is any other way. .

Firefox has stopped development of firefox reality a long time ago. They are updating the SDK from time to time, but they don’t add any new features and have no new releases (you can see here - Releases · MozillaReality/FirefoxReality · GitHub)

Not sure what can be done here… I hope firefox will ramp up and continue developing firefox reality further.