From 53e7b551d07f4349a09f8c60437e6c8f0ff8a9b4 Mon Sep 17 00:00:00 2001 From: fukunee Date: Sat, 19 Sep 2026 16:26:01 +0800 Subject: [PATCH] =?UTF-8?q?tilt=2050=C2=B0=20=E9=99=90=E5=88=B6=E6=94=B9?= =?UTF-8?q?=E7=94=A8=20postUpdate=20pitch=20=E5=A4=B9=E5=8F=96=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=9E=81=E9=99=90=E6=8A=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scene/CesiumGlobe.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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;