Skip to content

Commit

Permalink
A few more @cvan tweaks.
Browse files Browse the repository at this point in the history
Thanks for iterating on the text with me!
  • Loading branch information
toji committed Oct 19, 2017
1 parent fb2af73 commit c44dcaa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ The basic steps any WebVR application will go through are:

1. Request a VR device.
1. If a device is available, application advertises VR functionality to the user.
1. Request a VR session from the device in response to a user activation event.
1. Request a VR session from the device in response to a [user-activation event](https://html.spec.whatwg.org/multipage/interaction.html#activation).
1. Use the session to run a render loop that produces graphical frames to be displayed on the VR device.
1. Continue producing frames until the user indicates that they wish to exit VR mode.
1. End the VR session.

### Acquiring a Device

The first thing that any VR-enabled page will want to do is request a `VRDevice` and, if one is available, advertise VR functionality to the user. (For example, by adding a button to the DOM that the user can click to start VR content.)
The first thing that any VR-enabled page will want to do is request a `VRDevice` and, if one is available, advertise VR functionality to the user. (For example, by adding a button to the page that the user can click to start VR content.)

`navigator.vr.requestDevice` returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a `VRDevice` if one is available. In no `VRDevice` is available it will resolve to null. The promise will be rejected if an error occurs, such as the the page not having the appropriate permissions to access VR capabilities.
`navigator.vr.requestDevice` returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a `VRDevice` if one is available. If no `VRDevice` is available, it will resolve to null. The promise will be rejected if an error occurs, such as the the page not having the appropriate permissions to access VR capabilities.

A `VRDevice` represents a physical unit of VR hardware that can present imagery to the user somehow, referred to here as a "VR hardware device". On desktop clients this will usually be a headset peripheral; on mobile clients it may represent the mobile device itself in conjunction with a viewer harness (e.g., Google Cardboard/Daydream or Samsung GearVR). It may also represent devices without stereo-presentation capabilities but with more advanced tracking, such as ARCore/ARKit-compatible devices.

Expand All @@ -65,7 +65,7 @@ function checkForVR() {
}
}, err => {
// An error occurred while requesting a VRDevice.
console.error('Unable to request a VR device.');
console.error('Unable to request a VR device:', err);
});
}
```
Expand All @@ -74,15 +74,15 @@ Future revisions of the API may add filter criteria to `navigator.vr.requestDevi

> **Non-normative Note:** If there are multiple VR devices available, the UA will need to pick which one to return. The UA is allowed to use any criteria it wishes to select which device is returned, including settings UI that allows users to manage device priority. Calling `navigator.vr.requestDevice` should not trigger device selection UI, however, as this would cause many sites to display VR-specific dialogs early in the document lifecycle without and user activation.
It's possible that even if no VR device is available initially one may become available while the application is running, or that a previously available device becomes unavailable. This will be most common with PC peripherals that can be connected at disconnected at any time. To respond to these changes pages can listen to the `devicechange` event on the `navigator.vr` object.
It's possible that even if no VR device is available initially, one may become available while the application is running, or that a previously available device becomes unavailable. This will be most common with PC peripherals that can be connected or disconnected at any time. Pages can listen to the `devicechange` event emitted on `navigator.vr` to respond to changes in device availability after the page loads. (VR devices already available when the page loads will not cause a `devicechange` event to be fired.)

```js
navigator.vr.addEventListener('devicechange', checkForVR);
```

### Sessions

A `VRDevice` only indicates the availabilty of a VR device. In order to do anything that involves the device's presentation or tracking capabilities, the application will need to request a `VRSession` from the `VRDevice`.
A `VRDevice` indicates only the availability of a VR device. In order to do anything that involves the device's presentation or tracking capabilities, the application will need to request a `VRSession` from the `VRDevice`.

Sessions can be created with one of two levels of access:

Expand Down

1 comment on commit c44dcaa

@cvan
Copy link
Contributor

@cvan cvan commented on c44dcaa Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're welcome 👍

Please sign in to comment.