Files
gods-eye-view/src/camera.js
T
Sameh Khamis 46a53bb49c Fly the camera through the renderer's camera port
The Cesium camera port moves into render/cesium/camera.js, with the
listener list and position conversion shared from common.js. It now
covers flights (flyTo, flyToBounds, cancelFlight, flying), lookAt and
release, command hooks, and a flightEnd event for the flights it starts.

A flight's end that Cesium raises inside one of the port's own calls is
delivered once Cesium's call returns, so its callback sees the flight
let go of. A flight Cesium declines to start, mid scene-mode morph,
ends as cancelled instead of never settling.

Flight traces run in Node on the recorder's headless camera with a
virtual clock; the browser harness keeps the instant traces.

The startup fly-in, landmark and viewport flights, share-link restore
and the shell's camera state now go through the port. camera.js and
sharelink.js leave the Cesium allow-list.
2026-11-05 20:15:52 -08:00

35 lines
1.0 KiB
JavaScript

import { toRadians } from './geo/index.js';
import { cameraOf } from './render/rendererOf.js';
/**
* Set camera to Austin on load with a cinematic fly-in.
* @returns {Function} Cancels the pending or active startup flight.
*/
export function flyToAustin(viewer) {
const camera = cameraOf(viewer);
// Start from a high altitude, then fly down
camera.setView({
destination: { lon: -97.7431, lat: 30.2672, height: 25000 },
orientation: { heading: 0, pitch: toRadians(-90), roll: 0 },
});
// Cinematic fly-in after a brief pause
let flight = null;
const timer = setTimeout(() => {
if (viewer.isDestroyed()) return;
flight = camera.flyTo(
{ lon: -97.7431, lat: 30.2672, height: 600 },
{
orientation: { heading: toRadians(15), pitch: toRadians(-30), roll: 0 },
durationS: 4.0,
easing: 'cubicInOut',
},
);
}, 500);
return () => {
clearTimeout(timer);
// Only the fly-in: a flight the user started since is theirs.
if (!viewer.isDestroyed()) flight?.cancel();
};
}