mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +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
@@ -2,6 +2,12 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- The globe opens at planet level, the whole Earth in view, on every
|
||||
renderer, instead of flying in to Austin. A shared link still flies from
|
||||
there to its view. An application can start somewhere else, a city for
|
||||
instance, with the `startView` option of `createApplicationControls`
|
||||
(longitude, latitude and height, and heading and pitch in degrees)
|
||||
(samehkhamis).
|
||||
- An application's own tool can take the pointer as Draw does, and its click
|
||||
handlers can yield while a tool holds it, as the layers' do (`pointer` from
|
||||
`createApplicationTools`) (samehkhamis, #1641).
|
||||
|
||||
@@ -257,10 +257,6 @@ async function main() {
|
||||
() => window.__godsEyeView?.viewer && window.__godsEyeView?.styleManager,
|
||||
{ timeout: 60_000, polling: 100 },
|
||||
);
|
||||
// flyToAustin arrives ~500 ms after init; let it start and land before any
|
||||
// scene sets its own pose, or the arrival overwrites the first camera.
|
||||
await new Promise((resolve) => setTimeout(resolve, 2500));
|
||||
|
||||
const selected = SCENE_FILTER.length
|
||||
? SCENES.filter((scene) => SCENE_FILTER.some((prefix) => scene.id.startsWith(prefix)))
|
||||
: SCENES;
|
||||
|
||||
@@ -267,12 +267,6 @@ async function main() {
|
||||
{ timeout: 60000, polling: 100 },
|
||||
);
|
||||
|
||||
// flyToAustin schedules its 600 m arrival 500 ms after initialization.
|
||||
// Let that callback start, then cancel it before establishing the global
|
||||
// measurement camera so startup motion cannot invalidate the sample.
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
await page.evaluate(() => window.__godsEyeView.viewer.camera.cancelFlight());
|
||||
|
||||
const stateChecks = await page.evaluate((storageKey) => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
const restored = manager.getDetectionState();
|
||||
|
||||
Vendored
+10
-9
@@ -1,6 +1,6 @@
|
||||
import { catalogControlServices } from './catalog.js';
|
||||
import { StyleManager } from '../ui/composition.js';
|
||||
import { flyToAustin } from '../camera.js';
|
||||
import { applyStartView, START_VIEW } from '../camera.js';
|
||||
import { initCockpitCloudEffects } from '../cockpitCloudEffects.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
|
||||
@@ -8,7 +8,9 @@ import { t } from '../i18n/index.js';
|
||||
* Construct the existing controls and camera presentation. `initialShareCode`
|
||||
* opens a share code (the `<code>` of `/share/<code>`) at start-up, for a host
|
||||
* whose address does not carry one. `localePicker: false` removes the language
|
||||
* picker, for a page that does not initialize the app's locale.
|
||||
* picker, for a page that does not initialize the app's locale. `startView` is
|
||||
* where the camera starts (the whole planet by default; a host may pass a
|
||||
* city); a shared view flies from there.
|
||||
*/
|
||||
export function createApplicationControls({
|
||||
scene: { viewer, mapStackController, operations, viewerDrawsEntity },
|
||||
@@ -20,7 +22,10 @@ export function createApplicationControls({
|
||||
defer,
|
||||
initialShareCode = null,
|
||||
localePicker = true,
|
||||
startView = START_VIEW,
|
||||
}) {
|
||||
// Every boot starts from the same view, before share restoration flies on.
|
||||
applyStartView(viewer, startView);
|
||||
// Initialize the style manager (post-processing, HUD, locations, share links)
|
||||
const styleManager = new Controls(viewer, {
|
||||
services: {
|
||||
@@ -52,13 +57,9 @@ export function createApplicationControls({
|
||||
});
|
||||
defer(() => cockpitCloudEffects?.destroy());
|
||||
|
||||
// If no share link state, do default fly-to Austin
|
||||
if (!styleManager.hasShareState) {
|
||||
loaderStatus.textContent = t('Flying to Austin, TX...');
|
||||
defer(flyToAustin(viewer));
|
||||
} else {
|
||||
loaderStatus.textContent = t('Restoring shared view...');
|
||||
}
|
||||
loaderStatus.textContent = styleManager.hasShareState
|
||||
? t('Restoring shared view...')
|
||||
: t('Loading');
|
||||
|
||||
return { styleManager, weatherEffects, cockpitCloudEffects };
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import test, { after, before } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import '../testSupport/stubMgrs.mjs';
|
||||
import { installVueDom } from '../testSupport/vueDom.mjs';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const { createApplicationControls } = await import('./controls.js');
|
||||
|
||||
@@ -21,7 +22,10 @@ test('the application controls start and stop', () => {
|
||||
const cleanups = [];
|
||||
createApplicationControls({
|
||||
scene: {
|
||||
viewer: {},
|
||||
viewer: bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: { setView() {} },
|
||||
}),
|
||||
mapStackController: {},
|
||||
operations: {
|
||||
surface: { controlServices: {} },
|
||||
|
||||
@@ -1,68 +1,41 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { flyToAustin } from '../camera.js';
|
||||
import { applyStartView, START_VIEW } from '../camera.js';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
test('teardown before the initial camera delay prevents a late flight', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
let flights = 0;
|
||||
let cancelled = 0;
|
||||
const stop = flyToAustin(
|
||||
bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
setView() {},
|
||||
flyTo() {
|
||||
flights++;
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled++;
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
stop();
|
||||
t.mock.timers.tick(1000);
|
||||
assert.equal(flights, 0);
|
||||
assert.equal(cancelled, 0, 'no fly-in started, so none to cancel');
|
||||
});
|
||||
|
||||
test('teardown cancels the fly-in, not a flight the user started since', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const cancelled = [];
|
||||
let current = null;
|
||||
const viewer = bindFakeCesiumCamera({
|
||||
function viewerRecording(views) {
|
||||
return bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
get _currentFlight() {
|
||||
return current;
|
||||
setView(view) {
|
||||
views.push(view);
|
||||
},
|
||||
setView() {},
|
||||
flyTo(options) {
|
||||
current?.cancel();
|
||||
current = {
|
||||
name: options.duration === 4 ? 'fly-in' : 'user',
|
||||
...options,
|
||||
};
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled.push(current?.name);
|
||||
const flight = current;
|
||||
current = null;
|
||||
flight?.cancel();
|
||||
flyTo() {
|
||||
assert.fail('a start view is set, not flown to');
|
||||
},
|
||||
},
|
||||
});
|
||||
const stop = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
stop();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
}
|
||||
|
||||
// A user flight replaces the fly-in; teardown leaves it alone.
|
||||
const second = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
viewer.camera.flyTo({ duration: 2 });
|
||||
second();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
assert.equal(current.name, 'user');
|
||||
test('the camera starts over the whole planet, looking straight down', () => {
|
||||
const views = [];
|
||||
applyStartView(viewerRecording(views));
|
||||
assert.equal(views.length, 1);
|
||||
assert.ok(START_VIEW.height >= 20000000, 'the whole planet is in view');
|
||||
assert.ok(Math.abs(views[0].orientation.pitch + Math.PI / 2) < 1e-9);
|
||||
assert.equal(views[0].orientation.heading, 0);
|
||||
});
|
||||
|
||||
test('a host can start the camera at a city instead', () => {
|
||||
const views = [];
|
||||
applyStartView(viewerRecording(views), {
|
||||
lon: 2.35,
|
||||
lat: 48.86,
|
||||
height: 5000,
|
||||
heading: 90,
|
||||
pitch: -30,
|
||||
});
|
||||
assert.equal(views.length, 1);
|
||||
assert.ok(Math.abs(views[0].orientation.heading - Math.PI / 2) < 1e-9);
|
||||
assert.ok(Math.abs(views[0].orientation.pitch + Math.PI / 6) < 1e-9);
|
||||
});
|
||||
+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,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -102,7 +102,6 @@
|
||||
"Initializing photorealistic world...": "جارٍ تهيئة العالم الواقعي…",
|
||||
"Configuring viewer...": "جارٍ إعداد العارض…",
|
||||
"Google 3D Tiles unavailable ({detail}). Loading the keyless globe...": "بلاطات Google 3D Tiles غير متاحة ({detail}). جارٍ تحميل الكرة الأرضية بلا مفتاح…",
|
||||
"Flying to Austin, TX...": "جارٍ الانتقال إلى أوستن، تكساس…",
|
||||
"Restoring shared view...": "جارٍ استعادة العرض المشترك…",
|
||||
"LOADING LIVE DATA": "جارٍ تحميل البيانات المباشرة",
|
||||
"LOAD COMPLETE": "اكتمل التحميل",
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
"Side labels describe the source, not whether a report is true.": "Seitenangaben beschreiben die Quelle, nicht ob eine Meldung stimmt.",
|
||||
"Exit cockpit to fly to a news report": "Cockpit verlassen, um zu einer Meldung zu fliegen",
|
||||
"News items in the feed": "Meldungen im Feed",
|
||||
"Flying to Austin, TX...": "Flug nach Austin, TX...",
|
||||
"Restoring shared view...": "Geteilte Ansicht wird wiederhergestellt...",
|
||||
"Configuring viewer...": "Viewer wird konfiguriert...",
|
||||
"Loading Google 3D Tiles...": "Google 3D Tiles werden geladen...",
|
||||
|
||||
@@ -93,7 +93,6 @@
|
||||
"Initializing photorealistic world...": "Inicializando el mundo fotorrealista...",
|
||||
"Configuring viewer...": "Configurando el visor...",
|
||||
"Google 3D Tiles unavailable ({detail}). Loading the keyless globe...": "Google 3D Tiles no disponibles ({detail}). Cargando el globo sin clave...",
|
||||
"Flying to Austin, TX...": "Volando a Austin, TX...",
|
||||
"Restoring shared view...": "Restaurando la vista compartida...",
|
||||
"LOADING LIVE DATA": "CARGANDO DATOS EN VIVO",
|
||||
"LOAD COMPLETE": "CARGA COMPLETA",
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
"Board cleared.": "Tableau effacé.",
|
||||
"{owner} is using the pointer — close it first.": "Pointeur utilisé par : {owner}. Fermez d'abord cet outil.",
|
||||
"{label} · Detailed outline unavailable": "{label} · Contour détaillé indisponible",
|
||||
"Flying to Austin, TX...": "En route vers Austin, Texas…",
|
||||
"Restoring shared view...": "Restauration de la vue partagée…",
|
||||
"Configuring viewer...": "Configuration de la vue…",
|
||||
"Loading Google 3D Tiles...": "Chargement de Google 3D Tiles…",
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
"Board cleared.": "הלוח נוקה.",
|
||||
"{owner} is using the pointer — close it first.": "{owner} משתמש במצביע — סגור אותו תחילה.",
|
||||
"{label} · Detailed outline unavailable": "{label} · קו המתאר המפורט אינו זמין",
|
||||
"Flying to Austin, TX...": "טס אל Austin, TX...",
|
||||
"Restoring shared view...": "משחזר תצוגה משותפת...",
|
||||
"Configuring viewer...": "מגדיר צפייה...",
|
||||
"Loading Google 3D Tiles...": "טוען Google 3D Tiles...",
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
"Board cleared.": "Lavagna cancellata.",
|
||||
"{owner} is using the pointer — close it first.": "Lo strumento {owner} sta usando il puntatore: chiudilo prima.",
|
||||
"{label} · Detailed outline unavailable": "{label} · Contorno dettagliato non disponibile",
|
||||
"Flying to Austin, TX...": "Volo verso Austin, TX...",
|
||||
"Restoring shared view...": "Ripristino della vista condivisa...",
|
||||
"Configuring viewer...": "Configurazione del visualizzatore...",
|
||||
"Loading Google 3D Tiles...": "Caricamento di Google 3D Tiles...",
|
||||
|
||||
@@ -100,7 +100,6 @@
|
||||
"Board cleared.": "ボードを消去しました。",
|
||||
"{owner} is using the pointer — close it first.": "{owner}がポインターを使用中です。先に閉じてください。",
|
||||
"{label} · Detailed outline unavailable": "{label} · 詳細な輪郭を取得できません",
|
||||
"Flying to Austin, TX...": "テキサス州オースティンへ移動中…",
|
||||
"Restoring shared view...": "共有ビューを復元中…",
|
||||
"Configuring viewer...": "ビューアーを設定中…",
|
||||
"Loading Google 3D Tiles...": "Google 3D Tilesを読み込み中…",
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
"Board cleared.": "Quadro limpo.",
|
||||
"{owner} is using the pointer — close it first.": "A ferramenta \"{owner}\" está usando o ponteiro — feche-a primeiro.",
|
||||
"{label} · Detailed outline unavailable": "{label} · Contorno detalhado indisponível",
|
||||
"Flying to Austin, TX...": "Voando para Austin, TX...",
|
||||
"Restoring shared view...": "Restaurando a vista compartilhada...",
|
||||
"Configuring viewer...": "Configurando o visualizador...",
|
||||
"Loading Google 3D Tiles...": "Carregando Google 3D Tiles...",
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
"Side labels describe the source, not whether a report is true.": "Метки сторон описывают источник, а не достоверность сообщения.",
|
||||
"Exit cockpit to fly to a news report": "Выйдите из кабины, чтобы перелететь к сообщению",
|
||||
"News items in the feed": "Новостей в ленте",
|
||||
"Flying to Austin, TX...": "Перелёт в Остин, Техас...",
|
||||
"Restoring shared view...": "Восстановление общего вида...",
|
||||
"Initializing systems...": "Инициализация систем...",
|
||||
"Configuring viewer...": "Настройка просмотрщика...",
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
"Larger: more sources · fainter: older. Picture card: a major or fast-growing event with two or more sources.": "Större: fler källor · blekare: äldre. Bildkort: en allvarlig eller snabbt växande händelse med två eller fler källor.",
|
||||
"Side labels describe the source, not whether a report is true.": "Etiketter för sidtillhörighet beskriver källan, inte om en rapport är sann.",
|
||||
"News items in the feed": "Nyheter i flödet",
|
||||
"Flying to Austin, TX...": "Flyger till Austin, TX …",
|
||||
"Restoring shared view...": "Återställer delad vy …",
|
||||
"Configuring viewer...": "Konfigurerar vyn …",
|
||||
"Loading Google 3D Tiles...": "Laddar Google 3D Tiles …",
|
||||
|
||||
@@ -112,7 +112,6 @@
|
||||
"Board cleared.": "Дошку очищено.",
|
||||
"{owner} is using the pointer — close it first.": "Вказівник зайнятий: «{owner}». Спершу закрийте його.",
|
||||
"{label} · Detailed outline unavailable": "{label} · Докладний контур недоступний",
|
||||
"Flying to Austin, TX...": "Переліт до Остіна, Техас...",
|
||||
"Restoring shared view...": "Відновлення спільного вигляду...",
|
||||
"Configuring viewer...": "Налаштування переглядача...",
|
||||
"Loading Google 3D Tiles...": "Завантаження Google 3D Tiles...",
|
||||
|
||||
@@ -100,7 +100,6 @@
|
||||
"Board cleared.": "画板已清除。",
|
||||
"{owner} is using the pointer — close it first.": "{owner} 正在使用指针——请先关闭它。",
|
||||
"{label} · Detailed outline unavailable": "{label} · 无法获取详细轮廓",
|
||||
"Flying to Austin, TX...": "正在飞往德克萨斯州奥斯汀…",
|
||||
"Restoring shared view...": "正在恢复分享视图…",
|
||||
"Configuring viewer...": "正在配置视图…",
|
||||
"Loading Google 3D Tiles...": "正在加载 Google 3D Tiles…",
|
||||
|
||||
@@ -100,7 +100,6 @@
|
||||
"Board cleared.": "畫板已清除。",
|
||||
"{owner} is using the pointer — close it first.": "{owner} 正在使用指針——請先關閉它。",
|
||||
"{label} · Detailed outline unavailable": "{label} · 無法獲取詳細輪廓",
|
||||
"Flying to Austin, TX...": "正在飛往德克薩斯州奧斯汀…",
|
||||
"Restoring shared view...": "正在恢復分享視圖…",
|
||||
"Configuring viewer...": "正在配置視圖…",
|
||||
"Loading Google 3D Tiles...": "正在加載 Google 3D Tiles…",
|
||||
|
||||
Reference in new issue
Block a user