[Viewer] Replace WebVR with WebXR

Babylon.js Viewer: Babylon.js Viewer | Babylon.js Documentation

The Viewer uses WebVR system in BJS. Sadly WebVR has been deprecated and no longer works on current browsers.
https://caniuse.com/?search=webvr

Also the VR button doesn’t do anything when you press it because browsers no longer support it.

You can opt-in to WebXR via WebVR with the following:

However it’s not the recommended approach in the BJS docs.

Is using WebXR in the Viewer on the roadmap?

Adding @RaananW

I think that it is a misconception that the createDefaultVRExperience needs webvr support to be able to work. For example iOS does not support WebVR but the createDefaultVRExperience allows me to create a WebVR experience in iOS. Even on android i can not make webXR work in a cordova app. The createDefaultVRExperience works fine in an android app.

(It may be possible that you experience a not working createDefaultVRExperience because in de 4.2 version it switches to WebXR when WebVR is not available. But this was a mistake because createDefaultVRExperience can not work only more without WebVR. I have pushed a fix so you can disable this feature (Fix problem that VRExperienceHelper does not always respect the useXR… by tijmenvangulik · Pull Request #10347 · BabylonJS/Babylon.js · GitHub))

So please do not deprecate the old createDefaultVRExperience. It is in many cases the only option. WebXR has in my experience very limited support on devices which are not dedicated for VR.

1 Like

Adding @RaananW which was off before :slight_smile:

1 Like

The WebXR experience helper doesn’t work on iOS, that’s true. And the WebVR experience helper falls back to WebXR where WebXR is available. as the viewer doesn’t enable full interaction with the scene, but only allows simple interactions with the model, I think keeping the WebVR experience helper at the moment would be the right decision.

Is there something you are missing when using the VR helper? Is the XR fallback not working?

2 Likes

I think others experience a not working VRExperience. The XR helper fall back is doing a bit too much. Whenever webVR is not available it will start WebXR which is even more often not available. This way the CRExperience will never fall back to the old mode where only full screen api and device rotation is required. This way I think others will think that it does not work. I have already pushed a commit (which was accepted) which allows you to at least set the useXR to false. But I think it will be better to take it one step further and remove the line:
f (!vrSupported) {
webVROptions.useXR = true;
}
This way it will just work out of the box and developers do not get the idea that it does not work any more.