1. Introduction
Hardware that enables Virtual Reality (VR) and Augmented Reality (AR) applications are now broadly available to consumers, offering an immersive computing platform with both new opportunities and challenges. The ability to interact directly with immersive hardware is critical to ensuring that the web is well equipped to operate as a first-class citizen in this environment. The WebXR Augmented Reality module expands the functionality available to developers when their code is running on AR hardware.
1.1. Terminology
Augmented Reality describes a class of XR experiences in which virtual content is aligned and composed with the real-world environment before being displayed to users.XR hardware can be divided into categories based on display technology: additive light, pass-through, and opaque.
Devices described as having an additive light display technology, also known as see-through, use transparent optical displays to present virtual content. On these devices, the user may always be able to see through to the real-world environment regardless of developer requests during session creation.
Note: Such devices typically will not do any compositing in software, relying on the natural compositing afforded by transparent displays.
Devices described as having a pass-through display technology use an opaque display to combine virtual content with a camera stream of the real-world environment. On these devices, the real-world environment will only be visible when the developer has made an explicit request for it during session creation.
Note: Such devices will typically use cameras to collect images of the real world, and composite the AR scene with these images in software before displaying them to the user.
Devices described as having an opaque display technology fully obscure the real-world environment and do not provide a way to view the real-world environment.
Note: Such devices are typically VR devices that have chosen to allow "immersive-ar" sessions in an attempt to provide a compatibility path for AR content on VR devices.
2. WebXR Device API Integration
2.1. XRSessionMode
As defined in the WebXR Device API categorizes XRSessions based on their XRSessionMode. This module enables use of the "immersive-ar" XRSessionMode enum.
A session mode of "immersive-ar" indicates that the session’s output will be given exclusive access to the immersive XR device display and that content is intended to be blended with the real-world environment.
On compatible hardware, user agents MAY support "immersive-vr" sessions, "immersive-ar" sessions, or both. Supporting the additional "immersive-ar" session mode, does not change the requirement that user agents MUST support "inline" sessions.
NOTE: This means that "immersive-ar" sessions support all the features and reference spaces that "immersive-vr" sessions do, since both are immersive sessions.
"immersive-ar" sessions are supported.
navigator. xr. isSessionSupported( 'immersive-ar' ). then(( supported) => { if ( ! supported) { return ; } // 'immersive-ar' sessions are supported. // Page should advertise AR support to the user. }
"immersive-ar" XRSession.
let xrSession; navigator. xr. requestSession( "immersive-ar" ). then(( session) => { xrSession= session