Hand features the engine instead of guessing it from a viewer

No code outside src/globe calls isGlobeEngine or engineFromViewer any
more (14 calls left before this). The features that still sniffed take
the engine from their caller:

- Projection and surface helpers (focus de-emphasis, icon orientation,
  ground snap, the mesh floor sampler, ground picks) take the engine; the
  engine view's scene carries its projector instead of registering itself
  as a viewer.
- Credits go only through engine.credits, so annotations and layers
  share one OSM credit state on Cesium too (it could show twice).
- The annotation board and the resolver work on the engine: camera
  assists, visibility and picks go through engine.camera,
  engine.projector and src/geo, without Cesium.
- The Recent Imagery box tool has one implementation for both engines,
  on capture-phase canvas pointer events with the layer's engine.ground
  preview; the Navara copy goes. On Cesium the preview outline is solid
  now, as on Navara.
- Scene interactions take the engine, and the render governor has an
  engine variant beside the Cesium one.

Remaining engine-specific features stay behind explicit seams until the
contract covers them: the draw tool's Cesium surface (stock click actions
cannot be suspended), the annotation drapes (animated materials), share
follow, Cesium post effects and cyber sonar, and data packs (meshes).

Coupling: Cesium-importing files fall from 31 to 27, `viewer` lines
from 1367 to 1234, engine sniffing calls from 14 to 0.
This commit is contained in:
German Khokhlov committed 2026-11-07 08:46:30 +04:00
1 parent 406dd9122e
commit f1ec9d4a22
61 files changed
+823 -1230

No files matched your search

+6 -8
View File
@@ -163,12 +163,9 @@ test('NearFarScalar rendered-size interpolation matches Cesium clamp endpoints',
assert.ok(middle > 0.5 && middle < 3);
});
test('a focus target projects through the engine registered for its scene', async () => {
test('a focus target projects through the projector its scene carries', async () => {
const { publishFocusTargetFromCachedPosition, clearFocusTarget } =
await import('./focusDeemphasis.js');
const { registerViewerEngine } = await import(
'../globe/cesium/engineFromViewer.js'
);
const { createFakeEngine } = await import('../globe/testing/fakeEngine.js');
const engine = createFakeEngine();
const projected = [];
@@ -176,9 +173,11 @@ test('a focus target projects through the engine registered for its scene', asyn
projected.push(position);
return Object.assign(result, { x: 300, y: 200 });
};
// A scene with no Cesium behind it (the Navara renderer's adapter).
const scene = { frameState: { frameNumber: 7 } };
const unregister = registerViewerEngine(scene, engine);
// A scene with no Cesium behind it (a layer's engine view).
const scene = {
frameState: { frameNumber: 7 },
projector: engine.projector,
};
try {
const target = publishFocusTargetFromCachedPosition({
ownerLayer: 'flights',
@@ -201,7 +200,6 @@ test('a focus target projects through the engine registered for its scene', asyn
assert.equal(target.frameNumber, 7);
} finally {
clearFocusTarget('flights');
unregister();
engine.destroy();
}
});