mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Keep globe renderers warm across live engine switches
This commit is contained in:
1 parent
f71c76c306
commit
5e658d8c9d
15 files changed
+343
-34
No files matched your search
Vendored
+2
@@ -20,6 +20,7 @@ export function createApplicationControls({
|
||||
defer,
|
||||
initialShareCode = null,
|
||||
localePicker = true,
|
||||
engineSwitch = false,
|
||||
}) {
|
||||
// Initialize the style manager (post-processing, HUD, locations, share links)
|
||||
const styleManager = new Controls(viewer, {
|
||||
@@ -40,6 +41,7 @@ export function createApplicationControls({
|
||||
placeSearch,
|
||||
// A share code to open at start-up instead of the page's address.
|
||||
initialShareCode,
|
||||
engineSwitch,
|
||||
localePicker,
|
||||
});
|
||||
defer(() => styleManager.orbitController.stop());
|
||||
|
||||
@@ -177,7 +177,7 @@ export async function registerNavaraLayerRenderers() {
|
||||
* credits in its own attribution UI.
|
||||
*/
|
||||
export async function createNavaraScene({
|
||||
operations,
|
||||
container = document.getElementById('cesiumContainer'),
|
||||
cesiumToken,
|
||||
credits,
|
||||
MapController,
|
||||
@@ -191,7 +191,7 @@ export async function createNavaraScene({
|
||||
const createNavaraGlobe = await loadNavaraGlobe();
|
||||
signal.throwIfAborted();
|
||||
const globe = await createNavaraGlobe({
|
||||
container: document.getElementById('cesiumContainer'),
|
||||
container,
|
||||
// The cinematic look unless `?look=photoreal|minimal` asks otherwise.
|
||||
search: globalThis.location?.search ?? '',
|
||||
});
|
||||
@@ -241,8 +241,8 @@ export async function createNavaraScene({
|
||||
viewer: null,
|
||||
engine,
|
||||
tileset: null,
|
||||
setRenderLoop: globe.setRenderLoop,
|
||||
mapStackController,
|
||||
operations,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+33
-12
@@ -26,16 +26,10 @@ import { onLocaleChange, t } from '../i18n/index.js';
|
||||
export async function createApplicationScene({
|
||||
requestServices,
|
||||
googleApiKey,
|
||||
googleTokens = null,
|
||||
cesiumToken,
|
||||
credits,
|
||||
MapController = MapStackController,
|
||||
mapOptions = {},
|
||||
loaderStatus,
|
||||
engineKind = 'cesium',
|
||||
loadNavaraGlobe,
|
||||
signal,
|
||||
defer,
|
||||
rendererCache,
|
||||
...options
|
||||
}) {
|
||||
const operations = createApplicationOperations({
|
||||
requests: requestServices,
|
||||
@@ -51,11 +45,38 @@ export async function createApplicationScene({
|
||||
else window.__GOOGLE_MAPS_API_KEY__ = previousKey;
|
||||
});
|
||||
}
|
||||
const build = (resources) =>
|
||||
createRenderer({
|
||||
...options,
|
||||
googleApiKey,
|
||||
signal,
|
||||
...resources,
|
||||
});
|
||||
const { viewer, engine, tileset, mapStackController } = rendererCache
|
||||
? await rendererCache.acquire(options.engineKind, build, defer)
|
||||
: await build({ defer });
|
||||
return { viewer, engine, tileset, mapStackController, operations };
|
||||
}
|
||||
|
||||
async function createRenderer({
|
||||
googleApiKey,
|
||||
googleTokens = null,
|
||||
cesiumToken,
|
||||
credits,
|
||||
MapController = MapStackController,
|
||||
mapOptions = {},
|
||||
loaderStatus,
|
||||
engineKind = 'cesium',
|
||||
loadNavaraGlobe,
|
||||
signal,
|
||||
defer,
|
||||
container,
|
||||
}) {
|
||||
// The Navara mode's own code loads only in that mode, with Navara itself,
|
||||
// so the Cesium-mode bundle carries none of it.
|
||||
if (engineKind === 'navara')
|
||||
return (await import('./navaraMode.js')).createNavaraScene({
|
||||
operations,
|
||||
container,
|
||||
cesiumToken,
|
||||
credits,
|
||||
MapController,
|
||||
@@ -71,10 +92,10 @@ export async function createApplicationScene({
|
||||
// Provider attribution stays visible, including clean-view and recording.
|
||||
const creditContainer = document.createElement('div');
|
||||
creditContainer.id = 'cesium-credits';
|
||||
document.body.appendChild(creditContainer);
|
||||
(container ?? document.body).appendChild(creditContainer);
|
||||
defer(() => creditContainer.remove());
|
||||
const viewer = createApplicationViewer({
|
||||
container: 'cesiumContainer',
|
||||
container: container ?? 'cesiumContainer',
|
||||
creditContainer,
|
||||
});
|
||||
defer(() => {
|
||||
@@ -160,5 +181,5 @@ export async function createApplicationScene({
|
||||
});
|
||||
|
||||
signal.throwIfAborted();
|
||||
return { viewer, engine, tileset, mapStackController, operations };
|
||||
return { viewer, engine, tileset, mapStackController };
|
||||
}
|
||||
@@ -16,7 +16,9 @@ export function startApplicationChrome({
|
||||
const minimumDelay = new Promise((resolve) => {
|
||||
resolveDelay = resolve;
|
||||
});
|
||||
const delayTimer = setTimeout(resolveDelay, 1000);
|
||||
const switching = loadingScreen.classList.contains?.('hidden');
|
||||
const delayTimer = switching ? null : setTimeout(resolveDelay, 1000);
|
||||
if (switching) resolveDelay();
|
||||
const revealFirstRun = () => {
|
||||
if (disposed || signal.aborted || firstRun) return;
|
||||
firstRun = initializeWelcome?.({ styleManager, dataManager });
|
||||
@@ -28,7 +30,7 @@ export function startApplicationChrome({
|
||||
/* Restoration reports its own outcome through the controls. */
|
||||
})
|
||||
.then(() => {
|
||||
if (disposed || signal.aborted) return;
|
||||
if (disposed || signal.aborted || switching) return;
|
||||
loadingScreen.classList.add('hidden');
|
||||
loadingScreen.addEventListener('transitionend', revealFirstRun, {
|
||||
once: true,
|
||||
|
||||
Reference in new issue
Block a user