From 63e2194f4e12f6edbad931b80b14b6be6cb449c3 Mon Sep 17 00:00:00 2001 From: Vincent JAILLOT Date: Thu, 19 Sep 2024 11:52:50 +0200 Subject: [PATCH] chore(deps): bump @tweenjs/tween.js from 23.1.2 to 25.0.0 --- package-lock.json | 14 ++++++++++---- package.json | 2 +- src/Controls/StreetControls.js | 9 +++++++-- src/Utils/CameraUtils.js | 10 ++++++---- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8337663db0..7434df2196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@mapbox/mapbox-gl-style-spec": "^13.28.0", "@mapbox/vector-tile": "^2.0.3", "@tmcw/togeojson": "^5.8.1", - "@tweenjs/tween.js": "^23.1.2", + "@tweenjs/tween.js": "^25.0.0", "3d-tiles-renderer": "^0.3.37", "brotli-compress": "^1.3.3", "copc": "^0.0.6", @@ -2698,9 +2698,9 @@ "license": "MIT" }, "node_modules/@tweenjs/tween.js": { - "version": "23.1.3", - "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", - "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==" + "version": "25.0.0", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-25.0.0.tgz", + "integrity": "sha512-XKLA6syeBUaPzx4j3qwMqzzq+V4uo72BnlbOjmuljLrRqdsd3qnzvZZoxvMHZ23ndsRS4aufU6JOZYpCbU6T1A==" }, "node_modules/@types/body-parser": { "version": "1.19.5", @@ -2991,6 +2991,12 @@ "meshoptimizer": "~0.18.1" } }, + "node_modules/@types/three/node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "dev": true + }, "node_modules/@types/webxr": { "version": "0.5.20", "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.20.tgz", diff --git a/package.json b/package.json index 63f7a2bc2c..e38bfc37bd 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@mapbox/mapbox-gl-style-spec": "^13.28.0", "@mapbox/vector-tile": "^2.0.3", "@tmcw/togeojson": "^5.8.1", - "@tweenjs/tween.js": "^23.1.2", + "@tweenjs/tween.js": "^25.0.0", "3d-tiles-renderer": "^0.3.37", "brotli-compress": "^1.3.3", "copc": "^0.0.6", diff --git a/src/Controls/StreetControls.js b/src/Controls/StreetControls.js index e0e98245bf..b6cd45c874 100644 --- a/src/Controls/StreetControls.js +++ b/src/Controls/StreetControls.js @@ -299,7 +299,7 @@ class StreetControls extends FirstPersonControls { startQuaternion.copy(this.camera.quaternion); this.end.copy(this.camera); this.end.lookAt(position); - this.tween = new TWEEN.Tween({ t: 0 }, this.tweenGroup).to({ t: 1 }, time) + this.tween = new TWEEN.Tween({ t: 0 }).to({ t: 1 }, time) .easing(TWEEN.Easing.Quadratic.Out) .onComplete(() => { this.stopAnimations(); @@ -310,6 +310,8 @@ class StreetControls extends FirstPersonControls { }) .start(); + this.tweenGroup.add(this.tween); + this.animationFrameRequester = () => { this.tweenGroup.update(); // call reset from super class FirsPersonControls to make mouse rotation managed by FirstPersonControl still aligned @@ -340,7 +342,7 @@ class StreetControls extends FirstPersonControls { this.stopAnimations(); - this.tween = new TWEEN.Tween(this.camera.position, this.tweenGroup) // Create a new tween that modifies camera position + this.tween = new TWEEN.Tween(this.camera.position) // Create a new tween that modifies camera position .to(position.clone(), time) .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth. .onComplete(() => { @@ -349,6 +351,8 @@ class StreetControls extends FirstPersonControls { }) .start(); + this.tweenGroup.add(this.tween); + this.animationFrameRequester = () => { this.tweenGroup.update(); this.view.notifyChange(this.camera); @@ -364,6 +368,7 @@ class StreetControls extends FirstPersonControls { if (this.tween) { this.tween.stop(); this.tween = undefined; + this.tweenGroup.removeAll(); } if (this.animationFrameRequester) { this.view.removeFrameRequester(MAIN_LOOP_EVENTS.BEFORE_RENDER, this.animationFrameRequester); diff --git a/src/Utils/CameraUtils.js b/src/Utils/CameraUtils.js index 308be31f4e..5bccc8ece6 100644 --- a/src/Utils/CameraUtils.js +++ b/src/Utils/CameraUtils.js @@ -234,7 +234,7 @@ class CameraRig extends THREE.Object3D { this.end.target.rotation.z = this.start.target.rotation.z + difference - Math.sign(difference) * 2 * Math.PI; } - animations.push(new TWEEN.Tween(factor, tweenGroup).to({ t: 1 }, time) + animations.push(new TWEEN.Tween(factor).to({ t: 1 }, time) .easing(params.easing) .onUpdate((d) => { // rotate to coord destination in geocentric projection @@ -251,21 +251,23 @@ class CameraRig extends THREE.Object3D { // translate to coordinate destination in planar projection if (view.referenceCrs != 'EPSG:4978') { - animations.push(new TWEEN.Tween(this.position, tweenGroup) + animations.push(new TWEEN.Tween(this.position) .to(this.end.position, time) .easing(params.easing)); } // translate to altitude zero - animations.push(new TWEEN.Tween(this.seaLevel.position, tweenGroup) + animations.push(new TWEEN.Tween(this.seaLevel.position) .to(this.end.seaLevel.position, time) .easing(params.easing)); // translate camera position - animations.push(new TWEEN.Tween(this.camera.position, tweenGroup) + animations.push(new TWEEN.Tween(this.camera.position) .to(this.end.camera.position, time) .easing(params.easing)); + tweenGroup.add(...animations); + // update animations, transformation and view this.animationFrameRequester = () => { tweenGroup.update();