A number of years in the past I wrote an article about methods to detect VR help with JavaScript. Since that point, a complete lot has modified. “Augmented actuality” grew to become a factor and terminology has moved to “XR”, as an alternative of VR or AR. As such, the API has wanted to evolve.
The presence of navigator.xr
indicators that the browser helps the WebXR API and XR units:
const supportsXR = 'xr' in window.navigator;
I actually like utilizing in
for function checking reasonably than if(navigator.xr)
, as merely invoking that would trigger some initialization to happen. In future posts we’ll discover figuring out and connecting to totally different units.