feat(ui): switch between Cesium and Navara in Visual Presets

Remember the chosen engine and restore the current view after navigation. Keep the standalone JavaScript UI and retire the Dioxus migration and Cesium removal milestones.
This commit is contained in:
German Khokhlov committed 2026-11-02 11:29:55 +04:00
1 parent dc7a7c4d53
commit 1da65dc264
7 files changed
+171 -1

No files matched your search

+33 -1
View File
@@ -1,8 +1,40 @@
import { createApplicationControls } from '../app/controls.js';
import { getStandaloneCatalog } from './catalog.js';
import { ENGINE_STORAGE_KEY } from '../app/engineChoice.js';
export function createStandaloneControls(options) {
return createApplicationControls({
const controls = 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;
}