refactor(overlays): layer labels through the engine

The world overlay host already projects through engine.projector and tests
the horizon with projector.horizonVisible; the last Cesium value on its
path, the snapshot of an entry's cullPosition, is now a geo Cartesian3.

Navara's horizonVisible is Cesium's EllipsoidalOccluder.isPointVisible:
tested against Cesium's own on 8 000 eye/point pairs (600 m to 20 000 km,
points under, on and over the ellipsoid; no disagreement) and at the limb
(a label 40 m under the ellipsoid just past the horizon is hidden, with its
cullPosition lifted 100 m it is shown). It ran per label per frame with
three new vectors each call; it now uses scratch vectors. Micro-measure
(500 labels per frame, no scavenge during the run): 7 941 B per frame
before, 51 after.

The W1 sources that projected with Cesium's SceneTransforms themselves -
the icon orientation's exact projection and the launch replay overlay - go
through the engine's projector when their scene or viewer has a registered
engine. Satellites, vessel labels and aircraft recession project nothing
themselves (the host does).

scripts/qa-overlay-engines.mjs publishes the same labels on both engines at
a city, an orbital and a limb pose and compares the painted rectangles:
worst 0 / 2 / 0 px; on both, the far-side label is not painted, the lifted
limb label is and the buried one is not.
This commit is contained in:
German Khokhlov committed 2026-10-16 21:14:52 +04:00
1 parent 311722e6de
commit 7d5a484796
9 files changed
+139 -37

No files matched your search

+12 -8
View File
@@ -1,3 +1,4 @@
import { engineFromViewer } from '../../globe/cesium/engineFromViewer.js';
import * as Cesium from 'cesium';
import {
createCyberSonarSampler,
@@ -483,10 +484,16 @@ export function createOverlays({ state: layerState, services, parts, source }) {
hideReplayVehicleOverlay();
return null;
}
const windowPosition = Cesium.SceneTransforms.worldToWindowCoordinates(
layerState._viewer.scene,
position,
);
// The engine's projector (engineFromViewer), as the world overlay.
const projector = engineFromViewer(layerState._viewer)?.projector;
const project = (point) =>
projector
? projector.worldToWindow(point)
: Cesium.SceneTransforms.worldToWindowCoordinates(
layerState._viewer.scene,
point,
);
const windowPosition = project(position);
if (!windowPosition) {
hideReplayVehicleOverlay();
return null;
@@ -548,10 +555,7 @@ export function createOverlays({ state: layerState, services, parts, source }) {
useForward ? forwardProgress : backwardProgress,
);
const tangentWindowPosition = tangentPosition
? Cesium.SceneTransforms.worldToWindowCoordinates(
layerState._viewer.scene,
tangentPosition,
)
? project(tangentPosition)
: null;
if (tangentWindowPosition) {
const screenDelta = Math.hypot(