Move Cockpit onto the camera and frame ports

Cockpit now places its eye with the geo maths and moves the camera
through the camera port on the frame port's preUpdate, so cockpitCamera.js
and cockpitController.js no longer load Cesium and leave the allow-list.
Whether the aircraft still draws comes from a trackedEntityDrawn service,
which the application shell answers from the viewer's entities. The mesh
floor probe accepts the viewer as well as its scene.
This commit is contained in:
Sameh Khamis committed 2026-11-07 16:12:43 -08:00
1 parent b47aa5f3de
commit 2a9a2d5be8
11 files changed
+433 -159

No files matched your search

+6 -15
View File
@@ -1,5 +1,6 @@
/** Coordinate Cockpit lifecycle through supplied aircraft, terrain, rendering and briefing operations. */
import { onFollowChanged } from '../data/followed.js';
import { frameOf } from '../render/rendererOf.js';
import {
readAircraftInfo,
dispatchCockpitModeChanged,
@@ -62,7 +63,6 @@ import {
syncSignalLayout,
} from './cockpitLayout.js';
import { onKeyDown } from './cockpitInput.js';
import * as Cesium from 'cesium';
export class CockpitViewController {
constructor(
@@ -80,6 +80,8 @@ export class CockpitViewController {
publish = {},
} = {},
) {
// Before anything subscribes: a viewer with no frame port throws here.
const frame = frameOf(viewer);
this.viewer = viewer;
this.services = services;
this.destroyed = false;
@@ -183,27 +185,16 @@ export class CockpitViewController {
this.regionalBriefSubjectId = null;
this.contextLayoutFrame = null;
this.contextLayoutStamp = null;
this.scratchTarget = new Cesium.Cartesian3();
this.cockpitAnchor = new Cesium.Cartesian3();
/** Where the Cockpit eye is carried from, as ECEF; see cockpitCamera.js. */
this.cockpitAnchor = null;
this.cockpitAnchorValid = false;
this.scratchCamera = new Cesium.Cartesian3();
this.scratchAdvance = new Cesium.Cartesian3();
this.scratchCorrection = new Cesium.Cartesian3();
this.scratchForward = new Cesium.Cartesian3();
this.scratchHorizontal = new Cesium.Cartesian3();
this.scratchUp = new Cesium.Cartesian3();
this.scratchLocal = new Cesium.Cartesian3();
this.scratchEnu = new Cesium.Matrix4();
this.scratchAnchorCartographic = new Cesium.Cartographic();
this.scratchCameraCartographic = new Cesium.Cartographic();
this.scratchTargetCartographic = new Cesium.Cartographic();
this._listenerRemovers = [onLocaleChange(() => this.relocalize())];
// Camera mutations belong before scene update/culling. Changing the camera
// from preRender makes 3D Tiles discover a new view after traversal and can
// create a self-sustaining refinement loop under a moving cockpit camera.
this._listenerRemovers.push(
viewer.scene.preUpdate.addEventListener(() => this.update()),
frame.on('preUpdate', () => this.update()),
onFollowChanged(viewer, () => {
if (this.active) this._adoptTrackedEntity(performance.now());
else this.syncEntry();