Jump automatically in immersive mode

Is there a way to detect that the browser supports the immersive mode (I mean that the page is rendered in the browser of an oculus quest, for example) and then jump in the immersive mode automatically ?
So that the user don’t have to click on the helmet icon…


1 Like

Hi Michel_Winter,

I don’t believe you can do this. I think the browser requires the click or another “transient activation” as a matter of policy, similar to how user consent (usually in the form of a click) is required to play sounds on mobile browsers and things like that. This helps prevent rogue websites from preemptively forcing you into an immersive view when maybe that wasn’t what you actually wanted to do.


yes, it makes sense.
And do you if, at least, there is a way to customise the purple background with the helmet icon on the bottom-right corner ?

1 Like

I think you can!

I haven’t done this myself, so I don’t know exactly how it works, but I believe the uiOptions configuration variable can be given custom buttons you can use for starting/stopping WebXR. For immersive, only starting should matter, I guess, but either way I think this capability allows you to override the default enter/exit UI with any custom UI you want. Hope this helps, and best of luck!

1 Like

I’m making progress… but I just cannot make my custom button launch the immersion :-/
I made a simple playground to illustrate, if anybody has an idea…

@RaananW might be able to help

the disableDefaultUI flag set to true means that you will take care of the entire UI generation. If you want to pass buttons and have babylon set the click event on them, you need to remove the flag from the configuration:

Test XR custom buttons | Babylon.js Playground (babylonjs.com)

1 Like

Yes ! I was quite close but I would have spend several days more, thanks a lot !

1 Like