mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
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.
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
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',
|
||
);
|
||
});
|