mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
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:
commit
020a433b51
129 files changed
+22143
-336
No files matched your search
+139
-31
@@ -22,16 +22,28 @@ function stubCamera() {
|
||||
return {
|
||||
calls,
|
||||
heading: Cesium.Math.toRadians(45),
|
||||
cancelFlight() { calls.cancelFlight += 1; },
|
||||
flyToBoundingSphere(sphere, options) { calls.flights.push({ sphere, options }); },
|
||||
cancelFlight() {
|
||||
calls.cancelFlight += 1;
|
||||
},
|
||||
flyToBoundingSphere(sphere, options) {
|
||||
calls.flights.push({ sphere, options });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('a focus request carries the clicked target to any registered listener', () => {
|
||||
const target = new EventTarget();
|
||||
const seen = [];
|
||||
const dispose = registerWorldFocusRequestListener(target, (event) => seen.push(event.detail));
|
||||
assert.equal(requestWorldFocus({ kind: 'vessel', position: POSITION, id: '123' }, target), true);
|
||||
const dispose = registerWorldFocusRequestListener(target, (event) =>
|
||||
seen.push(event.detail),
|
||||
);
|
||||
assert.equal(
|
||||
requestWorldFocus(
|
||||
{ kind: 'vessel', position: POSITION, id: '123' },
|
||||
target,
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(seen.length, 1);
|
||||
assert.equal(seen[0].kind, 'vessel');
|
||||
assert.equal(seen[0].id, '123');
|
||||
@@ -45,7 +57,9 @@ test('a focus request carries the clicked target to any registered listener', ()
|
||||
test('requests without a kind or a position are dropped, never dispatched', () => {
|
||||
const target = new EventTarget();
|
||||
let count = 0;
|
||||
target.addEventListener(WORLD_FOCUS_REQUEST_EVENT, () => { count += 1; });
|
||||
target.addEventListener(WORLD_FOCUS_REQUEST_EVENT, () => {
|
||||
count += 1;
|
||||
});
|
||||
assert.equal(requestWorldFocus({ position: POSITION }, target), false);
|
||||
assert.equal(requestWorldFocus({ kind: 'vessel' }, target), false);
|
||||
assert.equal(requestWorldFocus(null, target), false);
|
||||
@@ -75,51 +89,95 @@ test('a refusing policy (cockpit owns the camera) never reaches the flight', ()
|
||||
const result = routeWorldFocusRequest(
|
||||
{ detail: { kind: 'vessel', id: '123', position: POSITION } },
|
||||
() => false,
|
||||
() => { flights += 1; },
|
||||
() => {
|
||||
flights += 1;
|
||||
},
|
||||
);
|
||||
assert.equal(result, false);
|
||||
assert.equal(flights, 0);
|
||||
});
|
||||
|
||||
test('malformed requests are inert', () => {
|
||||
assert.equal(routeWorldFocusRequest(null, () => 'x', () => 'y'), false);
|
||||
assert.equal(routeWorldFocusRequest({ detail: { kind: 'vessel' } }, () => 'x', () => 'y'), false);
|
||||
assert.equal(
|
||||
routeWorldFocusRequest(
|
||||
null,
|
||||
() => 'x',
|
||||
() => 'y',
|
||||
),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
routeWorldFocusRequest(
|
||||
{ detail: { kind: 'vessel' } },
|
||||
() => 'x',
|
||||
() => 'y',
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
// A request that cannot fly must never cost the user their tracking: the UI
|
||||
// policy releases the follow camera, so validation happens BEFORE it runs.
|
||||
test('an unflyable request never reaches the release policy', () => {
|
||||
const unflyable = [
|
||||
{ kind: 'plane', position: POSITION }, // no framing for this kind
|
||||
{ kind: 'vessel', position: { x: NaN, y: 0, z: 0 } }, // malformed position
|
||||
{ kind: 'vessel', position: { x: 0, y: 0 } }, // truthy but incomplete
|
||||
{ kind: 'plane', position: POSITION }, // no framing for this kind
|
||||
{ kind: 'vessel', position: { x: NaN, y: 0, z: 0 } }, // malformed position
|
||||
{ kind: 'vessel', position: { x: 0, y: 0 } }, // truthy but incomplete
|
||||
{ kind: 'vessel', id: '123', position: { x: 0, y: 0, z: 0 } }, // ECEF origin
|
||||
{ kind: 'fire', id: 'fire-1', position: { x: 1, y: 1, z: 1 } }, // finite but inside Earth
|
||||
{ kind: 'vessel', position: 'somewhere' },
|
||||
{ kind: 'vessel', position: POSITION }, // missing owner id
|
||||
{ kind: 'vessel', position: POSITION }, // missing owner id
|
||||
{ position: POSITION },
|
||||
];
|
||||
for (const detail of unflyable) {
|
||||
assert.equal(isValidWorldFocusTarget(detail), false, JSON.stringify(detail));
|
||||
assert.equal(
|
||||
isValidWorldFocusTarget(detail),
|
||||
false,
|
||||
JSON.stringify(detail),
|
||||
);
|
||||
let policyRuns = 0;
|
||||
const result = routeWorldFocusRequest(
|
||||
{ detail },
|
||||
() => { policyRuns += 1; return 'released'; },
|
||||
() => {
|
||||
policyRuns += 1;
|
||||
return 'released';
|
||||
},
|
||||
() => 'flew',
|
||||
);
|
||||
assert.equal(result, false, JSON.stringify(detail));
|
||||
assert.equal(policyRuns, 0, `the policy must not run for ${JSON.stringify(detail)}`);
|
||||
assert.equal(
|
||||
policyRuns,
|
||||
0,
|
||||
`the policy must not run for ${JSON.stringify(detail)}`,
|
||||
);
|
||||
// Nor may such a request be dispatched in the first place.
|
||||
assert.equal(requestWorldFocus(detail, new EventTarget()), false);
|
||||
}
|
||||
assert.equal(isValidWorldFocusTarget({ kind: 'vessel', id: '123', position: POSITION }), true);
|
||||
assert.equal(isValidWorldFocusTarget({ kind: 'fire', id: 'fire-1', position: POSITION }), true);
|
||||
assert.equal(
|
||||
isValidWorldFocusTarget({ kind: 'vessel', id: '123', position: POSITION }),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isValidWorldFocusTarget({ kind: 'fire', id: 'fire-1', position: POSITION }),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test('the transfer flight supersedes any flight in progress and keeps the operator heading', () => {
|
||||
const camera = stubCamera();
|
||||
assert.equal(flyToWorldTarget(bindFakeCesiumCamera({ camera }), { kind: 'vessel', id: '123', position: POSITION }), true);
|
||||
assert.equal(camera.calls.cancelFlight, 1, 'a prior flight must be cancelled, not queued');
|
||||
assert.equal(
|
||||
flyToWorldTarget(bindFakeCesiumCamera({ camera }), {
|
||||
kind: 'vessel',
|
||||
id: '123',
|
||||
position: POSITION,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
camera.calls.cancelFlight,
|
||||
1,
|
||||
'a prior flight must be cancelled, not queued',
|
||||
);
|
||||
assert.equal(camera.calls.flights.length, 1);
|
||||
const { sphere, options } = camera.calls.flights[0];
|
||||
assert.equal(sphere.radius, WORLD_FOCUS_FRAMING.vessel.radiusM);
|
||||
@@ -132,39 +190,89 @@ test('the transfer flight supersedes any flight in progress and keeps the operat
|
||||
|
||||
test('fires frame wider than vessels — a fire is read by its surroundings', () => {
|
||||
const camera = stubCamera();
|
||||
flyToWorldTarget(bindFakeCesiumCamera({ camera }), { kind: 'fire', id: 'fire-1', position: POSITION });
|
||||
flyToWorldTarget(bindFakeCesiumCamera({ camera }), {
|
||||
kind: 'fire',
|
||||
id: 'fire-1',
|
||||
position: POSITION,
|
||||
});
|
||||
const { sphere, options } = camera.calls.flights[0];
|
||||
assert.equal(sphere.radius, WORLD_FOCUS_FRAMING.fire.radiusM);
|
||||
assert.equal(options.offset.range, WORLD_FOCUS_FRAMING.fire.rangeM);
|
||||
assert.ok(WORLD_FOCUS_FRAMING.fire.rangeM > WORLD_FOCUS_FRAMING.vessel.rangeM);
|
||||
assert.ok(WORLD_FOCUS_FRAMING.fire.radiusM > WORLD_FOCUS_FRAMING.vessel.radiusM);
|
||||
assert.ok(
|
||||
WORLD_FOCUS_FRAMING.fire.rangeM > WORLD_FOCUS_FRAMING.vessel.rangeM,
|
||||
);
|
||||
assert.ok(
|
||||
WORLD_FOCUS_FRAMING.fire.radiusM > WORLD_FOCUS_FRAMING.vessel.radiusM,
|
||||
);
|
||||
});
|
||||
|
||||
test('every framing is a real oblique standoff, not a nadir or an inside-out sphere', () => {
|
||||
const kinds = Object.keys(WORLD_FOCUS_FRAMING);
|
||||
assert.deepEqual(kinds.sort(), ['fire', 'vessel']);
|
||||
assert.deepEqual(kinds.sort(), [
|
||||
'fire',
|
||||
'sighting',
|
||||
'sighting-area',
|
||||
'vessel',
|
||||
]);
|
||||
for (const kind of kinds) {
|
||||
const framing = WORLD_FOCUS_FRAMING[kind];
|
||||
// Looking DOWN at the target, but obliquely — a nadir drop reads as a map.
|
||||
assert.ok(framing.pitchDeg < 0, `${kind}: pitch must look down, got ${framing.pitchDeg}`);
|
||||
assert.ok(framing.pitchDeg > -80, `${kind}: pitch must stay oblique, got ${framing.pitchDeg}`);
|
||||
assert.ok(
|
||||
framing.pitchDeg < 0,
|
||||
`${kind}: pitch must look down, got ${framing.pitchDeg}`,
|
||||
);
|
||||
assert.ok(
|
||||
framing.pitchDeg > -80,
|
||||
`${kind}: pitch must stay oblique, got ${framing.pitchDeg}`,
|
||||
);
|
||||
// Standing off outside the framed sphere, at a human-readable distance.
|
||||
assert.ok(framing.radiusM > 0, `${kind}: radius must be positive`);
|
||||
assert.ok(
|
||||
framing.rangeM > framing.radiusM,
|
||||
`${kind}: range ${framing.rangeM} must stand off outside radius ${framing.radiusM}`,
|
||||
);
|
||||
assert.ok(framing.rangeM <= 10000, `${kind}: range must stay close-in, got ${framing.rangeM}`);
|
||||
// An obscured sighting frames its entire 0.2° privacy cell.
|
||||
const maximumRange = kind === 'sighting-area' ? 60000 : 10000;
|
||||
assert.ok(
|
||||
framing.rangeM <= maximumRange,
|
||||
`${kind}: range must fit its surface extent, got ${framing.rangeM}`,
|
||||
);
|
||||
}
|
||||
// Exact shipped values — a silent retune must show up as a failing test.
|
||||
assert.deepEqual({ ...WORLD_FOCUS_FRAMING.vessel }, { radiusM: 150, rangeM: 1200, pitchDeg: -30 });
|
||||
assert.deepEqual({ ...WORLD_FOCUS_FRAMING.fire }, { radiusM: 400, rangeM: 3000, pitchDeg: -35 });
|
||||
assert.deepEqual(
|
||||
{ ...WORLD_FOCUS_FRAMING.vessel },
|
||||
{ radiusM: 150, rangeM: 1200, pitchDeg: -30 },
|
||||
);
|
||||
assert.deepEqual(
|
||||
{ ...WORLD_FOCUS_FRAMING.fire },
|
||||
{ radiusM: 400, rangeM: 3000, pitchDeg: -35 },
|
||||
);
|
||||
assert.deepEqual(
|
||||
{ ...WORLD_FOCUS_FRAMING.sighting },
|
||||
{ radiusM: 250, rangeM: 2500, pitchDeg: -40 },
|
||||
);
|
||||
assert.deepEqual(
|
||||
{ ...WORLD_FOCUS_FRAMING['sighting-area'] },
|
||||
{ radiusM: 11000, rangeM: 60000, pitchDeg: -55 },
|
||||
);
|
||||
});
|
||||
|
||||
test('unknown kinds and missing viewers issue no flight', () => {
|
||||
const camera = stubCamera();
|
||||
assert.equal(flyToWorldTarget(bindFakeCesiumCamera({ camera }), { kind: 'plane', position: POSITION }), false);
|
||||
assert.equal(flyToWorldTarget(bindFakeCesiumCamera({ camera }), { kind: 'vessel' }), false);
|
||||
assert.equal(flyToWorldTarget(null, { kind: 'vessel', position: POSITION }), false);
|
||||
assert.equal(
|
||||
flyToWorldTarget(bindFakeCesiumCamera({ camera }), {
|
||||
kind: 'plane',
|
||||
position: POSITION,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
flyToWorldTarget(bindFakeCesiumCamera({ camera }), { kind: 'vessel' }),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
flyToWorldTarget(null, { kind: 'vessel', position: POSITION }),
|
||||
false,
|
||||
);
|
||||
assert.equal(camera.calls.flights.length, 0);
|
||||
});
|
||||
Reference in new issue
Block a user