Merge main through #1591 into the renderer seam

Brings in the wildlife sightings layer (#1591, iNaturalist and Acartia
sightings). Its badges, density glow and privacy cells draw through the
draw port: the badges and the glow are icons sets (iconCollection.js
batches point writes into one upsert per task), and the privacy cells are
ground-clamped shapes and lines sets swapped whole. The eye, the view
rectangle, clicks, projection, ground readiness and frames come from the
camera, query, input, globe and frame ports, so the layer, its card and
its placement no longer import Cesium.

Differences from main: the density glow is drawn as pixel-sized splats
(56 px) instead of metre-sized ones with a near fade; the card's pan eases
with cubicOut, the contract's nearest ease-out; ground heights are
resampled when the globe's load progress settles or its surface changes,
rather than on tileset load events.

Also fixes two things the last merge left: a double-click that starts on
the followed track and ends off it reaches the renderer's own follow again
(a press that cannot end a double-click on the track gives its hold back
at its release), and the Active Fires heat drapes under the weather
imagery, so weather turned on after it stacks above. CURRENT-STATE notes
that the 2D and Columbus scene-mode checks are gone.
This commit is contained in:
Sameh Khamis committed 2026-11-09 23:06:26 -08:00
commit 020a433b51
129 files changed
+22143 -336

No files matched your search

+123 -13
View File
@@ -5,21 +5,29 @@
// Run with: npm test
import test from 'node:test';
import assert from 'node:assert/strict';
import { fakeInput } from '../input/testDoubles.mjs';
import {
fakeInput,
FakeScreenSpaceEventHandler,
FAKE_EVENT_TYPES,
} from '../input/testDoubles.mjs';
import { bindRenderer } from '../render/rendererOf.js';
import { createCesiumInput } from '../render/cesium/input.js';
import { routeSceneDoubleClick, onSceneDoubleClick } from './cockpitInput.js';
function harness(t) {
t.mock.timers.enable({ apis: ['setTimeout'] });
function harness(t, { stock = null } = {}) {
t.mock.timers.enable({ apis: ['setTimeout', 'Date'] });
const viewer = {
scene: {
pick: () => null,
},
clock: { currentTime: 0 },
};
const input = fakeInput(viewer);
// The followed aircraft is drawn at (100, 100).
bindRenderer(viewer, { query: { project: () => ({ x: 100, y: 100 }) } });
const project = () => ({ x: 100, y: 100 });
// With `stock`, the renderer's own input port takes the viewer's stock
// double-click follow and runs it as the app's does; else the fake input.
const input = stock ? cesiumInput(viewer, stock, project) : fakeInput(viewer);
if (!stock) bindRenderer(viewer, { query: { project } });
const entity = {
id: 'flights:abc',
position: { getValue: () => ({ x: 1, y: 2, z: 3 }) },
@@ -31,12 +39,17 @@ function harness(t) {
destroyed: false,
entered: 0,
holds: 0,
holdStockFollow() {
this.holds += 1;
return () => {
this.holds -= 1;
};
},
// Counted here, unless the test watches the renderer's own hold.
...(stock
? {}
: {
holdStockFollow() {
this.holds += 1;
return () => {
this.holds -= 1;
};
},
}),
resolveEntryKind: () => 'aircraft',
enter() {
this.entered += 1;
@@ -53,6 +66,44 @@ function harness(t) {
return { input, controller, stop };
}
/** The Cesium renderer's input port over a fake handler, with `follow` as
* the viewer's stock double-click follow. */
function cesiumInput(viewer, follow, project) {
const stock = new FakeScreenSpaceEventHandler();
stock.setInputAction(follow, FAKE_EVENT_TYPES.LEFT_DOUBLE_CLICK);
viewer.screenSpaceEventHandler = stock;
viewer.scene.canvas = {
addEventListener() {},
removeEventListener() {},
};
const handler = new FakeScreenSpaceEventHandler();
const query = { project, pick: () => null, drillPick: () => [] };
const made = createCesiumInput(viewer, {
query,
createHandler: () => handler,
report: (error) => {
throw error;
},
document: null,
});
bindRenderer(viewer, { input: made.port, query });
const T = FAKE_EVENT_TYPES;
const fire = (type) => (position) => handler.fire(type, { position });
return {
down: fire(T.LEFT_DOWN),
up: fire(T.LEFT_UP),
click: fire(T.LEFT_CLICK),
tap(position) {
handler.fire(T.LEFT_DOWN, { position });
handler.fire(T.LEFT_UP, { position });
handler.fire(T.LEFT_CLICK, { position });
},
dblclick: fire(T.LEFT_DOUBLE_CLICK),
stockEnabled: (name) => made.port.behaviours[name].enabled,
destroy: () => made.dispose(),
};
}
const doubleClick = (input, position) => {
input.tap(position);
input.down(position);
@@ -88,15 +139,74 @@ test("a double-click elsewhere is the renderer's own", (t) => {
assert.equal(controller.holds, 0);
});
test('a single press on the track gives the stock follow back by itself', (t) => {
test('a single press on the track gives the stock follow back at its release, or by itself', (t) => {
const { input, controller } = harness(t);
input.tap({ x: 100, y: 100 });
assert.equal(controller.holds, 0, 'given back at the release');
t.mock.timers.tick(700);
input.down({ x: 100, y: 100 });
assert.equal(controller.holds, 1);
t.mock.timers.tick(700);
assert.equal(controller.holds, 0);
assert.equal(controller.holds, 0, 'a press never released lets go');
assert.equal(controller.entered, 0);
});
test("a double-click that starts on the track and ends off it is the renderer's own", (t) => {
const follows = [];
const { input, controller } = harness(t, {
stock: (event) => follows.push(event.position),
});
const on = { x: 120, y: 100 };
const off = { x: 140, y: 100 };
// As Cesium raises them: each press clicks, then the double-click.
input.tap(on);
input.tap(off);
input.dblclick(off);
assert.equal(controller.entered, 0);
assert.equal(follows.length, 1, 'the stock follow ran');
assert.equal(input.stockEnabled('dblclickFollow'), true);
});
test('a press elsewhere just before cannot make a press on the track keep its hold', (t) => {
const follows = [];
const { input, controller } = harness(t, {
stock: (event) => follows.push(event.position),
});
input.tap({ x: 500, y: 500 });
input.tap({ x: 120, y: 100 });
input.tap({ x: 140, y: 100 });
input.dblclick({ x: 140, y: 100 });
assert.equal(controller.entered, 0);
assert.equal(follows.length, 1, 'the stock follow ran');
});
test('a press on the track long after the last keeps no hold past its release', (t) => {
const { input, controller } = harness(t);
const on = { x: 100, y: 100 };
input.tap(on);
t.mock.timers.tick(701);
input.down(on);
input.up(on);
assert.equal(controller.holds, 0, 'it cannot end a double-click');
input.down(on);
input.up(on);
assert.equal(controller.holds, 1, 'a quick second press keeps it');
});
test('a double-click that ends on the track holds the stock follow off', (t) => {
const follows = [];
const { input, controller } = harness(t, {
stock: (event) => follows.push(event.position),
});
const on = { x: 110, y: 95 };
input.tap({ x: 140, y: 100 });
input.tap(on);
input.dblclick(on);
assert.equal(controller.entered, 1);
assert.deepEqual(follows, [], 'the stock follow did not run');
assert.equal(input.stockEnabled('dblclickFollow'), true, 'given back');
});
test('an active Cockpit leaves presses alone, and stopping lets a hold go', (t) => {
const { input, controller, stop } = harness(t);
controller.active = true;