Move the active fires layer's cells, camera, cards and LOD onto renderer ports

Heat cells are clamped rectangle fills in one draw set per layer
(firms:N:cells) instead of entities. The LOD watcher follows the camera
port's pose, view rectangle and moveEnd and the frame port's preRender;
cards project and horizon-test through the query port. Colours, the view
change thresholds and the padded bounds are unchanged. On a viewer with
no renderer bound, the layer answers projection, occlusion and preRender
from the viewer's scene, as it did before.

Policy, model, state, viewport, cards and lifecycle no longer import
Cesium and leave the allow-list. Rendering keeps Cesium for the detection
icons, which stay on the shared icon-set primitive, and loads the unbound
camera and draw factories. Heat cells are no longer entities, so
double-clicking one no longer makes the camera follow its centre.
This commit is contained in:
Sameh Khamis committed 2026-11-06 20:30:33 -08:00
1 parent 6f82f9cc9c
commit 6e23d2aac9
18 files changed
+639 -197

No files matched your search

+80
View File
@@ -851,3 +851,83 @@ test('the GNSS layer draws its cells as ground fills that stay out of the pick p
layer.destroy();
assert.equal(scene.added.length, 0);
});
test('the fires layer draws its heat cells as ground fills through the Cesium draw port', async (t) => {
const { createFirmsHeatmapLayer } =
await import('../../data/firmsHeatmap.js');
const { unregisterSpriteCollection } =
await import('../../data/spriteOrder.js');
const { fakeInput } = await import('../../input/testDoubles.mjs');
const { bindFakeCesiumScene } =
await import('../../testSupport/fakeCesiumScene.mjs');
const saved = globalThis.window;
globalThis.window = new EventTarget();
const scene = fakeScene();
// The layer keeps its detection icons over other sprites.
scene.primitives.contains = (p) => scene.added.includes(p);
scene.primitives.raiseToTop = () => {};
// Far out, where the layer draws heat cells rather than detections.
const viewer = {
scene,
camera: {
moveEnd: new Cesium.Event(),
positionWC: Cesium.Cartesian3.fromDegrees(-97.7, 30.2, 2e7),
directionWC: new Cesium.Cartesian3(0, 0, -1),
positionCartographic: Cesium.Cartographic.fromDegrees(-97.7, 30.2, 2e7),
},
};
// The real Cesium draw port; camera and frame from the viewer double.
const { unbind } = bindFakeCesiumScene(viewer, { draw: drawOf(viewer) });
const input = fakeInput(viewer);
const raw = (lat, lon, frp) => ({
lat,
lon,
frp,
confidence: 'h',
brightness: 340,
daynight: 'D',
acqDate: '2026-08-03',
acqTime: '0412',
instrument: 'VIIRS',
satellite: 'N20',
});
const layer = createFirmsHeatmapLayer({
id: 'firms',
name: 'FIRMS',
feed: {
getSnapshot: async () => ({
fires: [raw(30.5, -98.2, 1500), raw(-12.1, 131.4, 5)],
fetchedAt: Date.now(),
}),
},
overlayHost: { setEntries() {}, setVisible() {}, clearSource() {} },
});
t.after(() => {
input.destroy();
unbind();
unregisterSpriteCollection('firms');
if (saved === undefined) delete globalThis.window;
else globalThis.window = saved;
});
layer.init(viewer);
await layer.enable(viewer);
const all = (host, out = []) => {
out.push(host);
if (host instanceof Cesium.PrimitiveCollection)
for (let i = 0; i < host.length; i++) all(host.get(i), out);
return out;
};
const grounds = () =>
scene.added
.flatMap((host) => all(host))
.filter((p) => p instanceof Cesium.GroundPrimitive);
const instances = grounds().flatMap((g) => g.geometryInstances);
assert.equal(instances.length, 2, 'one fill per cell');
for (const instance of instances) {
assert.ok(instance.geometry instanceof Cesium.RectangleGeometry);
assert.match(instance.id.set, /^firms:\d+:cells$/);
}
assert.equal(grounds()[0].classificationType, Cesium.ClassificationType.BOTH);
layer.destroy(viewer);
assert.equal(grounds().length, 0);
});
-6
View File
@@ -63,13 +63,7 @@
"src/layers/cctv/state.js",
"src/layers/cctv/testing.js",
"src/layers/directions/index.js",
"src/layers/firms/cards.js",
"src/layers/firms/lifecycle.js",
"src/layers/firms/model.js",
"src/layers/firms/policy.js",
"src/layers/firms/rendering.js",
"src/layers/firms/state.js",
"src/layers/firms/viewport.js",
"src/layers/flights/controller.js",
"src/layers/flights/enrichment.js",
"src/layers/flights/evidence.js",