From 8ca2e9ebe310e964e4d93367fd1d277588517d2b Mon Sep 17 00:00:00 2001 From: fukunee Date: Sat, 19 Sep 2026 16:08:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E9=94=AE=E5=8E=9F=E7=94=9F=20tilt=20?= =?UTF-8?q?=E6=9D=BE=E5=BC=80=E5=90=8E=E8=87=AA=E5=8A=A8=E5=9B=9E=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scene/CesiumGlobe.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/scene/CesiumGlobe.js b/src/scene/CesiumGlobe.js index ae3239a..f8955a4 100644 --- a/src/scene/CesiumGlobe.js +++ b/src/scene/CesiumGlobe.js @@ -255,6 +255,7 @@ export class CesiumGlobe { this._buildMarkers(); this._setupPick(); + this._setupRightRestore(); this._loadBoundaries(); this._buildCityLabels(); @@ -355,6 +356,36 @@ export class CesiumGlobe { viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK); } + // 右键原生 tilt 松开后自动回位:按下记录相机状态,松开恢复(并清掉 tilt 惯性余力) + _setupRightRestore() { + const scene = this.viewer.scene; + const camera = this.viewer.camera; + const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); + this._rightRestore = null; + + handler.setInputAction(() => { + this._rightRestore = { + position: Cesium.Cartesian3.clone(camera.position), + direction: Cesium.Cartesian3.clone(camera.direction), + up: Cesium.Cartesian3.clone(camera.up), + }; + }, Cesium.ScreenSpaceEventType.RIGHT_DOWN); + + handler.setInputAction(() => { + if (!this._rightRestore) return; + const s = this._rightRestore; + this._rightRestore = null; + const tiltState = scene.screenSpaceCameraController._lastInertiaTiltMovement; + if (tiltState) tiltState.inertiaEnabled = false; + camera.setView({ + destination: s.position, + orientation: { direction: s.direction, up: s.up }, + }); + }, Cesium.ScreenSpaceEventType.RIGHT_UP); + + this._rightRestoreHandler = handler; + } + // 相机平滑飞至某个标记上空并居中:回到与初始一致的高度与北朝上方向,左键拖拽手感不变 flyToEntry(index) { const entry = ENTRIES[index];