diff --git a/src/scene/CesiumGlobe.js b/src/scene/CesiumGlobe.js index 374b96f..728c444 100644 --- a/src/scene/CesiumGlobe.js +++ b/src/scene/CesiumGlobe.js @@ -212,7 +212,23 @@ export class CesiumGlobe { controller.enableCollisionDetection = true; // 必须开启:缩放距离限制在关闭时会被忽略 controller.minimumZoomDistance = 3000; // 最近约 3 km(城区尺度) controller.maximumZoomDistance = 8e6; // 最远约 8000 km - controller.maximumTiltAngle = Cesium.Math.toRadians(50); // 倾斜最多 50°(相对天底) + + // 限制最大倾斜角:pitch 夹取到 -40°(即从天底最多 50°)。用 postUpdate 手动夹取, + // 避免原生 maximumTiltAngle 在极限处与拖动反复角力产生的抖动。 + const MAX_TILT_PITCH = Cesium.Math.toRadians(-40); + scene.postUpdate.addEventListener(() => { + const camera = viewer.camera; + if (camera.pitch > MAX_TILT_PITCH) { + camera.setView({ + destination: Cesium.Cartesian3.clone(camera.positionWC), + orientation: { + heading: camera.heading, + pitch: MAX_TILT_PITCH, + roll: camera.roll, + }, + }); + } + }); // 限制鼠标按钮:只保留左键旋转 + 滚轮缩放;禁用中键倾斜、右键缩放 controller.rotateEventTypes = Cesium.CameraEventType.LEFT_DRAG;