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

+19 -4
View File
@@ -354,12 +354,27 @@ test('fake drillPick records width and height; maps return promises', async () =
}
});
test('fake camera position fills a result and height is the pose height', () => {
test('fake livePosition is one object that follows the camera; height is the pose height', () => {
const engine = createFakeEngine({ altitude: 2_000_000 });
const result = geo.cartesian3.create();
assert.equal(engine.camera.position(result), result);
const live = engine.camera.livePosition;
assert.ok(
geo.cartesian3.distance(result, engine.camera.pose().position) < 1e-6,
geo.cartesian3.distance(live, engine.camera.pose().position) < 1e-6,
);
assert.ok(Math.abs(engine.camera.height() - 2_000_000) < 0.01);
engine.fake.setPose({ longitude: 0.3, latitude: 0.2, height: 500 });
assert.equal(engine.camera.livePosition, live);
assert.ok(
geo.cartesian3.distance(live, engine.camera.pose().position) < 1e-6,
);
});
test('fake host elements can be supplied', () => {
const container = { id: 'globe' };
const canvas = { id: 'canvas' };
const engine = createFakeEngine({ container, canvas });
assert.equal(engine.host.container, container);
assert.equal(engine.host.canvas, canvas);
assert.deepEqual(createFakeEngine().host.container, {
kind: 'fake-container',
});
});