How to detect if site is viewed using HMD?

Currently using the default webxr experience helper triggers the “Enter VR” button even on Android phones. This is for cardboard of course which has very limited usage.

Is there any way to detect if the client browser is a HMD (Like Meta Quest or Apple Vision Pro)?

cc @sevaseva

1 Like

By default (customizable) the “Enter VR” button is shown in systems that implement the WebXR spec. If the kind of webxr session that your application requests (upon a click on that button) isn’t actually supported by the system, the user will still see the button and then an error after clicking that button.

If you only want to show that button (or your custom UI for entering/exiting the immersive session) if the system supports the specific configuration of session you need (i.e. sessionMode, referenceSpaceType, requiredFeatures - that sort of thing), my understanding is that WebXRDefaultExperience won’t do that for you; you will need to implement your own check. Calling xr.isSessionSupported() is the best you can do unless you want to analyse the user agent string and create a whitelist of specific devices that support the capabilities your application needs.

Is there any way to detect if the client browser is a HMD (Like Meta Quest or Apple Vision Pro)?

It depends on your definition of “HMD”. Clearly, some would argue that an Android phone with Google Cardboard thing is an example of an HMD, but you may not agree. How do you define HMD?

1 Like