Files
gods-eye-view/src/layers/flights/controller.test.mjs
T
Sameh Khamis ed6e21b6f3 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.
2026-11-07 02:36:39 -08:00

39 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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',
);
});