From 3f739079e04611660bb2140c66f25cd8ebaf1311 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Thu, 21 Apr 2022 21:09:26 +0200 Subject: [PATCH 1/8] Fix #670 DataHelper.viewerCoordsToVector3 always returns null --- src/services/DataHelper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/DataHelper.js b/src/services/DataHelper.js index a07e75858..6fbdfd515 100644 --- a/src/services/DataHelper.js +++ b/src/services/DataHelper.js @@ -168,8 +168,8 @@ export class DataHelper extends AbstractService { viewerCoordsToVector3(viewerPoint) { const sphereIntersect = this.getIntersections(viewerPoint).filter(i => i.object.userData[MESH_USER_DATA]); - if (sphereIntersect) { - return sphereIntersect.point; + if (sphereIntersect.length) { + return sphereIntersect[0].point; } else { return null; From 9fba9b5399a9d1941c86166e8580a8d417d17acd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 11:38:09 +0200 Subject: [PATCH 2/8] Bump axios from 0.26.1 to 0.27.0 (#674) Bumps [axios](https://github.com/axios/axios) from 0.26.1 to 0.27.0. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.26.1...v0.27.0) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f2ebbfc0c..7f3b41cf0 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@vuepress/plugin-back-to-top": "^1.8.2", "@vuepress/plugin-google-analytics": "^1.8.2", "autoprefixer": "^10.3.3", - "axios": "^0.26.0", + "axios": "^0.27.0", "cpx2": "^4.1.2", "date-fns": "^2.23.0", "eslint": "^8.2.0", From 556d954970974eb7254e11b72e840f5db9d0d5a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 May 2022 10:08:46 +0200 Subject: [PATCH 3/8] Bump mocha from 9.2.2 to 10.0.0 (#675) Bumps [mocha](https://github.com/mochajs/mocha) from 9.2.2 to 10.0.0. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v9.2.2...v10.0.0) --- updated-dependencies: - dependency-name: mocha dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f3b41cf0..6c6b25981 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "eslint-plugin-import": "^2.25.2", "jsdoc": "^3.6.7", "marked": "^4.0.0", - "mocha": "^9.1.1", + "mocha": "^10.0.0", "nosleep.js": "^0.12.0", "npm-run-all": "^4.1.3", "postcss": "^8.3.6", From bd35930651a9fa64ce8758e03f50901132b3e6a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 May 2022 08:53:26 +0200 Subject: [PATCH 4/8] Bump three from 0.139.2 to 0.140.0 (#676) Bumps [three](https://github.com/mrdoob/three.js) from 0.139.2 to 0.140.0. - [Release notes](https://github.com/mrdoob/three.js/releases) - [Commits](https://github.com/mrdoob/three.js/commits) --- updated-dependencies: - dependency-name: three dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c6b25981..4764e9be6 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "url": "git://github.com/mistic100/Photo-Sphere-Viewer.git" }, "dependencies": { - "three": "^0.139.0", + "three": "^0.140.0", "uevent": "^2.1.1" }, "devDependencies": { From 0fc5a1111684fd0a6f2f2d9d533a827e1d780f27 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sun, 15 May 2022 10:20:12 +0200 Subject: [PATCH 5/8] Fix #680 markers: imageLayer size on HDPI screens --- src/plugins/markers/Marker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/markers/Marker.js b/src/plugins/markers/Marker.js index 492951ac0..33d29eaef 100644 --- a/src/plugins/markers/Marker.js +++ b/src/plugins/markers/Marker.js @@ -715,7 +715,7 @@ export class Marker { } // 100 is magic number that gives a coherent size at default zoom level - this.$el.scale.set(this.config.width / 100 * SYSTEM.pixelRatio, this.config.height / 100 * SYSTEM.pixelRatio, 1); + this.$el.scale.set(this.config.width / 100, this.config.height / 100, 1); break; // no default From 25a61d76ee0f90132297c3d0da2db29a1aa93f0e Mon Sep 17 00:00:00 2001 From: Damien Sorel Date: Fri, 20 May 2022 12:39:13 +0200 Subject: [PATCH 6/8] Fix #681 video: add playsinline attribute --- src/adapters/shared/AbstractVideoAdapter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/adapters/shared/AbstractVideoAdapter.js b/src/adapters/shared/AbstractVideoAdapter.js index 46f1a4d02..892bbf472 100644 --- a/src/adapters/shared/AbstractVideoAdapter.js +++ b/src/adapters/shared/AbstractVideoAdapter.js @@ -162,6 +162,7 @@ export class AbstractVideoAdapter extends AbstractAdapter { const video = document.createElement('video'); video.crossOrigin = this.psv.config.withCredentials ? 'use-credentials' : 'anonymous'; video.loop = true; + video.playsinline = true; video.style.display = 'none'; video.muted = this.config.muted; video.src = src; From 7e07deb74c5223976a6b0ad4a4d509530dd79e33 Mon Sep 17 00:00:00 2001 From: Damien Sorel Date: Fri, 20 May 2022 13:03:28 +0200 Subject: [PATCH 7/8] Close #679 improve touch support detection --- src/Viewer.js | 3 +- src/buttons/AbstractMoveButton.js | 5 ++- src/buttons/AbstractZoomButton.js | 5 ++- src/buttons/ZoomRangeButton.js | 5 ++- src/data/system.js | 51 ++++++++++++++++++++++--------- src/plugins/markers/Marker.js | 2 +- 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/Viewer.js b/src/Viewer.js index 3d73fe959..0d5bb303f 100644 --- a/src/Viewer.js +++ b/src/Viewer.js @@ -265,7 +265,8 @@ export class Viewer extends EventEmitter { this.setPanorama(this.config.panorama); } - SYSTEM.isTouchEnabled.then(enabled => toggleClass(this.container, 'psv--is-touch', enabled)); + toggleClass(this.container, 'psv--is-touch', SYSTEM.isTouchEnabled.initial); + SYSTEM.isTouchEnabled.promise.then(enabled => toggleClass(this.container, 'psv--is-touch', enabled)); // enable GUI after first render this.once(EVENTS.RENDER, () => { diff --git a/src/buttons/AbstractMoveButton.js b/src/buttons/AbstractMoveButton.js index 35c91fc59..3ac2606c2 100644 --- a/src/buttons/AbstractMoveButton.js +++ b/src/buttons/AbstractMoveButton.js @@ -89,7 +89,10 @@ export class AbstractMoveButton extends AbstractButton { * @override */ isSupported() { - return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) }; + return { + initial: !SYSTEM.isTouchEnabled.initial, + promise: SYSTEM.isTouchEnabled.promise.then(enabled => !enabled), + }; } /** diff --git a/src/buttons/AbstractZoomButton.js b/src/buttons/AbstractZoomButton.js index 8e2c88eb8..b611bda83 100644 --- a/src/buttons/AbstractZoomButton.js +++ b/src/buttons/AbstractZoomButton.js @@ -72,7 +72,10 @@ export class AbstractZoomButton extends AbstractButton { * @override */ isSupported() { - return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) }; + return { + initial: !SYSTEM.isTouchEnabled.initial, + promise: SYSTEM.isTouchEnabled.promise.then(enabled => !enabled), + }; } /** diff --git a/src/buttons/ZoomRangeButton.js b/src/buttons/ZoomRangeButton.js index 84df738eb..b0ff28f63 100644 --- a/src/buttons/ZoomRangeButton.js +++ b/src/buttons/ZoomRangeButton.js @@ -104,7 +104,10 @@ export class ZoomRangeButton extends AbstractButton { * @override */ isSupported() { - return { initial: true, promise: SYSTEM.isTouchEnabled.then(enabled => !enabled) }; + return { + initial: !SYSTEM.isTouchEnabled.initial, + promise: SYSTEM.isTouchEnabled.promise.then(enabled => !enabled), + }; } /** diff --git a/src/data/system.js b/src/data/system.js index 644b52afa..323a4797f 100644 --- a/src/data/system.js +++ b/src/data/system.js @@ -1,4 +1,7 @@ import { PSVError } from '../PSVError'; +import { VIEWER_DATA } from './constants'; + +const LOCALSTORAGE_TOUCH_SUPPORT = `${VIEWER_DATA}_touchSupport`; /** * @summary General information about the system @@ -12,7 +15,7 @@ import { PSVError } from '../PSVError'; * @property {string} mouseWheelEvent * @property {string} fullscreenEvent * @property {Function} getMaxCanvasWidth - Returns the max width of a canvas allowed by the browser - * @property {Promise} isTouchEnabled + * @property {{initial: boolean, promise: Promise}} isTouchEnabled */ export const SYSTEM = { loaded : false, @@ -81,27 +84,47 @@ function getWebGLCtx() { /** * @summary Detects if the user is using a touch screen - * @returns {Promise} + * @returns {{initial: boolean, promise: Promise}} * @private */ function isTouchEnabled() { - return new Promise((resolve) => { - const listener = (e) => { - if (e) { - resolve(true); - } - else { - resolve(false); - } + let initial = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0); + if (LOCALSTORAGE_TOUCH_SUPPORT in localStorage) { + initial = localStorage[LOCALSTORAGE_TOUCH_SUPPORT] === 'true'; + } + + const promise = new Promise((resolve) => { + let clear; - window.removeEventListener('touchstart', listener); + const listenerMouse = () => { + clear(); + localStorage[LOCALSTORAGE_TOUCH_SUPPORT] = false; + resolve(false); }; - window.addEventListener('touchstart', listener, false); + const listenerTouch = () => { + clear(); + localStorage[LOCALSTORAGE_TOUCH_SUPPORT] = true; + resolve(true); + }; - // after 10 secs auto-reject the promise - setTimeout(listener, 10000); + const listenerTimeout = () => { + clear(); + localStorage[LOCALSTORAGE_TOUCH_SUPPORT] = initial; + resolve(initial); + }; + + clear = () => { + window.removeEventListener('mousedown', listenerMouse); + window.removeEventListener('touchstart', listenerTouch); + }; + + window.addEventListener('mousedown', listenerMouse, false); + window.addEventListener('touchstart', listenerTouch, false); + setTimeout(listenerTimeout, 10000); }); + + return { initial, promise }; } /** diff --git a/src/plugins/markers/Marker.js b/src/plugins/markers/Marker.js index 33d29eaef..4e8d6d69e 100644 --- a/src/plugins/markers/Marker.js +++ b/src/plugins/markers/Marker.js @@ -1,5 +1,5 @@ import * as THREE from 'three'; -import { CONSTANTS, PSVError, SYSTEM, utils } from '../..'; +import { CONSTANTS, PSVError, utils } from '../..'; import { getShortestArc, logWarn } from '../../utils'; import { MARKER_DATA, SVG_NS } from './constants'; import { getPolygonCenter, getPolylineCenter } from './utils'; From c2d70f1145515137c6d59ab1aa21ede9f9d805b3 Mon Sep 17 00:00:00 2001 From: Damien Sorel Date: Fri, 20 May 2022 13:11:52 +0200 Subject: [PATCH 8/8] Close #664 gyroscope: longer detection timeout --- src/plugins/gyroscope/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugins/gyroscope/index.js b/src/plugins/gyroscope/index.js index 136f3685b..67a45b951 100644 --- a/src/plugins/gyroscope/index.js +++ b/src/plugins/gyroscope/index.js @@ -279,9 +279,7 @@ export class GyroscopePlugin extends AbstractPlugin { }; window.addEventListener('deviceorientation', listener, false); - - // after 2 secs, auto-reject the promise - setTimeout(listener, 2000); + setTimeout(listener, 10000); }); } else {