From c196e15a8c7ccf594fe6a5044fbdcb51cc2eff91 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Wed, 11 Jul 2018 14:59:09 -0700 Subject: [PATCH] Disable Sensors if loading example within an iframe -- details in README in next commit. For #27 --- examples/index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/index.html b/examples/index.html index 697a1eb..9a10782 100644 --- a/examples/index.html +++ b/examples/index.html @@ -114,6 +114,15 @@ console.log('creating CardboardVRDisplay with options', config); var vrDisplay = new CardboardVRDisplay(config); +// If loading this inside of an iframe (see iframe.html), +// force using the `devicemotion` sensor fusion, rather than +// newer Generic Sensors due to an issue with sensors +// in iframes in Chrome < m69: +// https://bugs.chromium.org/p/chromium/issues/detail?id=849501 +if (window.self !== window.top) { + vrDisplay.poseSensor_.useDeviceMotion(); +} + navigator.getVRDisplays = function () { return new Promise(function (resolve) { resolve([vrDisplay]);