mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
1c8cf240c4
commit
ed6e21b6f3
4 files changed
+45
-8
No files matched your search
@@ -745,6 +745,7 @@
|
||||
"src/layers/flights/snapshotRenderer.js",
|
||||
"src/layers/flights/records.test.mjs",
|
||||
"src/layers/flights/ingestion.test.mjs",
|
||||
"src/layers/flights/controller.test.mjs",
|
||||
"src/layers/military/records.js",
|
||||
"src/layers/military/recordPolicy.js",
|
||||
"src/layers/military/snapshotRenderer.js",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { findCamera } from '../../render/rendererOf.js';
|
||||
|
||||
export function createController({
|
||||
flightState,
|
||||
@@ -13,13 +13,12 @@ export function createController({
|
||||
flightState.feed._activeUpdateControllers.clear();
|
||||
}
|
||||
|
||||
/** The feed query around the camera's ground point, or {} with none. */
|
||||
function _flightQuery(viewer) {
|
||||
const cartographic = viewer?.camera?.positionCartographic;
|
||||
return cartographic
|
||||
? {
|
||||
latitude: Cesium.Math.toDegrees(cartographic.latitude),
|
||||
longitude: Cesium.Math.toDegrees(cartographic.longitude),
|
||||
}
|
||||
const pose = viewer ? findCamera(viewer)?.pose() : null;
|
||||
// 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: pose.lat, longitude: pose.lon }
|
||||
: {};
|
||||
}
|
||||
return { _abortActiveUpdates, _flightQuery };
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
});
|
||||
@@ -42,7 +42,6 @@
|
||||
"src/layers/cctv/rendering.js",
|
||||
"src/layers/directions/index.js",
|
||||
"src/layers/firms/rendering.js",
|
||||
"src/layers/flights/controller.js",
|
||||
"src/layers/flights/enrichment.js",
|
||||
"src/layers/flights/evidence.js",
|
||||
"src/layers/flights/icons.js",
|
||||
|
||||
Reference in new issue
Block a user