Load the default renderer as the page starts, and follow through the camera port in tests

- The standalone page starts loading the default renderer as it starts
  (loadDefaultRenderer), so Cesium arrives beside the page's own setup,
  not after it; the scene takes a plugin or a promise of one.
- Where a follow target's layer has no display position yet, the followed
  position is the target's own position at the frame port's scene time.
- The globe engine's photoreal base that fails to come back is off again
  and the globe shown; a later switch tries again. The draped-imagery host
  asks the map engine whether the globe is shown where the renderer cannot
  say. The scene resizes the renderer with its container.
- Cockpit and voice tests follow through the camera port (followEntity),
  not by setting the viewer's tracked entity; the fake frame port has a
  scene time.
This commit is contained in:
Sameh Khamis committed 2026-11-10 17:44:29 -08:00
1 parent 6daf63d90c
commit ae4fbb5053
21 files changed
+328 -87

No files matched your search

+18 -11
View File
@@ -4,6 +4,7 @@ import { CockpitViewController } from './cockpitController.js';
import { withEntityRecord } from '../data/entityRecords.js';
import { fakeInput } from '../input/testDoubles.mjs';
import { bindRenderer } from '../render/rendererOf.js';
import { entityFollowTarget, followedOf } from '../data/followed.js';
import {
cockpitAnchorCorrectionStep,
cockpitGroundSafeHeight,
@@ -37,18 +38,30 @@ function environment() {
preUpdate: event,
screenSpaceCameraController: { enableInputs: true },
},
trackedEntityChanged: event,
entities: { contains: () => false },
};
// What the camera follows, as a layer's follow sets it.
const camera = {
followed: null,
follow(target) {
camera.followed = target;
},
on: (name, fn) =>
name === 'followChanged' ? event.addEventListener(fn) : () => {},
};
// The renderer's frame port: Cockpit moves the camera on its preUpdate.
bindRenderer(viewer, {
camera,
frame: {
on: (phase, fn) =>
phase === 'preUpdate' ? event.addEventListener(fn) : () => {},
},
});
/** Follow a holder of an entity record, as a layer's follow does. */
const follow = (holder) =>
camera.follow(holder ? entityFollowTarget(holder, {}) : null);
return {
viewer,
follow,
callbacks,
restore() {
Object.assign(globalThis, original);
@@ -96,7 +109,7 @@ test('disposing an active Cockpit releases the supplied render owner without ret
env.viewer.scene.screenSpaceCameraController.enableInputs,
true,
);
assert.equal(env.viewer.trackedEntity, undefined);
assert.equal(followedOf(env.viewer), null);
assert.equal(owner.active, false);
} finally {
env.restore();
@@ -122,15 +135,9 @@ test('aircraft identity is read from the supplied layer instances', () => {
militaryFlightsLayer: { getTrackedInfo: () => military },
},
});
env.viewer.trackedEntity = withEntityRecord(
{},
{ trackedId: 'military:def456' },
);
env.follow(withEntityRecord({}, { trackedId: 'military:def456' }));
assert.deepEqual(owner.readAircraftInfo(), military);
env.viewer.trackedEntity = withEntityRecord(
{},
{ trackedId: 'flights:abc123' },
);
env.follow(withEntityRecord({}, { trackedId: 'flights:abc123' }));
assert.deepEqual(owner.readAircraftInfo(), civilian);
owner.dispose();
} finally {