refactor(overlays): use the globe engine

The world overlay host takes its frames (frames.postRender), camera events
(camera.moveEnd), canvas size (host.size), projection matrix
(projector.viewProjection), horizon test (projector.horizonVisible) and
render requests (render.request('world-overlay')) from the globe engine.
initWorldOverlay accepts an engine or, for callers that still hold a
viewer, resolves the viewer's engine through engineFromViewer.

Contract: camera.position(result) becomes camera.livePosition, one
engine-owned object holding the current position, so per-frame readers
and paint lanes keep a live camera position without allocating; engine
events gain raiseValue for argument-list-free frame dispatch. Steady-state
frame allocation is unchanged (worker probe, 30 chunks: 2696/9536/38593
B/frame before and after; detection 473749 -> 408085).
This commit is contained in:
German Khokhlov committed 2026-10-15 18:32:40 +04:00
1 parent 58a196374f
commit aaa6074663
11 files changed
+284 -134

No files matched your search

+17 -3
View File
@@ -188,7 +188,7 @@ test('assertGlobeEngine accepts a complete engine and names every missing capabi
test('the contract carries what the shell infrastructure needs', () => {
for (const member of [
'camera.position',
'camera.livePosition',
'camera.height',
'maps.releasePhotorealTiles',
])
@@ -196,12 +196,12 @@ test('the contract carries what the shell infrastructure needs', () => {
const engine = createFakeEngine();
const broken = {
...engine,
camera: { ...engine.camera, position: undefined, height: 1 },
camera: { ...engine.camera, livePosition: undefined, height: 1 },
maps: { ...engine.maps, releasePhotorealTiles: undefined },
};
assert.throws(
() => assertGlobeEngine(broken),
/camera\.position.*camera\.height.*maps\.releasePhotorealTiles/,
/camera\.livePosition.*camera\.height.*maps\.releasePhotorealTiles/,
);
});
@@ -256,3 +256,17 @@ test('the contract suite rejects a raw Cesium-style event that double-registers'
failed.join('\n'),
);
});
test('raiseValue raises exactly one argument with the event semantics', () => {
const event = createEngineEvent();
const seen = [];
const second = (...values) => seen.push(['second', values]);
event.addEventListener((...values) => {
seen.push(['first', values]);
event.removeEventListener(second);
});
event.addEventListener(second);
event.raiseValue(42);
assert.deepEqual(seen, [['first', [42]]]);
assert.equal(event.numberOfListeners, 1);
});