mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge main and switch Cesium and Navara in place through Vue
Preserve the camera, map source and layer selection across engine sessions. Restore the previous engine if startup fails and retain local history navigation.
This commit is contained in:
commit
b8f4d097c4
1691 files changed
+225876
-41594
No files matched your search
@@ -1,19 +1,27 @@
|
||||
import { createStandaloneCatalog } from './catalog.js';
|
||||
import { createStandalonePlaceSearch } from './placeSearch.js';
|
||||
import { CITY_POIS } from '../locations.js';
|
||||
import { CITY_POIS } from '../cityPois.js';
|
||||
import { createApplication } from '../app/application.js';
|
||||
import { createStandaloneScene } from './scene.js';
|
||||
import { createStandaloneControls } from './controls.js';
|
||||
import { createStandaloneData } from './data.js';
|
||||
import { createStandaloneTools } from './tools.js';
|
||||
import { resolveLocale, applyDocumentLanguage } from '../i18n/locale.js';
|
||||
import {
|
||||
applyDocumentTranslations,
|
||||
getLocale,
|
||||
onLocaleChange,
|
||||
setLocale,
|
||||
} from '../i18n/index.js';
|
||||
import { mountApplicationViews } from '../ui/views/index.js';
|
||||
import { createGoogleTokenSource } from '../maps/googleTokens.js';
|
||||
import { resolveEngineKind } from '../app/engineChoice.js';
|
||||
|
||||
// The existing controls and layer catalog contain page-scoped state.
|
||||
let constructed = false;
|
||||
// Only one engine may own the page at a time.
|
||||
let owner = null;
|
||||
|
||||
/** The page's engine choice: ?engine=, else the stored gev.engine, else Cesium. */
|
||||
function pageEngineKind() {
|
||||
export function pageEngineKind() {
|
||||
let storage = null;
|
||||
try {
|
||||
storage = globalThis.localStorage ?? null;
|
||||
@@ -23,7 +31,7 @@ function pageEngineKind() {
|
||||
return resolveEngineKind({ search: globalThis.location?.search, storage });
|
||||
}
|
||||
|
||||
/** Compose the standalone application once per page. Reload to start again. */
|
||||
/** Compose one engine session. Destroy it before starting another. */
|
||||
export function createStandaloneApplication({
|
||||
googleApiKey,
|
||||
cesiumToken,
|
||||
@@ -34,15 +42,32 @@ export function createStandaloneApplication({
|
||||
allowQaRegistration = false,
|
||||
engineKind = pageEngineKind(),
|
||||
}) {
|
||||
if (constructed)
|
||||
if (owner)
|
||||
throw new Error('The standalone application already owns this page');
|
||||
constructed = true;
|
||||
// Locale is resolved before any UI initialization so <html lang>/<html dir>
|
||||
// and every catalog lookup agree from the first painted frame. Module
|
||||
// scripts execute after parsing, so the DOM is ready here: the views
|
||||
// translate as they render, and the page's static data-i18n* markup (the
|
||||
// loading screen) is translated here and after every language switch.
|
||||
const activeLocale = resolveLocale();
|
||||
setLocale(activeLocale);
|
||||
applyDocumentLanguage(document, activeLocale);
|
||||
// Views render the page's markup; wiring reads it.
|
||||
mountApplicationViews(document);
|
||||
applyDocumentTranslations(document);
|
||||
const loadingScreen = document.getElementById('loading-screen');
|
||||
const loaderStatus = loadingScreen.querySelector('.loader-status');
|
||||
let placeSearch;
|
||||
let catalog;
|
||||
return createApplication({
|
||||
const application = createApplication({
|
||||
createScene: async (context) => {
|
||||
// A language switch applies in place; the page's own markup follows.
|
||||
context.defer(
|
||||
onLocaleChange(() => {
|
||||
applyDocumentLanguage(document, getLocale());
|
||||
applyDocumentTranslations(document);
|
||||
}),
|
||||
);
|
||||
placeSearch = createStandalonePlaceSearch({
|
||||
// The bundled city and landmark data the offline name provider reads.
|
||||
// The search package takes it as plain data rather than importing it,
|
||||
@@ -131,4 +156,13 @@ export function createStandaloneApplication({
|
||||
return tools;
|
||||
},
|
||||
});
|
||||
owner = application;
|
||||
application.subscribe(({ status }) => {
|
||||
if (
|
||||
(status === 'destroyed' || status === 'failed') &&
|
||||
owner === application
|
||||
)
|
||||
owner = null;
|
||||
});
|
||||
return application;
|
||||
}
|
||||
Vendored
+1
-32
@@ -1,40 +1,9 @@
|
||||
import { createApplicationControls } from '../app/controls.js';
|
||||
import { getStandaloneCatalog } from './catalog.js';
|
||||
import { ENGINE_STORAGE_KEY } from '../app/engineChoice.js';
|
||||
|
||||
export function createStandaloneControls(options) {
|
||||
const controls = createApplicationControls({
|
||||
return createApplicationControls({
|
||||
catalog: options?.catalog ?? getStandaloneCatalog(),
|
||||
...options,
|
||||
});
|
||||
const select = document.getElementById('globe-engine');
|
||||
const container = document.getElementById('globe-engine-control');
|
||||
if (select && container) {
|
||||
const current = options.scene.engine.kind;
|
||||
select.value = current;
|
||||
const switchEngine = () => {
|
||||
const next = select.value;
|
||||
if (next === current || !['cesium', 'navara'].includes(next)) return;
|
||||
controls.styleManager.shareLinkManager.flush();
|
||||
const url = new URL(window.location.href);
|
||||
// Keep Back meaningful even when this visit began without ?engine=.
|
||||
url.searchParams.set('engine', current);
|
||||
window.history.replaceState(window.history.state, '', url);
|
||||
url.searchParams.set('engine', next);
|
||||
try {
|
||||
window.localStorage.setItem(ENGINE_STORAGE_KEY, next);
|
||||
} catch {
|
||||
// The explicit URL also works when storage is blocked.
|
||||
}
|
||||
select.value = current;
|
||||
window.location.assign(url);
|
||||
};
|
||||
select.addEventListener('change', switchEngine);
|
||||
container.hidden = false;
|
||||
options.defer(() => {
|
||||
select.removeEventListener('change', switchEngine);
|
||||
container.hidden = true;
|
||||
});
|
||||
}
|
||||
return controls;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import { createWeatherSource } from '../layers/weather/source.js';
|
||||
import { createCycloneSource } from '../layers/cyclones/source.js';
|
||||
import { createWindSource } from '../layers/wind/source.js';
|
||||
import { createFirmsSource } from '../layers/firms/source.js';
|
||||
import { createGhostMapsSource } from '../layers/ghostMaps/source.js';
|
||||
import { createMapillarySource } from '../layers/streetLevel/providers/mapillary/source.js';
|
||||
import { createReferenceSources } from '../sources/reference.js';
|
||||
export { createReferenceSources as createStandaloneReferenceSources } from '../sources/reference.js';
|
||||
@@ -50,6 +51,7 @@ export function createStandaloneLayerSources(overrides = {}) {
|
||||
launches: createLaunchSource(),
|
||||
alpr: createAlprTileSource(),
|
||||
firms: createFirmsSource(),
|
||||
's2-ghostmaps': createGhostMapsSource(),
|
||||
wind: createWindSource(),
|
||||
weather: createWeatherSource(),
|
||||
cyclones: createCycloneSource(),
|
||||
|
||||
@@ -17,6 +17,11 @@ export function createStandaloneTools(options) {
|
||||
},
|
||||
},
|
||||
...options,
|
||||
voice: { toolCatalog: loadToolCatalog, ...options?.voice },
|
||||
voice: {
|
||||
supportedProviders: ['openai', 'gemini'],
|
||||
panel: true,
|
||||
toolCatalog: loadToolCatalog,
|
||||
...options?.voice,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export { StyleManager } from '../ui/composition.js';
|
||||
Reference in new issue
Block a user