Get to know MDN better
Esta página ha sido traducida del inglés por la comunidad. Aprende más y únete a la comunidad de MDN Web Docs.
Experimental: Esta es una tecnología experimental
Comprueba la Tabla de compabilidad de navegadores cuidadosamente antes de usarla en producción.
WebVR proporciona soporte para la exposición de dispositivos de realidad virtual — por ejemplo el visualizador de Oculus Rift o HTC Vive — para aplicaciones web, permitiendo a los desarrolladores traducir la información de posición y movimiento del visualizador al movimiento alrededor de una escena en 3D. Esto tiene numerosas aplicaciones interesantes, desde visitas virtuales de productos y aplicaciones de capacitación interactiva hasta juegos inmersivos en primera persona.
Any VR devices attached to your computer will be returned by the Navigator.getVRDisplays() method; each one will be represented by a VRDisplay object.
VRDisplay is the central interface in the WebVR API — via its properties and methods you can access functionality to:
A typical (simple) WebVR app would work like so:
In addition, WebVR 1.1 adds a number of events on the Window object to allow JavaScript to respond to changes to the status of the display.
Nota: You can find a lot more out about how the API works in our Using the WebVR API and WebVR Concepts articles.
Many WebVR hardware setups feature controllers that go along with the headset. These can be used in WebVR apps via the Gamepad API, and specifically the Gamepad Extensions API that adds API features for accessing controller pose, haptic actuators, and more.
Nota: Our Using VR controllers with WebVR article explains the basics of how to use VR controllers with WebVR apps.
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.
VRDisplayCapabilitiesDescribes the capabilities of a VRDisplay — it's features can be used to perform VR device capability tests, for example can it return position information.
VRDisplayEventRepresents the event object of WebVR-related events (see the window object extensions listed below).
VRFrameDataRepresents all the information needed to render a single frame of a VR scene; constructed by VRDisplay.getFrameData().
VRPoseRepresents the position state at a given timestamp (which includes orientation, position, velocity, and acceleration.)
VREyeParametersProvides access to all the information required to correctly render a scene for each given eye, including field of view information.
VRFieldOfViewRepresents a field of view defined by 4 different degree values describing the view from a center point.
VRLayerInitRepresents a layer to be presented in a VRDisplay.
VRStageParametersRepresents the values describing the the stage area for devices that support room-scale experiences.
The WebVR API extends the following APIs, adding the listed features.
Returns the VRDisplay.displayId of the associated VRDisplay — the VRDisplay that the gamepad is controlling the displayed scene of.
Returns an array containing every VRDisplay object that is currently presenting (VRDisplay.ispresenting is true).
Navigator.getVRDisplays()Returns a promise that resolves to an array of VRDisplay objects representing any available VR displays connected to the computer.
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 vrdisplaypresentchange event fires).
Window.onvrdisplayconnectRepresents an event handler that will run when a compatible VR display has been connected to the computer (when the vrdisplayconnect event fires).
Window.onvrdisplaydisconnectRepresents an event handler that will run when a compatible VR display has been disconnected from the computer (when the vrdisplaydisconnect event fires).
Window.onvrdisplayactivateRepresents an event handler that will run when a display is able to be presented to (when the vrdisplayactivate event fires), for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
Window.onvrdisplaydeactivateRepresents an event handler that will run when a display can no longer be presented to (when the vrdisplaydeactivate event fires), for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
The following events are listed in the spec, but do not currently seem to be implemented anywhere as yet.
Window.onvrdisplayblurRepresents 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 vrdisplayblur event fires) — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience.
Window.onvrdisplayfocusRepresents an event handler that will run when presentation to a display has resumed after being blurred (when the vrdisplayfocus event fires).
You can find a number of examples at these locations:
Esta API se especificó en la antigua API de WebVR que fue reemplazada por la API del dispositivo WebXR. Ya no está en camino de convertirse en un estándar.
Hasta que todos los navegadores hayan implementado las nuevas API de WebXR, se recomienda confiar en frameworks, como A-Frame, Babylon.js, o Three.js, o un polyfill, para desarrollar aplicaciones WebXR que funcionen en todos los navegadores [1].
Enable JavaScript to view this browser compatibility table.
This page was last modified on 17 dic 2024 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.