From 7c0c62bc56c2b8ea4fc44783093b3c0196bc0488 Mon Sep 17 00:00:00 2001 From: Kevin Staunton-Lambert Date: Tue, 20 Dec 2022 14:18:18 +1100 Subject: [PATCH] chore: Swap webvr ro webxr polyfill packages (add iOS permission check on entering 360) --- src/big-vr-play-button.js | 9 ++++----- src/plugin.js | 7 +++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/big-vr-play-button.js b/src/big-vr-play-button.js index 5d398114..ecdc1ece 100644 --- a/src/big-vr-play-button.js +++ b/src/big-vr-play-button.js @@ -1,4 +1,5 @@ import videojs from 'video.js'; +import window from 'global/window'; const BigPlayButton = videojs.getComponent('BigPlayButton'); @@ -9,18 +10,16 @@ class BigVrPlayButton extends BigPlayButton { handleClick() { // For iOS we need permission for the device orientation data, this will pop up an 'Allow' if not already set - if (window.typeof(DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") { + // eslint-disable-next-line + if (typeof(window.DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") { window.DeviceMotionEvent.requestPermission().then(response => { if (response !== 'granted') { - this.log("DeviceMotionEvent permissions not set"); + this.log('DeviceMotionEvent permissions not set'); } }); } - super.handleClick(); } - - } videojs.registerComponent('BigVrPlayButton', BigVrPlayButton); diff --git a/src/plugin.js b/src/plugin.js index 335d0e66..74e4bc88 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -145,6 +145,7 @@ class VR extends Plugin { this.scene.add(this.movieScreen); const ambient = new THREE.HemisphereLight(0xffffff, 0xbbbbff, 0.7); + this.scene.add(ambient); } else if (projection === '360_LR' || projection === '360_TB') { // Left eye view @@ -802,8 +803,10 @@ void main() { window.addEventListener('vrdisplaydeactivate', this.handleVrDisplayDeactivate_, true); // For iOS we need permission for the device orientation data, this will pop up an 'Allow' - if (window.typeof(DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") { + // eslint-disable-next-line + if (typeof(window.DeviceMotionEvent) === 'function' && typeof(window.DeviceMotionEvent.requestPermission) === "function") { const self = this; + window.DeviceMotionEvent.requestPermission().then(response => { if (response === 'granted') { window.addEventListener('deviceorientation', (event) => { @@ -818,7 +821,7 @@ void main() { } onDeviceOrientationChange(pitch, roll, yaw) { - this.log(`orientation pitch=${parseInt(pitch)} roll=${parseInt(roll)} yaw=${parseInt(yaw)}`); + this.log(`orientation pitch=${parseInt(pitch, 10)} roll=${parseInt(roll, 10)} yaw=${parseInt(yaw, 10)}`); } buildControllers() {