Last active
August 29, 2015 14:06
-
-
Save kennu/24161a199128fdf1f884 to your computer and use it in GitHub Desktop.
Oculus WebGL Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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