Fly the remaining flights through the camera port, on any viewer

The embed view, the celestial-ring focus, the ground-guard lift, the
Bhote Koshi approach and orbit, launch selection and replay flights, and
the cockpit's view and takeover now drive the renderer's camera port.
The contract gains a sineInOut easing, pinned by a conformance trace.

A viewer with no renderer bound, such as one a caller of a public
export brings, now gets a camera port too, as it already got an input
port: cameraOf builds one over the viewer's own Cesium camera and keeps
it for the viewer's life, until a renderer is bound. The Cesium adapter
provides the factory as it loads; code that reaches Cesium takes cameraOf
from the adapter so the factory comes with it, and findCamera answers
null where a missing camera is not an error (HUD, share link, world
focus, Recent Imagery's ZOOM IN). A test walks every package export and
fails one that can reach the bridge without loading the factory.

A destroyed viewer gets no camera and lets go of a built one, and the
application renderer stays bound until its viewer is destroyed.
This commit is contained in:
Sameh Khamis committed 2026-11-06 08:21:57 -08:00
1 parent c5b716b107
commit 1d4e4ebe90
44 files changed
+1167 -344

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ import {
import { entityRecord, readEntityRecord } from '../../data/entityRecords.js';
import { alprMarkers } from './markerState.js';
import { heightsFor } from '../../queries/heights.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createAlprPresentation({ state, services, source }) {
const { governorRequestRender } = services.render;
+1 -1
View File
@@ -1,6 +1,6 @@
import * as Cesium from 'cesium';
import { VESSEL_FOCUS_RADIUS_M } from './policy.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createFocus({ state: layerState, services, parts, source }) {
const flightsLayer = services.flights;
+1 -1
View File
@@ -1,6 +1,6 @@
import * as Cesium from 'cesium';
import { CCTV_FOCUS_RESULT } from './policy.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createNavigation({
state: layerState,
+1 -1
View File
@@ -23,7 +23,7 @@ import {
translateKnown,
} from '../../i18n/index.js';
import { formatQuantity } from '../../ui/unitLabels.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
// "10-12 15:00 UTC" never breaks across lines: no-break spaces, and a word
// joiner after the hyphen (JetBrains Mono has no U+2011 non-breaking hyphen).
+1 -1
View File
@@ -6,7 +6,7 @@ import {
ANCHOR_REFRESH_M,
} from './policy.js';
import { formatNumber, t, tn } from '../../i18n/index.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
// installationFeedback.js is shared with the HUD (src/loadingFeedback.js) and
// hands back msg()-marked English plus values; getStats translates them here.
+1 -1
View File
@@ -1,6 +1,6 @@
import * as Cesium from 'cesium';
import { t } from '../../i18n/index.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
import {
SATELLITE_STANDALONE_DEFAULTS,
LAUNCH_PAD_ZONE_MAX_CAMERA_HEIGHT_M,
+13 -12
View File
@@ -1,5 +1,6 @@
import * as Cesium from 'cesium';
import { t } from '../../i18n/index.js';
import { cameraOf } from '../../render/cesium/camera.js';
import {
REPLAY_ASCENT_FALLBACK_SEC,
REPLAY_ASCENT_MIN_SEC,
@@ -353,7 +354,7 @@ export function createReplay({ state: layerState, services, parts, source }) {
parts.overlays.syncMissionOverlayEntries();
parts.policyHelpers.releaseAircraftTracking(layerState._dataManager);
layerState._viewer.trackedEntity = undefined;
layerState._viewer.camera.cancelFlight();
cameraOf(layerState._viewer).cancelFlight();
layerState._animationStarts.set(
launchId,
Date.now() +
@@ -485,20 +486,20 @@ export function createReplay({ state: layerState, services, parts, source }) {
}
});
layerState._viewer.camera.flyToBoundingSphere(
new Cesium.BoundingSphere(track.ascentPath[0], 0),
cameraOf(layerState._viewer).flyToBounds(
{ center: track.ascentPath[0], radius: 0 },
{
offset: new Cesium.HeadingPitchRange(
initialHeading,
Cesium.Math.toRadians(-20),
REPLAY_INITIAL_RANGE_M,
),
duration: 1.4,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
complete: () => {
offset: {
heading: initialHeading,
pitch: Cesium.Math.toRadians(-20),
range: REPLAY_INITIAL_RANGE_M,
},
durationS: 1.4,
easing: 'cubicInOut',
onComplete: () => {
cameraReady = true;
},
cancel: () => {
onCancel: () => {
if (
token === layerState._replayCameraToken &&
layerState._replayCameraLaunchId === launchId
+26 -27
View File
@@ -1,5 +1,6 @@
import * as Cesium from 'cesium';
import { MISSION_GLOBE_VIEW_RANGE_M, MISSION_FOCUS_RANGE_M } from './policy.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createSelection({
state: layerState,
@@ -32,20 +33,23 @@ export function createSelection({
);
const distance = earthRadius / Math.max(Math.sin(angularRadius), 1e-4);
const altitude = Math.max(earthRadius * 1.55, distance - earthRadius);
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromRadians(
const camera = cameraOf(viewer);
camera.flyTo(
Cesium.Cartesian3.fromRadians(
cartographic.longitude,
cartographic.latitude,
altitude,
),
orientation: {
heading: viewer.camera.heading,
pitch: -Cesium.Math.PI_OVER_TWO,
roll: 0,
{
orientation: {
heading: camera.pose().heading,
pitch: -Cesium.Math.PI_OVER_TWO,
roll: 0,
},
durationS: duration,
easing: 'cubicInOut',
},
duration,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
});
);
}
function entityLaunchId(entity) {
@@ -187,11 +191,10 @@ export function createSelection({
Cesium.Cartesian3.cross(right, direction, new Cesium.Cartesian3()),
new Cesium.Cartesian3(),
);
layerState._viewer.camera.flyTo({
destination,
cameraOf(layerState._viewer).flyTo(destination, {
orientation: { direction, up },
duration: 1.1,
complete: () => {
durationS: 1.1,
onComplete: () => {
if (layerState._selectedLaunchId === launch.id)
startMissionZoomAnchor(launch, range);
},
@@ -202,24 +205,20 @@ export function createSelection({
if (!layerState._viewer || !launch) return;
parts.replay.stopMissionReplay();
stopMissionZoomAnchor();
const launchPosition = Cesium.Cartesian3.fromDegrees(
launch.lon,
launch.lat,
);
layerState._viewer.selectedEntity = layerState._dataSource.entities.getById(
`rocket-launch:${launch.id}`,
);
layerState._viewer.camera.flyToBoundingSphere(
new Cesium.BoundingSphere(launchPosition, 0),
cameraOf(layerState._viewer).flyToBounds(
{ center: { lon: launch.lon, lat: launch.lat }, radius: 0 },
{
offset: new Cesium.HeadingPitchRange(
0,
Cesium.Math.toRadians(-42),
MISSION_FOCUS_RANGE_M,
),
duration: 1.4,
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
complete: () => {
offset: {
heading: 0,
pitch: Cesium.Math.toRadians(-42),
range: MISSION_FOCUS_RANGE_M,
},
durationS: 1.4,
easing: 'cubicInOut',
onComplete: () => {
if (layerState._selectedLaunchId === launch.id) {
startMissionZoomAnchor(launch, MISSION_FOCUS_RANGE_M);
}
+1 -1
View File
@@ -4,7 +4,7 @@ import {
GLOBAL_RADIO_ALTITUDE_M,
RADIO_GLOBE_RECENTER_MAX_HEIGHT_M,
} from './policy.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createNavigation({
state: layerState,
+7 -5
View File
@@ -34,7 +34,7 @@ import {
} from './model.js';
import { msg, t } from '../../i18n/index.js';
import { READOUT_WORDS, displayDay, displayMetres } from './display.js';
import { cameraOf } from '../../render/rendererOf.js';
import { findCamera } from '../../render/rendererOf.js';
/**
* Quiet time after the last arrow key before the focused day previews, so a
@@ -980,15 +980,17 @@ export function createRecentImageryLayer({
const target = _boxError ? _refusalTarget : null;
const camera = _viewer?.camera;
const ellipsoid = ellipsoidOf(_viewer);
if (!target || !camera?.flyTo || !ellipsoid?.cartographicToCartesian)
return null;
// No camera port: a viewer of the caller's own whose renderer did not
// bring the camera factory (GEV's own imagery renderer does).
const port = findCamera(_viewer);
if (!target || !port || !ellipsoid?.cartographicToCartesian) return null;
const canvas = _viewer.scene?.canvas;
const height = fitViewHeightM({
width: canvas?.clientWidth,
height: canvas?.clientHeight,
fovy: camera.frustum?.fovy,
fovy: camera?.frustum?.fovy,
});
cameraOf(_viewer).flyTo(
port.flyTo(
ellipsoid.cartographicToCartesian({
longitude: toRadians(target.lon),
latitude: toRadians(target.lat),
+3
View File
@@ -8,6 +8,9 @@
*/
import * as Cesium from 'cesium';
import { withTileRequestHook } from '../../render/cesium/tileRequests.js';
// The layer is Cesium-free and flies through `cameraOf`; its Cesium renderer
// brings the factory a viewer with no renderer bound gets a camera from.
import '../../render/cesium/camera.js';
import { PRODUCTS, gibsTemplate } from './model.js';
const SLOT_IDS = ['a', 'b'];
+1 -1
View File
@@ -1,7 +1,7 @@
import * as Cesium from 'cesium';
import { plausibleSurfaceHeight, sampledSurfaceHeight } from './view.js';
import { heightsFor } from '../../queries/heights.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
/** Fly the globe camera once to frame a photo after it opens. */
export function createCameraFraming({ state }) {
+1 -1
View File
@@ -1,6 +1,6 @@
import * as Cesium from 'cesium';
import { cablePicks } from './pickState.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
export function createInteraction({ state, inputFor }) {
function registerPickEntity(entity, info) {
+1 -1
View File
@@ -10,7 +10,7 @@ import {
} from './clock.js';
import { formatUtcDayMonth, t, msg } from '../../i18n/index.js';
import { formatScaleLabel } from '../../ui/unitLabels.js';
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf } from '../../render/cesium/camera.js';
/**
* A stored (English) failure in the language. HTTP failures from source.js