This page is not complete.
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
WebVR provides support for exposing virtual reality devices — for example head-mounted displays like the Oculus Rift — to web apps, enabling developers to translate position and movement information from the display into movement around a 3D scene. This has numerous very interesting applications, from virtual product tours and interactive training apps to super immersive first person games.
Concepts and usage
Any VR devices attached to your computer will be returned by the
Navigator.getVRDisplays() method. This returns an array of objects to represent the attached devices, which inherit from the general
VRDevice object — generally a head mounted display will have two devices — the head mounted display itself, represented by
HMDVRDevice, and a position sensor camera that keeps track of your head position, represented by
PositionSensorVRDevice object contains the
getState() method, which returns a
VRPositionState object — this represents the sensor’s state at a given timestamp, and includes properties containing useful data such as current velocity, acceleration, and orientation, useful for updating the rendering of a scene on each frame according to the movement of the VR head mounted display.
HMDVRDevice.getEyeParameters() method returns a
VREyeParameters object, which can be used to return field of view information — how much of the scene the head mounted display can see. The
VREyeParameters.currentFieldOfView returns a
VRFieldOfView object that contains 4 angles describing the current view from a center point. You can also change the field of view using
- Represents any VR device supported by this API. It includes generic information such as device IDs and descriptions, as well as methods for starting to present a VR scene, retrieving eye parameters and display capabilities, and other important functionality.
- Describes the capabilities of a
VRDisplay— it's features can be used to perform VR device capability tests, for example can it return position information.
- Represents the event object of WebVR-related events (see the window object extensions listed below).
- Represents all the information needed to render a single frame of a VR scene; constructed by
- Represents the position state at a given timestamp (which includes orientation, position, velocity, and acceleration.)
- Provides access to all the information required to correctly render a scene for each given eye, including field of view information.
- Represents a field of view defined by 4 different degree values describing the view from a center point.
- Represents a layer to be presented in a
- Represents the values describing the the stage area for devices that support room-scale experiences.
Extensions to other interfaces
The WebVR API extends the following APIs, adding the listed features.
- Returns the
VRDisplay.displayIdof the associated
VRDisplaythat the gamepad is controlling the displayed scene of.
- Returns an array containing every
VRDisplayobject that is currently presenting (
- Returns a promise that resolves to an array of
VRDisplayobjects representing any available VR displays connected to the computer.
- Represents an event handler that will run when a compatible VR display has been connected to the computer (when the
- Represents an event handler that will run when a compatible VR display has been disconnected from the computer (when the
- Represents an event handler that will run when a display is able to be presented to (when the
vrdisplayactivateevent fires), for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
- Represents an event handler that will run when a display can no longer be presented to (when the
vrdisplaydeactivateevent fires), for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
- Represents an event handler that will run when presentation to a display has been paused for some reason by the browser, OS, or VR hardware (when the
vrdisplayblurevent fires) — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience.
- Represents an event handler that will run when presentation to a display has resumed after being blurred (when the
- represents an event handler that will run when the presenting state of a VR display changes — i.e. goes from presenting to not presenting, or vice versa (when the
You can find a number of examples at these locations:
|Feature||Chrome||Chromium||Edge||Firefox (Gecko)||Internet Explorer||Opera||Safari (WebKit)|
|Basic support||(Yes)||(Yes)||(Yes)||55 (55)||No support||No support||No support|
|Feature||Android||Edge||Firefox Mobile (Gecko)||IE Phone||Opera Mobile||Safari Mobile||Chrome for Android||Samsung Internet for GearVR|
|Basic support||No support||No support||55.0 (55)||No support||No support||No support||(Yes)||(Yes)
- A-Frame — Open source web framework for building VR experiences.
- MozVR team — Demos, and useful utilities
- webvr.info — Up-to-date information about WebVR, browser setup, and community.
- MozVr.com — Demos, downloads, and other resources from the Mozilla VR team.
- threejs-vr-boilerplate — A useful starter template for writing WebVR apps into.