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];