Ask the flight feed around the camera port's ground point, and take the flights controller off the Cesium list

The flights controller reads the camera's longitude and latitude from the
renderer's camera port instead of the Cesium camera, and asks for no area
when the pose has no ground point or the viewer is gone. It no longer
imports Cesium or reads the viewer's camera, so it leaves the allow-list.
The flights entry already loads the Cesium camera factory for viewers with
no renderer bound.
This commit is contained in:
Sameh Khamis committed 2026-11-07 02:36:39 -08:00
1 parent 1c8cf240c4
commit ed6e21b6f3
4 files changed
+45 -8

No files matched your search

+1
View File
@@ -745,6 +745,7 @@
"src/layers/flights/snapshotRenderer.js", "src/layers/flights/snapshotRenderer.js",
"src/layers/flights/records.test.mjs", "src/layers/flights/records.test.mjs",
"src/layers/flights/ingestion.test.mjs", "src/layers/flights/ingestion.test.mjs",
"src/layers/flights/controller.test.mjs",
"src/layers/military/records.js", "src/layers/military/records.js",
"src/layers/military/recordPolicy.js", "src/layers/military/recordPolicy.js",
"src/layers/military/snapshotRenderer.js", "src/layers/military/snapshotRenderer.js",
+6 -7
View File
@@ -1,4 +1,4 @@
import * as Cesium from 'cesium'; import { findCamera } from '../../render/rendererOf.js';
export function createController({ export function createController({
flightState, flightState,
@@ -13,13 +13,12 @@ export function createController({
flightState.feed._activeUpdateControllers.clear(); flightState.feed._activeUpdateControllers.clear();
} }
/** The feed query around the camera's ground point, or {} with none. */
function _flightQuery(viewer) { function _flightQuery(viewer) {
const cartographic = viewer?.camera?.positionCartographic; const pose = viewer ? findCamera(viewer)?.pose() : null;
return cartographic // An eye at the earth's centre has no ground point: the pose gives NaN.
? { return pose && Number.isFinite(pose.lat) && Number.isFinite(pose.lon)
latitude: Cesium.Math.toDegrees(cartographic.latitude), ? { latitude: pose.lat, longitude: pose.lon }
longitude: Cesium.Math.toDegrees(cartographic.longitude),
}
: {}; : {};
} }
return { _abortActiveUpdates, _flightQuery }; return { _abortActiveUpdates, _flightQuery };
+38
View File
@@ -0,0 +1,38 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { bindRenderer } from '../../render/rendererOf.js';
import { createController } from './controller.js';
const controller = () =>
createController({ flightState: { feed: {} }, parts: {}, layer: {} });
test('the feed is asked for the flights around the camera port’s ground point', () => {
let pose = { lon: -97.04, lat: 32.9, height: 9000 };
const viewer = {};
const unbind = bindRenderer(viewer, { camera: { pose: () => pose } });
try {
const { _flightQuery } = controller();
assert.deepEqual(_flightQuery(viewer), {
latitude: 32.9,
longitude: -97.04,
});
pose = { lon: NaN, lat: NaN, height: NaN };
assert.deepEqual(_flightQuery(viewer), {}, 'no ground point: no area');
pose = { lon: -97.04, lat: NaN, height: 9000 };
assert.deepEqual(_flightQuery(viewer), {}, 'half a ground point: none');
} finally {
unbind();
}
});
test('with no viewer or camera the query names no area', () => {
const { _flightQuery } = controller();
assert.deepEqual(_flightQuery(null), {});
assert.deepEqual(_flightQuery(undefined), {});
assert.deepEqual(_flightQuery({}), {}, 'a viewer with no camera');
assert.deepEqual(
_flightQuery({ isDestroyed: () => true, camera: {} }),
{},
'a destroyed viewer',
);
});
-1
View File
@@ -42,7 +42,6 @@
"src/layers/cctv/rendering.js", "src/layers/cctv/rendering.js",
"src/layers/directions/index.js", "src/layers/directions/index.js",
"src/layers/firms/rendering.js", "src/layers/firms/rendering.js",
"src/layers/flights/controller.js",
"src/layers/flights/enrichment.js", "src/layers/flights/enrichment.js",
"src/layers/flights/evidence.js", "src/layers/flights/evidence.js",
"src/layers/flights/icons.js", "src/layers/flights/icons.js",