Skip to content

Instantly share code, notes, and snippets.

@kennu
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennu/24161a199128fdf1f884 to your computer and use it in GitHub Desktop.
Save kennu/24161a199128fdf1f884 to your computer and use it in GitHub Desktop.
Oculus WebGL Examples
if (navigator.getVRDevices) {
var displayDevice, sensorDevice;
navigator.getVRDevices().then(function (devices) {
for (var i = 0; i < devices.length; i++) {
if (!displayDevice && devices[i] instanceof HMDVRDevice) {
displayDevice = devices[i];
}
}
for (var i = 0; i < devices.length; i++) {
if (!sensorDevice && devices[i] instanceof PositionSensorVRDevice && (!displayDevice || devices[i].hardwareUnitId == displayDevice.hardwareUnitId)) {
sensorDevice = devices[i];
}
}
if (displayDevice && sensorDevice) {
// VR is available!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment