JavaScript Mapping Library
A few years ago I wrote an article about how to detect VR support with JavaScript. Since that time, a whole lot has changed. “Augmented reality” became a thing and terminology has moved to “XR”, instead of VR or AR. As such, the API has needed to evolve.
The presence of navigator.xr signals that the browser supports the WebXR API and XR devices:
navigator.xr
const supportsXR = 'xr' in window.navigator;
I really like using in for feature checking rather than if(navigator.xr), as simply invoking that could cause some initialization to take place. In future posts we’ll explore identifying and connecting to different devices.
in
if(navigator.xr)
The post Detect XR Support with JavaScript appeared first on David Walsh Blog.
David Walsh Blog
You must be logged in to post a comment.
This site uses Akismet to reduce spam. Learn how your comment data is processed.