VRDisplay

Experimental: Это экспериментальная технология
Так как спецификация этой технологии ещё не стабилизировалась, смотрите таблицу совместимости по поводу использования в различных браузерах. Также заметьте, что синтаксис и поведение экспериментальной технологии может измениться в будущих версиях браузеров, вслед за изменениями спецификации.

The VRDisplay interface of the WebVR API 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.

An array of all connected VR Devices can be returned by invoking the Navigator.getVRDisplays() method.

Properties

VRDisplay.capabilities (en-US) Только для чтения

Returns a VRDisplayCapabilities object that indicates the various capabilities of the VRDisplay.

VRDisplay.depthFar (en-US)

Gets and sets the z-depth defining the far plane of the eye view frustum, i.e. the furthest viewable boundary of the scene.

VRDisplay.depthNear (en-US)

Gets and sets the z-depth defining the near plane of the eye view frustum, i.e. the nearest viewable boundary of the scene.

VRDisplay.displayId (en-US) Только для чтения

Returns an identifier for this particular VRDisplay, which is also used as an association point in the Gamepad API (see Gamepad.displayId).

VRDisplay.displayName (en-US) Только для чтения

Returns a human-readable name to identify the VRDisplay.

VRDisplay.isConnected (en-US) Только для чтения

Returns a Boolean (en-US) indicating whether the VRDisplay is connected to the computer.

VRDisplay.isPresenting (en-US) Только для чтения

Returns a Boolean (en-US) indicating whether the VRDisplay is currently having content presented through it.

VRDisplay.stageParameters (en-US) Только для чтения

Returns a VRStageParameters object containing room-scale parameters, if the VRDisplay is capable of supporting room-scale experiences.

Methods

VRDisplay.getEyeParameters() (en-US)

Returns the VREyeParameters (en-US) object containing the eye parameters for the specified eye.

VRDisplay.getFrameData() (en-US)

Accepts a VRFrameData object and populates it with the information required to render the current frame.

VRDisplay.getLayers() (en-US)

Returns the layers currently being presented by the VRDisplay.

VRDisplay.resetPose() (en-US)

Resets the pose for this VRDisplay, treating its current VRPose.position and VRPose.orientation (en-US) as the "origin/zero" values.

VRDisplay.cancelAnimationFrame() (en-US)

A special implementation of Window.cancelAnimationFrame that allows callbacks registered with VRDisplay.requestAnimationFrame() to be unregistered.

VRDisplay.requestAnimationFrame()

A special implementation of Window.requestAnimationFrame containing a callback function that will be called every time a new frame of the VRDisplay presentation is rendered.

VRDisplay.requestPresent()

Starts the VRDisplay presenting a scene.

VRDisplay.exitPresent() (en-US)

Stops the VRDisplay presenting a scene.

VRDisplay.submitFrame() (en-US)

Captures the current state of the VRLayer (en-US) currently being presented and displays it on the VRDisplay.

Deprecated methods

VRDisplay.getPose() (en-US) Устарело

Returns a VRPose object defining the future predicted pose of the VRDisplay as it will be when the current frame is actually presented. This method is deprecated — instead, you should use VRDisplay.getFrameData() (en-US), which also provides a VRPose object.

Obsolete methods

VRDisplay.getImmediatePose() (en-US)

Returns a VRPose object defining the current pose of the VRDisplay, with no prediction applied. This is no longer needed, and has been removed from the spec.

VRDisplay.hardwareUnitId (en-US)

Returns a DOMString defining the shared ID of the display, and any other devices that are part of that hardware set (e.g. controllers). This is no longer needed, and has been removed from the spec. Displays now use VRDisplay.displayId (en-US), and corresponsing controllers will now return the same ID under Gamepad.displayId.

Examples

if(navigator.getVRDisplays) {
  console.log('WebVR 1.1 supported');
  // Then get the displays attached to the computer
  navigator.getVRDisplays().then(function(displays) {
    // If a display is available, use it to present the scene
    if(displays.length > 0) {
      vrDisplay = displays[0];
      // Now we have our VRDisplay object and can do what we want with it
    }
  });
}

Примечание: You can see this complete code at raw-webgl-example.

Specifications

Specification Status Comment
WebVR 1.1
Определение 'VRDisplay' в этой спецификации.
Черновик Initial definition

Browser compatibility

BCD tables only load in the browser

See also