From 1126f9a79eba3109aa804cc3458d67c1b5ac8777 Mon Sep 17 00:00:00 2001 From: fukunee Date: Sat, 19 Sep 2026 14:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E9=94=AE=20tilt=20=E6=9D=BE=E5=BC=80?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E5=BD=92=E4=BD=8D=EF=BC=88=E8=AE=B0?= =?UTF-8?q?=E5=BD=95/=E6=81=A2=E5=A4=8D=E7=9B=B8=E6=9C=BA=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scene/CesiumGlobe.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/scene/CesiumGlobe.js b/src/scene/CesiumGlobe.js index 0a86305..2b29082 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,7 +356,34 @@ export class CesiumGlobe { viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK); } - // 右键环视:地表附近右键拖动,以点击点为球心调整视角,松开归位 + // 右键操作(原生 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; + 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];