liveBook · Manning

WebVR

As explained in Web Components in Action

WebVR is a web API specification for displaying virtual-reality content and receiving headset and controller pose input.

How does a browser know where a VR headset—and its controllers—are? WebVR defines a JavaScript API for displaying VR and receiving their position and rotation input. Browsers implement the API; headset and controller support depends on the browser and device. section 15.2

WebVR was an emerging standard already being superseded by WebXR, a name intended to include augmented reality and other immersive experiences. Treat browser and device support as something to check, not assume. section 15.2

Listing 15.2. A-Frame hello WebVR scene
<html>
<head>
   <title>Hello, WebVR! • A-Frame</title>
   <script src="aframe.min.js"></script>                                   #1
</head>
<body>
<a-scene background="color: #ECECEC">                                      #2
        <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow>
        </a-box>                                                           #3
        <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow>
        </a-sphere>
        <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color=
        "#FFC65D" shadow></a-cylinder>
        <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4"
        color="#7BC8A4" shadow></a-plane>
</a-scene>
</body>
</html>

The A-Frame scene is a small markup-based starting point for exploring VR: an <a-scene> contains a box, sphere, cylinder, and plane. It demonstrates scene creation, not a direct WebVR API implementation. section 15.2

How Web Components in Action covers it

How deep it goes
Defines the API's purpose and flags its changing status, but does not work through direct WebVR API calls.
Examples
Uses an A-Frame scene with a box, sphere, cylinder, and plane as an immersive-content example.
What it assumes
Assumes basic HTML and JavaScript familiarity while introducing the VR API through familiar browser concepts and scene markup.
What you can do after
Evaluate/understand it as a VR browser API whose support and successor standard matter when choosing an immersive approach.
How it connects
Connects WebVR to WebXR, augmented reality, A-Frame, and browser headset and controller support.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.