Follow through the camera port in the remaining tests

- The tests that faked a follow by setting the viewer's tracked entity,
  or by raising its change event, follow through the camera port
  (followEntity, or a port with follow and followChanged), and check
  followedOf: camera handoffs, globe rotation, tilt, ground guard,
  vessels, ALPR, CCTV, Contacts, radio, orientation, share links and
  follow offsets, the tracked readout and the shell's camera listeners.
- The fake Cesium camera port delivers followChanged from the port itself.
- A ride handed to another aircraft is adopted by the follow's change, as
  the application does, not by the test calling the adoption.
- The unbound-factory record lists the scene, the map defaults, share
  restoration and the World Packet as entries whose caller loads the
  factories; the map startup test stubs the default renderer load.
This commit is contained in:
Sameh Khamis committed 2026-11-10 18:10:14 -08:00
1 parent 9a13aeab48
commit 1fbe546531
21 files changed
+476 -148

No files matched your search

+31 -6
View File
@@ -7,9 +7,9 @@ import * as Cesium from 'cesium';
import { applyShareFollowOffset, placeFollowEye } from './shareFollow.js';
import { followOffsetToEnu } from '../share/viewCodec.js';
import { withEntityRecord } from '../data/entityRecords.js';
import { followedOf } from '../data/followed.js';
import { entityFollowTarget, followedOf } from '../data/followed.js';
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
import { findCamera } from '../render/rendererOf.js';
import { findCamera, rendererOf } from '../render/rendererOf.js';
function realCamera() {
const scene = {
@@ -58,10 +58,6 @@ function following(start = START) {
camera,
scene,
clock: { currentTime: Cesium.JulianDate.now() },
trackedEntity: withEntityRecord(
{},
{ trackedId: 'satellites:25544', displayPosition: () => TARGET },
),
};
bindFakeCesiumCamera(viewer, {
frame: {
@@ -69,6 +65,35 @@ function following(start = START) {
phase === 'preUpdate' ? scene.preUpdate.addEventListener(cb) : () => {},
},
});
// The port follows the satellite, already framed in its orbit frame; its
// follow offset is the eye in that frame, as the Cesium follow's is.
const renderer = rendererOf(viewer);
const port = renderer.camera;
const followed = entityFollowTarget(
withEntityRecord(
{},
{ trackedId: 'satellites:25544', displayPosition: () => TARGET },
),
{ position: () => TARGET, frame: 'autodetect' },
);
renderer.camera = Object.create(port, {
followed: { get: () => followed },
followFramed: { get: () => true },
followOffset: {
value: Object.freeze({
get() {
const p = camera.position;
return { x: p.x, y: p.y, z: p.z };
},
set(offset) {
camera.lookAtTransform(
camera.transform,
new Cesium.Cartesian3(offset.x, offset.y, offset.z),
);
},
}),
},
});
return viewer;
}