Skip to content

Commit

Permalink
Access polyfilled vrDevice directly instead of string matching. In th…
Browse files Browse the repository at this point in the history
…e case of a WebVR native device present the PolyfillControls won't provide date in magic window mode on mobile devices (fix #3617)
  • Loading branch information
dmarcos committed Jun 4, 2018
1 parent 614cce8 commit aaa3bf0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/utils/device.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
var vrDisplay;
var polyfilledVRDisplay;
var POLYFILL_VRDISPLAY_ID = 'Cardboard VRDisplay';

if (navigator.getVRDisplays) {
navigator.getVRDisplays().then(function (displays) {
vrDisplay = displays.length && displays[0];
polyfilledVRDisplay = vrDisplay.displayName === POLYFILL_VRDISPLAY_ID;
});
}

Expand Down Expand Up @@ -109,10 +106,11 @@ module.exports.isNodeEnvironment = !module.exports.isBrowserEnvironment;
*/
module.exports.PolyfillControls = function PolyfillControls (object) {
var frameData;
var vrDisplay = window.webvrpolyfill.getPolyfillDisplays()[0];
if (window.VRFrameData) { frameData = new window.VRFrameData(); }
this.update = function () {
var pose;
if (!vrDisplay || !polyfilledVRDisplay) { return; }
if (!vrDisplay) { return; }
vrDisplay.getFrameData(frameData);
pose = frameData.pose;
if (pose.orientation !== null) {
Expand Down

0 comments on commit aaa3bf0

Please sign in to comment.