Google has added a new augmented reality (AR) API, the WebXR Hit Test API, to Chrome Canary, the version of Chrome where it tests bleeding edge, experimental functionality. The API is designed to “[help] immersive web code place objects in the real world.”
According to Google, “Augmented reality will be a valuable addition to a lot of existing web pages. For example, it can help people learn on education sites, and allow potential buyers to visualize objects in their home while shopping.”
As the Immersive Web Community Group explains, “In order to place an object in a user-picked location that corresponds to real-world geometry, the most common approach is a raycast into the AR system’s understanding of the real world.”
The WebXR Hit Test API provides a single API that performs a raycast against an AR system’s understanding of the world. It accepts as input an origin and direction of a raycast, as well as a frame-of-reference to which the raycast is relative. it outputs an array of objects containing hit results.
Developers wanting to experiment with the WebXR Hit Test API will need a compatible smartphone running Android O or later, ARCore and Chrome Canary with the appropriate WebXRDevice API and WebXR Hit Test Chrome flags set. A number of demos are available.
Google says that the WebXR Hit Test API will remain in Chrome Canary for an extended period of time to ensure that it’s robust enough and suitable for developers.