mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(app): the globe opens at planet level
The camera starts with the whole Earth in view, looking straight down, instead of flying in to Austin. A shared link flies on from there. A different start, a city for instance, is set with the startView option of createApplicationControls. The Cesium renderer and the test stub now start from the same pose, so state that carries over from the first frames (screen clusters, marker selection, label placement) no longer depends on which of them drew it.
This commit is contained in:
1 parent
e9085e8df3
commit
639e92b4f7
20 files changed
+72
-116
No files matched your search
+22
-27
@@ -2,33 +2,28 @@ 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.
|
||||
* The view the renderer starts from: the whole planet, looking straight
|
||||
* down, centred where Cesium's default view rectangle is.
|
||||
*/
|
||||
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 },
|
||||
});
|
||||
export const START_VIEW = Object.freeze({
|
||||
lon: -82.5,
|
||||
lat: 35,
|
||||
height: 23000000,
|
||||
});
|
||||
|
||||
// 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();
|
||||
};
|
||||
/**
|
||||
* Put the camera at a start view without a flight. A host may pass a city
|
||||
* (`{ lon, lat, height, heading?, pitch? }`, angles in degrees) instead of
|
||||
* the planet.
|
||||
*/
|
||||
export function applyStartView(viewer, view = START_VIEW) {
|
||||
const { lon, lat, height, heading = 0, pitch = -90 } = view;
|
||||
cameraOf(viewer).setView({
|
||||
destination: { lon, lat, height },
|
||||
orientation: {
|
||||
heading: toRadians(heading),
|
||||
pitch: toRadians(pitch),
|
||||
roll: 0,
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user