Draw FIRMS fire glows through the draw port and take the FIRMS renderer off the Cesium list

The fire glows are one draw-port icon set with horizon cull, drawn on the
renderer's moving-icon path with a hold motion, as the layer's own icon
primitive drew them. Only glows that are new or changed are written, after
the set accepts them; fires a refresh drops are removed. Clicks read the
renderer's hit and match the layer's own set id. The sprite order registers
the set by its id.
This commit is contained in:
Sameh Khamis committed 2026-11-08 10:29:40 -08:00
1 parent 3fa1ad0283
commit b2502d6f37
11 files changed
+275 -118

No files matched your search

+14 -6
View File
@@ -15,6 +15,7 @@ import { createIconSet, ICON_CULL_LIFT } from './iconSet.js';
import { writeHoldSegment } from './iconSegment.js';
import { fakeInput } from '../input/testDoubles.mjs';
import { bindFakeCesiumScene } from '../testSupport/fakeCesiumScene.mjs';
import { createCesiumDraw } from '../render/cesium/draw.js';
const AUSTIN = { lon: -97.7, lat: 30.2 };
/** Antipode of Austin — as far behind the limb as a point on Earth can be. */
@@ -379,9 +380,14 @@ function createHarness(rawFires) {
},
frameState: { mode: Cesium.SceneMode.SCENE3D, mapProjection: new Cesium.GeographicProjection() },
mapProjection: new Cesium.GeographicProjection(),
requestRender: () => {},
isDestroyed: () => false,
},
};
bindFakeCesiumScene(viewer);
// The Cesium draw port over the stub scene: the glows are a real GPU icon
// set, whose rows say what the GPU would draw.
const draw = createCesiumDraw({ scene: viewer.scene, report: () => {} });
bindFakeCesiumScene(viewer, { draw: draw.port });
fakeInput(viewer);
const layer = createFirmsHeatmapLayer({
@@ -411,7 +417,7 @@ function createHarness(rawFires) {
const occluder = new Cesium.EllipsoidalOccluder(Cesium.Ellipsoid.WGS84, viewer.camera.positionWC);
const out = new Map();
for (let row = 0; row < set.count; row += 1)
out.set(set.idAt(row), set.show && gpuShows(set, row, occluder));
out.set(set.idAt(row), primitives[0].show !== false && set.show && gpuShows(set, row, occluder));
return out;
},
moveCameraTo(lon, lat, height = REPRO_HEIGHT_M) {
@@ -482,7 +488,8 @@ test('layer: a refresh keeps rows and restyles one whose index now holds another
const set = harness.icons();
const austin = set.row('firms-0');
const handle = set.handleAt(austin);
const before = set.width(austin);
const drawnPx = (row) => set.width(row) * set.scale(row);
const before = drawnPx(austin);
const beforeImage = set.imageFar(austin);
fires[0] = rawFire(AUSTIN.lat + 0.5, AUSTIN.lon, 1);
@@ -490,7 +497,7 @@ test('layer: a refresh keeps rows and restyles one whose index now holds another
const row = set.row('firms-0');
assert.equal(set.handleAt(row), handle, 'the row (and its pick id) survives the rebuild');
assert.ok(set.width(row) < before, `restyled for the weaker fire: ${set.width(row)} < ${before}`);
assert.ok(drawnPx(row) < before, `restyled for the weaker fire: ${drawnPx(row)} < ${before}`);
assert.notEqual(set.imageFar(row), beforeImage, 'a red glow becomes a yellow one');
const carto = Cesium.Cartographic.fromCartesian(set.position(row, 0, new Cesium.Cartesian3()));
assert.ok(Math.abs(Cesium.Math.toDegrees(carto.latitude) - (AUSTIN.lat + 0.5)) < 1e-6, 'moved to the new fire');
@@ -519,7 +526,7 @@ test('layer: re-enabling after the camera moved shows the icons, culled from the
// loaded, so enable() does not reload): the GPU culls from the current
// camera on the first frame.
const show = harness.showById();
assert.equal(harness.icons().show, true, 'the icon set is visible again');
assert.notEqual(harness.primitives[0].show, false, 'the icon set is visible again');
assert.equal(show.get('firms-1'), true, 'the Tokyo fire is revealed at enable time');
assert.equal(show.get('firms-0'), false, 'the Austin fire is NOT left shining through the planet');
} finally {
@@ -547,7 +554,8 @@ test('layer: a refresh drops rows whose fires left, and an empty one drops them
Array.from({ length: set.count }, (_, row) => set.idAt(row)),
['firms-0'],
);
assert.equal(set.metaAt(set.row('firms-0')).fire.lat, AUSTIN.lat, 'the kept row holds its own fire');
const kept = Cesium.Cartographic.fromCartesian(set.position(set.row('firms-0'), 0, new Cesium.Cartesian3()));
assert.ok(Math.abs(Cesium.Math.toDegrees(kept.latitude) - AUSTIN.lat) < 1e-6, 'the kept row holds its own fire');
fires.length = 0;
await harness.layer.update();
+35 -4
View File
@@ -17,6 +17,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fakeInput } from '../input/testDoubles.mjs';
import { bindFakeCesiumScene } from '../testSupport/fakeCesiumScene.mjs';
import { fakeDrawPort } from '../testSupport/fakeDrawPort.mjs';
const LAYER_SOURCE = readLayerSource(
path.join(path.dirname(fileURLToPath(import.meta.url)), 'firmsHeatmap.js'),
@@ -37,6 +38,9 @@ function makeFire(overrides = {}) {
};
}
/** A pick of the layer's glow `id`, as the renderer reports one of its icons. */
const glowPick = (id) => ({ glow: id });
/**
* Stand the layer up far enough to drive one click. `cardHit` is what the
* overlay host reports under the click position — the real host only publishes
@@ -73,16 +77,30 @@ function harness({
},
});
const draw = fakeDrawPort();
// A glow pick names the layer's own icon set, as the renderer's pick does.
const pick = () =>
picked?.glow
? {
primitive: {},
id: {
set: [...draw.sets.values()].find(
(record) => record.kind === 'icons' && !record.disposed,
)?.spec.id,
id: picked.glow,
},
}
: picked;
const viewer = {
scene: {
pick: () => picked,
pick,
canvas: { clientWidth: 1280, clientHeight: 800 },
camera: cameraPosition ? { positionWC: cameraPosition } : undefined,
globe: { ellipsoid: Cesium.Ellipsoid.WGS84 },
},
dataSources: { add() {}, remove() {} },
};
bindFakeCesiumScene(viewer);
bindFakeCesiumScene(viewer, { draw });
const input = fakeInput(viewer);
// The LOD rebuild (and with it the context-registration sweep) is inert
// without a data source, so tests that drive a real refresh need one.
@@ -205,7 +223,7 @@ test('far-side detections cannot consume the bounded ambient-card cohort', () =>
test('clicking a fire sprite selects it and requests the camera transfer', () => {
const fire = makeFire();
const h = harness({ fires: [fire], picked: { id: 'firms-7' } });
const h = harness({ fires: [fire], picked: glowPick('firms-7') });
try {
h.click();
assert.equal(h.requests.length, 1);
@@ -217,6 +235,19 @@ test('clicking a fire sprite selects it and requests the camera transfer', () =>
}
});
test('an item named like a fire in another draw set is not a fire', () => {
const h = harness({
fires: [makeFire()],
picked: { primitive: {}, id: { set: 'other-layer:1:icons', id: 'firms-7' } },
});
try {
h.click();
assert.equal(h.requests.length, 0);
} finally {
h.cleanup();
}
});
test('clicking a fire CARD behaves exactly like clicking its sprite', () => {
const fire = makeFire();
// The click lands on the card, but the scene pick returns the 3D-Tiles
@@ -239,7 +270,7 @@ test('clicking a fire CARD behaves exactly like clicking its sprite', () => {
// The voice model reads these labels as data (track_entity, get_entity_context,
// pointer_context); the voice card translates them where it shows them.
test('fire labels stay English data in a translated interface', () => {
const h = harness({ fires: [makeFire()], picked: { id: 'firms-7' } });
const h = harness({ fires: [makeFire()], picked: glowPick('firms-7') });
try {
setLocale('ru');
h.click();
+1 -1
View File
@@ -115,7 +115,7 @@ test('flights, AIS, and FIRMS enable paths are wired through the shared sprite r
assert.match(firmsLayer.enable.toString(), /restoreSpriteOrderOnEnable\('firms', viewer\)/);
assert.match(
createFirmsRendering.toString(),
/registerSpriteCollection\('firms', layerState\._iconPrimitive\);\s*restoreSpriteOrder\(layerState\._viewer\);/,
/spriteEntry = registerSpriteSet\('firms', set\.id\);\s*restoreSpriteOrder\(layerState\._viewer\);/,
'lazy FIRMS registration must restore order immediately',
);
});