whats the best way to determine if running on mobile AR (one camera) or VR headset (two cameras)
couldn’t see any methods on WebXRManager that expose this info.
this seems to be working for me but its not a great solution
const cameraVR = renderer.xr.getCamera();
const isAR = (cameraVR.cameras.length == 0);
console.log('isAR: ' + isAR );
is there a better way?
WebXRManager
does not have to expose this information since it is the app which decides what kind of XR session mode is used. In context of three.js
, your app has to detect whether VRButton
or ARButton
starts the XR session. This can be achieved by adding a custom event listener to the buttons.
hi, thanks for clarifying.
ive been finding the distinction between AR and VR in terms of XR in threejs confusing.
ie - the threejs WebXR AR samples run on mobile AR devices and also run in VR when launched on the Quest (for example). i need to dig into the code a bit more, but it seems threejs works out which device its running on is able to launch in AR or VR mode.
im also trying to build code/experiences that can run on both AR and VR. so my ideal UX would be - user presses launch AR/VR/XR button, and upon session start, there is some callback to say what device the XR session is running on. i might be completely off in how im approaching this but just wanted to share my first impression when running the threejs WebXR AR samples (on mobile Android and the Quest)
The ARButton
and VRButton
concept is just a thin layer on top of WebXR which distinguishes between AR and VR. So when requesting a XR session, you have to decide between immersive-vr
or immersive-ar
.