Draft
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.
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
.
The 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.
The 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 HMDVRDevice.setFieldOfView()
.
VRDisplay
VRDisplayCapabilities
VRDisplay
— it's features can be used to perform VR device capability tests, for example can it return position information.VRPose
VREyeParameters
VRFieldOfView
VRLayer
VRDisplay
.VRStageParameters
Gamepad.displayId
Read only
VRDisplay.displayId
of the associated VRDisplay
— the VRDisplay
that the gamepad is controlling the displayed scene of.Navigator.activeVRDisplays
Read only
VRDisplay
object that is currently presenting (VRDisplay.ispresenting
is true
).Navigator.getVRDisplays()
VRDisplay
objects representing any available VR devices connected to the computer.Window.onvrdisplayconnected
vrdisplayconnected
event fires).Window.onvrdisplaydisconnected
vrdisplaydisconnected
event fires).Window.onvrdisplaypresentchange
onvrdisplaypresentchange
event fires).You can find a number of examples at these Github repos:
Specification | Status | Comment |
---|---|---|
WebVR | Editor's Draft | Initial definition |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | No support | (Yes) | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android | Samsung Internet for GearVR |
---|---|---|---|---|---|---|---|
Basic support | No support | (Yes) | No support | No support | No support | No support |
(Yes) |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebVR_API