From 2687e5fd9500866f04e68abcd50e84d069e204bc Mon Sep 17 00:00:00 2001 From: fukunee Date: Sat, 19 Sep 2026 02:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E8=AE=B0=E4=BE=BF=E7=AD=BE=EF=BC=9A?= =?UTF-8?q?=E5=8A=A0=E7=BC=A9=E6=94=BE=E8=B7=9D=E7=A6=BB=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8D=E8=83=8C=E9=9D=A2=E5=8F=AF=E8=A7=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scene/CesiumGlobe.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scene/CesiumGlobe.js b/src/scene/CesiumGlobe.js index da6e5ed..763a1cf 100644 --- a/src/scene/CesiumGlobe.js +++ b/src/scene/CesiumGlobe.js @@ -271,17 +271,21 @@ export class CesiumGlobe { _updateMarkerLayer() { const scene = this.viewer.scene; const camera = scene.camera; - const toPos = new Cesium.Cartesian3(); + const outOfRange = camera.positionCartographic.height > 1e7; // 最远 1 万 km 内显示 + for (const m of this.markers) { const el = m.el; if (!el) continue; + if (outOfRange) { el.style.display = 'none'; continue; } + const win = Cesium.SceneTransforms.worldToWindowCoordinates(scene, m.position); if (!win) { el.style.display = 'none'; continue; } - Cesium.Cartesian3.subtract(m.position, camera.positionWC, toPos); - if (Cesium.Cartesian3.dot(toPos, camera.directionWC) < 0) { - el.style.display = 'none'; // 背对相机不显示 - continue; - } + + // 背面(远半球)隐藏:dot(P, C) <= |P|² 时为背对地球 + const dotPC = Cesium.Cartesian3.dot(m.position, camera.positionWC); + const r2 = Cesium.Cartesian3.magnitudeSquared(m.position); + if (dotPC <= r2) { el.style.display = 'none'; continue; } + el.style.display = 'block'; el.style.left = `${win.x}px`; el.style.top = `${win.y}px`;