refactor: extract application construction and lifecycle

This commit is contained in:
Sameh Khamis committed 2026-09-11 17:02:54 -07:00
1 parent 092f28e301
commit 4d37760314
36 files changed
+1363 -382

No files matched your search

+7 -1
View File
@@ -48,6 +48,7 @@ export function flyToPreset(viewer, presetName, duration = 3.0) {
/**
* Set camera to Austin on load with a cinematic fly-in.
* @returns {Function} Cancels the pending or active startup flight.
*/
export function flyToAustin(viewer) {
// Start from a high altitude, then fly down
@@ -61,7 +62,8 @@ export function flyToAustin(viewer) {
});
// Cinematic fly-in after a brief pause
setTimeout(() => {
const timer = setTimeout(() => {
if (viewer.isDestroyed()) return;
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(-97.7431, 30.2672, 600),
orientation: {
@@ -73,4 +75,8 @@ export function flyToAustin(viewer) {
easingFunction: Cesium.EasingFunction.CUBIC_IN_OUT,
});
}, 500);
return () => {
clearTimeout(timer);
if (!viewer.isDestroyed()) viewer.camera.cancelFlight();
};
}