From 6ee3bb2f7d766e2cafaf1b657399d6f6463fbced Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 7 Nov 2026 02:59:01 -0800 Subject: [PATCH] Read and restore the shell's camera state through the camera port The shell's camera snapshot now comes from the camera port's pose and its restore converts with the geo helpers. The shell stays on the allow-list: it still loads the Cesium camera and effects factories for the entries that reach it. --- src/ui/applicationShell.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/ui/applicationShell.js b/src/ui/applicationShell.js index d69926fed..b728f9e0e 100644 --- a/src/ui/applicationShell.js +++ b/src/ui/applicationShell.js @@ -30,10 +30,11 @@ import { setCyberSonarControls, } from './cyberSonarControls.js'; -import * as Cesium from 'cesium'; -import { cameraOf } from '../render/cesium/camera.js'; +import { toDegrees, toRadians } from '../geo/index.js'; +import { cameraOf, findCamera } from '../render/cesium/camera.js'; // Loads the effects factory, so visual settings on a viewer with no renderer -// bound still get an effects port. +// bound still get an effects port. Loading the camera and effects factories +// is all that keeps this module on the Cesium allow-list. import '../render/cesium/effects.js'; import { aircraftTrackingTarget } from '../cockpitTracking.js'; @@ -90,7 +91,7 @@ import { useRecordingStore } from './stores/recording.js'; export class StyleManager extends ShellFacade { /** - * @param {Cesium.Viewer} viewer - The CesiumJS viewer instance. + * @param {object} viewer - The scene object the renderer draws. * @param {object} [options] * @param {boolean} [options.localePicker=true] - false removes the language * picker, for a host that does not initialize Core's locale. @@ -1437,15 +1438,16 @@ export class StyleManager extends ShellFacade { * @returns {{lat: number, lon: number, alt: number, heading: number, pitch: number, roll: number}|null} */ getCameraState() { - const carto = this.viewer.camera.positionCartographic; - if (!carto) return null; + const pose = findCamera(this.viewer)?.pose(); + if (!pose || !Number.isFinite(pose.lat) || !Number.isFinite(pose.lon)) + return null; return { - lat: Cesium.Math.toDegrees(carto.latitude), - lon: Cesium.Math.toDegrees(carto.longitude), - alt: carto.height, - heading: Cesium.Math.toDegrees(this.viewer.camera.heading), - pitch: Cesium.Math.toDegrees(this.viewer.camera.pitch), - roll: Cesium.Math.toDegrees(this.viewer.camera.roll), + lat: pose.lat, + lon: pose.lon, + alt: pose.height, + heading: toDegrees(pose.heading), + pitch: toDegrees(pose.pitch), + roll: toDegrees(pose.roll), }; } @@ -1461,9 +1463,9 @@ export class StyleManager extends ShellFacade { { lon: cameraState.lon, lat: cameraState.lat, height: cameraState.alt }, { orientation: { - heading: Cesium.Math.toRadians(cameraState.heading || 0), - pitch: Cesium.Math.toRadians(cameraState.pitch || -35), - roll: Cesium.Math.toRadians(cameraState.roll || 0), + heading: toRadians(cameraState.heading || 0), + pitch: toRadians(cameraState.pitch || -35), + roll: toRadians(cameraState.roll || 0), }, durationS: Math.max(0.2, duration || 0), easing: 'cubicInOut',