https://immersiveweb.dev/
The WebXR Device API
The WebXR Device API provides access to input (pose information from
headset and controllers) and output (hardware display) capabilities
commonly associated with Virtual Reality (VR) and Augmented Reality
(AR) devices. It allows you develop and host VR and AR experiences on
the web.
You can read more about the goals of this standardisation effort by
reading the WebXR Explainer.
What does this mean...
[mr]
For phones:
Enable VR by providing pose information and allowing the WebGL scene
to be rendered side by side to be placed in a headset like the
Cardboard
Enable AR by using the platforms AR capabilities such as ARCore to
render the WebGL scene onto the users environment like a magic
window.
For Desktops:
Desktop computers can make use of tethered VR hardware such as the
Oculus Rift or HTC Vive to display the VR scene
For standalone AR Headsets:
Enable AR by using the platforms AR capabilities to render the WebGL
scene immersively onto the users environment.
For standalone VR Headsets:
Enable VR by rendering the scene using the platforms VR capabilities.
Try out some Demos
A demo of VR and AR with the WebXR Device API, embedded with an
iframe, for iframes allow="xr-spatial-tracking" is required.
These are samples from the WebXR Samples from the Immersive Web
Working Group They use a very minimal libary to show how one can make
use of the WebXR Device API directly.
[inlinesess] This sample demonstrates use of an 'inline' XRSession to
present content on the page prior to entering XR presentation with an
immersive session. [inputtrack] This sample demonstrates basic
tracking and rendering of XRInputSources. It does not respond to
button presses or other controller interactions. [teleportat] This
sample demonstrates teleporting the viewer by updating the XRSession
reference space.
Benefits of doing XR on the Web
* Instant deployment to every XR platform with a WebXR enabled Web
Browser
* Future proof experiences, new AR and VR hardware comes about
regularly, your experience should continue working on new
hardware without needing to push new code.
* An experience can choose to target both VR and AR, Handheld and
head mounted devices with a single release. Minimal code changes
needed to support VR and AR together.
* No app stores or large downloads required, users get immediate
access to your experience without needing to leave your web site.
* Since the rendering is handled by WebGL, which has been around
since 2011, you gain the benefit of WebGL's rich development tool
ecosystem and a large, active developer community.
WebXR in the Real World
[hello-webx]
Hello WebXR
Mozilla Mixed Reality
The demo is designed as a playground where you can try different
experiences and interactions in VR, and introduce newcomers to the VR
world and its special language in a smooth, easy and nice way.
[xrdinosaur]
XR Dinosaurs
Brandon Jones
Welcome to the web's virtual Dinosaur Park!
We've used the magic of your browser to bring back a friendly pack of
prehistoric pals.
Our dinosaurs can be viewed with a variety of Virtual Reality
headsets, Augmented Reality headsets and phones, or directly in your
browser.
[wydk]
What You Don't Know
Jono & Mr. Doob
Dive into the creative process of avant-pop artist Matthew Dear from
his new single of the same name. Floating above you is a magic
eight-ball reciting lyrics. In the distance planetary objects orbit
around you to the beat. And directly ahead is an elastic donut which
bounces, bulges, and twists to the complex melodies.
Getting started building a WebXR Website
These are brief guides to building a site which uses and AR and VR.
The WebXR device API relies on graphics APIs like WebGL & WebGL2 to
work, these graphics libraries and frameworks come with WebXR support
built in.
A-Frame Babylon.js model-viewer p5.xr PlayCanvas React-XR Three.js
Unity Verge3D Wonderland Engine
A-Frame is a web framework for building 3D/AR/VR experiences using a
combination of HTML and Javascript.
A-Frame is based on three.js and has a large community, as well as
lots of community-made custom elements and components.
Babylon.js is an easy to use real-time 3D game engine built using
TypeScript. It has full WebXR support out of the box, including gaze
and teleportation support, AR experimental features and more. To
simplify WebXR development Babylon.js offers the WebXR Experience
Helper, which is the one-stop-shop for all XR-related
functionalities.
To get started use the Babylon.js playground, or try these demos:
* https://playground.babylonjs.com/#PPM311
* https://playground.babylonjs.com/#JA1ND3#164
To start on your own use this simple template:
Babylon - Getting Started
For advanced examples and documentation see the Babylon.js WebXR
documentation page
Model viewer is a custom HTML element for displaying 3D models and
vieweing them in AR
AR
p5.xr is an add-on for p5.js, a Javascript library that makes coding
accessible for artists, designers, educators, and beginners. p5.xr
adds the ability to run p5 sketches in Augmented Reality or Virtual
Reality.
p5.xr also works in the p5.js online editor, simply add a script tag
pointing to the latest p5.xr release in the index.html file.
PlayCanvas is an open-source game engine. It uses HTML5 and WebGL to
run games and other interactive 3D content in any mobile or desktop
browser.
Full documentation available on the PlayCanvas Developer site
including API reference. Also check out XR tutorials with sources
using online Editor as well as engine-only examples and their source
code.
Below is basic example of setting up PlayCanvas application, simple
scene with light and some cubes aranged in grid. And Immersive VR
session on click/touch if WebXR is supported:
PlayCanvas Basic VR
react-xr is a collection of hooks to help you build XR experiences in
react-three-fiber applications. To make a VR React application we'll
use the following stack:
The Stack
Three.js is a library for 3D graphics, react-three-fiber is react
renderer for Three.js, drei is a collection of reusable components
for r3f and react-xr is a collection of hooks to help you build XR
experiences in react-three-fiber applications.
react-xr
As soon as you have a 3D scene using react-three-fiber you can make
it available in VR or AR with react-xr.
For that, the only thing you need to do is to replace