mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Add a Navara HD renderer choice, release a parked engine after three minutes, and cut Navara's memory
Navara now draws at CSS pixels without MSAA, like Cesium; Navara HD keeps the device pixel ratio and MSAA 4. Only one Navara variant is ever kept. A parked engine is released after three minutes and its WebGL context is lost. Three leaks that kept a released Navara alive are fixed, the canvas context drops its unused antialias buffer, cloud shadows use two 256 px cascades, and the tile cache is budgeted from the screen buffers.
This commit is contained in:
1 parent
a6c64713ee
commit
9825b02aab
22 files changed
+657
-58
No files matched your search
+15
-6
@@ -1,21 +1,30 @@
|
||||
/** The localStorage key that remembers an engine choice between visits. */
|
||||
export const ENGINE_STORAGE_KEY = 'gev.engine';
|
||||
|
||||
const KINDS = new Set(['cesium', 'navara']);
|
||||
/**
|
||||
* The globe choices: Cesium, Navara at CSS pixels without MSAA (as Cesium
|
||||
* draws), and Navara HD at the device pixel ratio with MSAA 4 (on a 2x
|
||||
* screen about 1 GiB more: 2.7 GiB against 1.8).
|
||||
*/
|
||||
export const ENGINE_CHOICES = Object.freeze(['cesium', 'navara', 'navara-hd']);
|
||||
|
||||
/** The engine a choice runs: both Navara choices are the Navara engine. */
|
||||
export const engineOfChoice = (choice) =>
|
||||
choice === 'cesium' ? 'cesium' : 'navara';
|
||||
|
||||
const known = (value) => {
|
||||
const kind = String(value ?? '')
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
return KINDS.has(kind) ? kind : null;
|
||||
return ENGINE_CHOICES.includes(kind) ? kind : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* The globe engine for this page: `?engine=cesium|navara`, else the stored
|
||||
* `gev.engine`, else Cesium. Navara is experimental; an unknown or unreadable
|
||||
* value never selects it.
|
||||
* The globe choice for this page: `?engine=cesium|navara|navara-hd`, else
|
||||
* the stored `gev.engine`, else Cesium. Navara is experimental; an unknown or
|
||||
* unreadable value never selects it.
|
||||
* @param {{ search?: string, storage?: { getItem(key: string): string | null } | null }} [where]
|
||||
* @returns {'cesium' | 'navara'}
|
||||
* @returns {'cesium' | 'navara' | 'navara-hd'}
|
||||
*/
|
||||
export function resolveEngineKind({ search = '', storage = null } = {}) {
|
||||
const fromQuery = known(new URLSearchParams(search).get('engine'));
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { ENGINE_STORAGE_KEY, resolveEngineKind } from './engineChoice.js';
|
||||
import {
|
||||
ENGINE_STORAGE_KEY,
|
||||
engineOfChoice,
|
||||
resolveEngineKind,
|
||||
} from './engineChoice.js';
|
||||
|
||||
const storage = (value) => ({
|
||||
getItem: (key) => (key === ENGINE_STORAGE_KEY ? value : null),
|
||||
@@ -53,3 +57,23 @@ test('unknown values and unreadable storage fall back to Cesium', () => {
|
||||
};
|
||||
assert.equal(resolveEngineKind({ search: '', storage: throwing }), 'cesium');
|
||||
});
|
||||
|
||||
test('Navara HD is a choice of the Navara engine', () => {
|
||||
assert.equal(
|
||||
resolveEngineKind({
|
||||
search: '?engine=navara-hd',
|
||||
storage: storage('cesium'),
|
||||
}),
|
||||
'navara-hd',
|
||||
);
|
||||
assert.equal(
|
||||
resolveEngineKind({ search: '', storage: storage('navara-hd') }),
|
||||
'navara-hd',
|
||||
);
|
||||
assert.equal(resolveEngineKind({ search: '?engine=navara-4k' }), 'cesium');
|
||||
assert.deepEqual(['cesium', 'navara', 'navara-hd'].map(engineOfChoice), [
|
||||
'cesium',
|
||||
'navara',
|
||||
'navara',
|
||||
]);
|
||||
});
|
||||
@@ -336,6 +336,7 @@ export async function createNavaraScene({
|
||||
mapOptions,
|
||||
loaderStatus,
|
||||
loadNavaraGlobe = loadNavaraGlobeModule,
|
||||
hd = false,
|
||||
signal,
|
||||
defer,
|
||||
}) {
|
||||
@@ -346,6 +347,8 @@ export async function createNavaraScene({
|
||||
container,
|
||||
// The cinematic look unless `?look=photoreal|minimal` asks otherwise.
|
||||
search: globalThis.location?.search ?? '',
|
||||
// Navara HD: the device pixel ratio and MSAA (viewOptions.js).
|
||||
hd,
|
||||
});
|
||||
defer(() => globe.destroy());
|
||||
const { engine } = globe;
|
||||
|
||||
+5
-3
@@ -21,8 +21,9 @@ import { loadCesium } from './loadCesium.js';
|
||||
|
||||
/**
|
||||
* Construct the application globe using the caller's local configuration.
|
||||
* `engineKind` 'navara' builds the experimental Navara engine instead of the
|
||||
* Cesium viewer: the scene then has no viewer (`viewer: null`).
|
||||
* `engineKind` 'navara' or 'navara-hd' (the page's engine choice,
|
||||
* src/app/engineChoice.js) builds the experimental Navara engine instead of
|
||||
* the Cesium viewer: the scene then has no viewer (`viewer: null`).
|
||||
*/
|
||||
export async function createApplicationScene({
|
||||
requestServices,
|
||||
@@ -113,7 +114,7 @@ async function createRenderer({
|
||||
}) {
|
||||
// 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') {
|
||||
if (engineKind === 'navara' || engineKind === 'navara-hd') {
|
||||
const scene = await (
|
||||
await import('./navaraMode.js')
|
||||
).createNavaraScene({
|
||||
@@ -124,6 +125,7 @@ async function createRenderer({
|
||||
mapOptions,
|
||||
loaderStatus,
|
||||
loadNavaraGlobe,
|
||||
hd: engineKind === 'navara-hd',
|
||||
signal,
|
||||
defer,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user