Last active
March 13, 2017 16:45
-
-
Save zazabe/3a2f9db8084d5af0304ddbc0c84b20ec to your computer and use it in GitHub Desktop.
Get WebVR device info
This file contains hidden or 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
| var getDeviceData = function() { | |
| return navigator.getVRDisplays() | |
| .then(function(devices) { | |
| var device = devices[0]; | |
| var getInfo = function(obj) { | |
| var info = {}; | |
| for(var name in obj) { | |
| if(typeof obj[name] == 'object') { | |
| info[name] = getInfo(obj[name]); | |
| } else if (typeof obj[name] != 'function') { | |
| info[name] = obj[name]; | |
| } | |
| } | |
| return info; | |
| }; | |
| if(device) { | |
| var info = getInfo(device); | |
| info.leftEye = getInfo(device.getEyeParameters('left')); | |
| info.rightEye = getInfo(device.getEyeParameters('right')); | |
| return info; | |
| } else { | |
| return null; | |
| } | |
| }); | |
| }; | |
| getDeviceData().then(function(info) {console.log(JSON.stringify(info, null, ' '))}); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
experimental chrome for android fake device
{ "displayId": 1, "displayName": "Unofficial Cardboard Inc. The Classic", "isConnected": true, "isPresenting": false, "capabilities": { "hasOrientation": true, "hasPosition": false, "hasExternalDisplay": false, "canPresent": true }, "stageParameters": {}, "leftEye": { "offset": { "0": -0.029999999329447746, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 50, "downDegrees": 50, "leftDegrees": 50, "rightDegrees": 50 }, "renderWidth": 1280, "renderHeight": 1440 }, "rightEye": { "offset": { "0": 0.029999999329447746, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 50, "downDegrees": 50, "leftDegrees": 50, "rightDegrees": 50 }, "renderWidth": 1280, "renderHeight": 1440 } }HTC Vive
{ "displayId": 1, "displayName": "HTC Vive MV", "isConnected": true, "isPresenting": false, "capabilities": { "hasOrientation": true, "hasPosition": true, "hasExternalDisplay": true, "canPresent": true, "maxLayers": 1 }, "stageParameters": { "sittingToStandingTransform": { "0": 1, "1": 0, "2": 0, "3": 0, "4": 0, "5": 1, "6": 0, "7": 0, "8": 0, "9": 0, "10": 1, "11": 0, "12": 0, "13": 0, "14": 0, "15": 1 }, "sizeX": 0, "sizeZ": 0 }, "leftEye": { "offset": { "0": -0.03175000101327896, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 55.78550720214844, "downDegrees": 55.787662506103516, "leftDegrees": 54.37397003173828, "rightDegrees": 51.39063262939453 }, "renderWidth": 1512, "renderHeight": 1680 }, "rightEye": { "offset": { "0": 0.03175000101327896, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 55.88190841674805, "downDegrees": 55.63058853149414, "leftDegrees": 51.34524154663086, "rightDegrees": 54.32575225830078 }, "renderWidth": 1512, "renderHeight": 1680 } }Oculus Rift CV1
{ "displayId": 1, "displayName": "Oculus Rift CV1, Oculus VR", "isConnected": true, "isPresenting": false, "capabilities": { "hasOrientation": true, "hasPosition": true, "hasExternalDisplay": true, "canPresent": true, "maxLayers": 1 }, "stageParameters": { "sittingToStandingTransform": { "0": 1, "1": 0, "2": 0, "3": 0, "4": 0, "5": 1, "6": 0, "7": 0, "8": 0, "9": 0, "10": 1, "11": 0, "12": 0, "13": 1.0051966905593872, "14": 0, "15": 1 }, "sizeX": 0, "sizeZ": 0 }, "leftEye": { "offset": { "0": -0.033042486757040024, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 41.65303039550781, "downDegrees": 48.00802230834961, "leftDegrees": 43.97736740112305, "rightDegrees": 35.57476806640625 }, "renderWidth": 1332, "renderHeight": 1586 }, "rightEye": { "offset": { "0": 0.033042486757040024, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 41.65303039550781, "downDegrees": 48.00802230834961, "leftDegrees": 35.57476806640625, "rightDegrees": 43.97736740112305 }, "renderWidth": 1332, "renderHeight": 1586 } }Oculus Rift DK2
{ "displayId": 1, "displayName": "Oculus Rift DK2, Oculus VR", "isConnected": true, "isPresenting": false, "capabilities": { "hasOrientation": true, "hasPosition": true, "hasExternalDisplay": true, "canPresent": true, "maxLayers": 1 }, "stageParameters": { "sittingToStandingTransform": { "0": 1, "1": 0, "2": 0, "3": 0, "4": 0, "5": 1, "6": 0, "7": 0, "8": 0, "9": 0, "10": 1, "11": 0, "12": 0, "13": 1.0401796102523804, "14": 0, "15": 1 }, "sizeX": 0, "sizeZ": 0 }, "leftEye": { "offset": { "0": -0.03175000101327896, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 53.094383239746094, "downDegrees": 53.094383239746094, "leftDegrees": 46.6320915222168, "rightDegrees": 47.52769088745117 }, "renderWidth": 1182, "renderHeight": 1464 }, "rightEye": { "offset": { "0": 0.03175000101327896, "1": 0, "2": 0 }, "fieldOfView": { "upDegrees": 53.094383239746094, "downDegrees": 53.094383239746094, "leftDegrees": 47.52769088745117, "rightDegrees": 46.6320915222168 }, "renderWidth": 1182, "renderHeight": 1464 } }