Remove always-true layer availability and leftover viewer paths

Every layer draws on both engines, so the per-engine availability
machinery always answered yes. The renderer manifest is now the id to
display map plus the wind flow backend; the catalog filter, the voice and
QA-probe refusals and the engine-kind checks go with it. The Navara
notice lists the same layers in the same words.

Paths that read the Cesium viewer behind an engine that is always there
are gone: the Recent Imagery viewer fallbacks, the shell's imagery-host
service (one shared host module remains), the engineless map controller,
viewer gates in voice actions, world packets and camera verbs, the
orientation controls' tracked-entity fallback, and the Bhote Koshi and
FIRMS Cesium-shaped paths. setCameraInputs, which nothing called, leaves
the contract; suspensions remain.

Smaller duplicates go too: one tracker-release helper for navigation and
location, the no-op frame latch, missing-engine guards, one name for the
injected display, flat bikeshare and installations displays, one overlay
host and binder, one name per world-overlay method, and stub-viewer
guards in the Cesium engine. Layers that still read the viewer keep the
shared init(viewer, context) entry.

Behaviour is unchanged on both engines. Viewer lines fall from 849 to
750 and engine-name literals from 32 to 27.
This commit is contained in:
German Khokhlov committed 2026-11-08 17:06:01 +04:00
1 parent 371d848eec
commit 7f478e3815
279 files changed
+1570 -3104

No files matched your search

+2 -2
View File
@@ -29,9 +29,9 @@ export function createCards({
function rebuildAmbientLabels() {
if (!layerState._renderer) return;
const scene = layerState._viewer.scene;
const scene = layerState._view.scene;
const project = (position, result) =>
layerState._renderer.project(position, result);
layerState._renderer.view.worldToWindow(position, result);
const now = Date.now();
const entries = [];
/** @type {Array<{x: number, y: number}>} Screen positions of accepted labels. */
+4 -4
View File
@@ -7,8 +7,8 @@ test('reenabling an empty filtered layer never reveals the retained pre-filter h
const noop = () => {};
const layerState = {
_enabled: false,
_viewer: {},
_dataSource: {},
_view: {},
_renderer: {},
_fires: [],
_loading: true,
_pickIndexById: new Map(),
@@ -34,13 +34,13 @@ test('reenabling an empty filtered layer never reveals the retained pre-filter h
selection: { installClickHandler: noop },
},
});
await lifecycle.methods.enable(layerState._viewer);
await lifecycle.methods.enable(layerState._view);
assert.equal(
shown,
false,
'empty current set must keep the old raster hidden while refresh is pending',
);
layerState._fires = [{ frp: null, confidence: null }];
await lifecycle.methods.enable(layerState._viewer);
await lifecycle.methods.enable(layerState._view);
assert.equal(shown, true, 'nonempty sets still resume their raster');
});
+3 -3
View File
@@ -1,4 +1,4 @@
import { bindContextStore } from '../../data/bindContextStore.js';
import { bindOverlayHost } from '../../overlays/bindOverlayHost.js';
import { adaptFirmsRecords } from '../../data/firmsAdapt.js';
import { fireDetectionKey } from '../../data/firmsLabels.js';
import { filterFires } from '../../data/firmsIntensity.js';
@@ -11,7 +11,7 @@ export function createIngestion({
config,
feed,
}) {
const { clearSelectedEntityContextForLayer } = bindContextStore(
const { clearSelectedEntityContextForLayer } = bindOverlayHost(
services.context,
() => layerState._renderer?.engine,
);
@@ -20,7 +20,7 @@ export function createIngestion({
/** Replace a validated snapshot while preserving source freshness and selection identity. */
async function loadHeatmap() {
if (!layerState._dataSource || !layerState._enabled) return;
if (!layerState._renderer || !layerState._enabled) return;
layerState.request?.abort();
const request = new AbortController();
layerState.request = request;
+6 -7
View File
@@ -1,4 +1,4 @@
import { bindContextStore } from '../../data/bindContextStore.js';
import { bindOverlayHost } from '../../overlays/bindOverlayHost.js';
import { FIRMS_OVERLAY_SOURCE_ID } from '../../data/firmsLabels.js';
export function createLifecycle({
@@ -9,7 +9,7 @@ export function createLifecycle({
feed,
}) {
const { registerPickOwner, unregisterPickOwner } = services.picking;
const { clearSelectedEntityContextForLayer } = bindContextStore(
const { clearSelectedEntityContextForLayer } = bindOverlayHost(
services.context,
() => layerState._renderer?.engine,
);
@@ -39,8 +39,7 @@ export function createLifecycle({
if (layerState._renderer || !engine) return;
layerState._renderer = config.renderer.create({ engine, id, services });
if (!layerState._renderer) return;
layerState._viewer = layerState._renderer.view;
layerState._dataSource = layerState._renderer.dataSource;
layerState._view = layerState._renderer.view;
layerState._renderer.setVisible(false);
layerState._restoringViewport = waitForCameraRestore;
if (layerState._enabled && !waitForCameraRestore) this.showRenderer();
@@ -67,7 +66,7 @@ export function createLifecycle({
components.rendering.removeDetectionCollections();
releaseHeat();
layerState._renderer?.destroy();
layerState._renderer = layerState._viewer = layerState._dataSource = null;
layerState._renderer = layerState._view = null;
layerState._pickIndexById.clear();
layerState._labelCandidates = [];
layerState._camSnapValid = false;
@@ -143,8 +142,8 @@ export function createLifecycle({
clearSelectedEntityContextForLayer(id);
layerState._renderer?.destroy();
layerState._renderer = null;
layerState._viewer = null;
layerState._dataSource = null;
layerState._view = null;
layerState._renderer = null;
layerState._allFires = [];
layerState._allFiresByFrp = [];
layerState._fires = [];
+1 -15
View File
@@ -99,16 +99,12 @@ export function createFirmsDisplay(
engine,
{ id = 'local-firms', loadImage, createCanvas } = {},
) {
if (!engine?.movers || !engine?.ground || !engine?.imagery)
throw new TypeError('The FIRMS display needs a globe engine');
let destroyed = false,
visible = false,
cellItems = [],
cellsQueued = false,
sprites = null,
heat = null;
// The layer's visibility as the context store reads a data source's.
const dataSource = { show: false };
const clickRemovers = new Set();
const cells = engine.ground.createSet({ id: `${id}:cells`, kind: 'cell' });
cells.show(false);
@@ -116,9 +112,6 @@ export function createFirmsDisplay(
layerId: id,
isDestroyed: () => destroyed,
});
// The camera and scene events the layer's watchers listen to.
layerView.view.camera.moveEnd = engine.camera.moveEnd;
layerView.view.scene.preRender = engine.frames.preRender;
// Cells arrive one addCell at a time: one commit per batch.
const scheduleCells = () => {
if (cellsQueued || destroyed) return;
@@ -137,16 +130,11 @@ export function createFirmsDisplay(
return {
engine,
view: layerView.view,
dataSource,
project: (position, result) =>
engine.projector.worldToWindow(position, result),
visible: () => visible,
viewRectangle(result) {
const rect = engine.camera.viewRectangle();
return rect ? Object.assign(result ?? {}, rect) : null;
},
horizon: () => ({
isPointVisible: (position) => engine.projector.horizonVisible(position),
}),
/**
* Calls `handler({ position, picked })` for every click while the layer
* is shown, with the pick under it; returns the remover.
@@ -171,7 +159,6 @@ export function createFirmsDisplay(
const next = show !== false;
if (visible === next) return;
visible = next;
dataSource.show = next;
sprites?.setVisible(next);
cells.show(next);
},
@@ -230,7 +217,6 @@ export function createFirmsDisplay(
if (destroyed) return;
destroyed = true;
visible = false;
dataSource.show = false;
cellItems = [];
for (const release of [...clickRemovers]) release();
removeSprites();
+6 -6
View File
@@ -230,7 +230,7 @@ for (const make of HARNESSES) {
}
r.setVisible(false);
assert.equal(h.ground.listed(id).shown, false);
assert.equal(r.dataSource.show, false);
assert.equal(r.visible(), false);
r.clearCells();
await settle();
assert.equal(r.cellCount(), 0);
@@ -422,19 +422,19 @@ for (const make of HARNESSES) {
1e-6,
),
);
assert.equal(r.view.camera.moveEnd, h.engine.camera.moveEnd);
assert.equal(r.view.scene.preRender, h.engine.frames.preRender);
assert.equal(r.engine.camera.moveEnd, h.engine.camera.moveEnd);
assert.equal(r.engine.frames.preRender, h.engine.frames.preRender);
const near = at(FIRE.lon, FIRE.lat);
assert.deepEqual(
r.project(near, {}),
r.view.worldToWindow(near, {}),
h.engine.projector.worldToWindow(near, {}),
);
assert.deepEqual(r.viewRectangle({}), {
...h.engine.camera.viewRectangle(),
});
const far = at(FIRE.lon + 180, -FIRE.lat);
assert.equal(r.horizon().isPointVisible(near), true);
assert.equal(r.horizon().isPointVisible(far), false);
assert.equal(r.view.horizon().isPointVisible(near), true);
assert.equal(r.view.horizon().isPointVisible(far), false);
r.destroy();
} finally {
h.destroy();
+4 -4
View File
@@ -38,9 +38,9 @@ export function createRendering({
function renderCurrentLod(force = false) {
if (
!layerState._dataSource ||
!layerState._renderer ||
!layerState._fires.length ||
!layerState._viewer
!layerState._view
) {
// A filter that leaves nothing shown must not leave the old heat behind.
if (!layerState._fires.length) layerState._heatImagery?.setShow(false);
@@ -295,7 +295,7 @@ export function createRendering({
// reports false, so this chain terminates instead of looping against a
// down proxy (the next camera-driven rebuild retries).
warmFireAnchorFloors(candidates).then((warmed) => {
if (!warmed || !layerState._enabled || !layerState._viewer) return;
if (!warmed || !layerState._enabled || !layerState._view) return;
const currentLod = LOD_LEVELS[layerState._currentLodIndex];
if (!currentLod || currentLod.mode !== 'detections') return;
renderCurrentLod(true);
@@ -389,7 +389,7 @@ export function createRendering({
*/
function fireHorizonOccluder() {
return layerState._renderer?.horizon() ?? null;
return layerState._renderer?.view.horizon() ?? null;
}
/**
+3 -3
View File
@@ -1,4 +1,4 @@
import { bindContextStore } from '../../data/bindContextStore.js';
import { bindOverlayHost } from '../../overlays/bindOverlayHost.js';
import {
FIRMS_OVERLAY_SOURCE_ID,
fireDetectionKey,
@@ -22,7 +22,7 @@ export function createSelection({
getContextStore,
removeEntityContext = (id) => getContextStore()?.entities.delete(id),
registerEntityContext,
} = bindContextStore(services.context, () => layerState._renderer?.engine);
} = bindOverlayHost(services.context, () => layerState._renderer?.engine);
const { id, name, overlayHost } = config;
/**
@@ -191,7 +191,7 @@ export function createSelection({
layerId: id,
layerName: name,
source: 'NASA FIRMS',
dataSource: layerState._dataSource,
isVisible: () => layerState._renderer?.visible() ?? false,
// i18n-ignore: English entity label; the voice card translates it (shownEntityLabel)
label: `Fire · FRP ${components.model.formatFrp(fire.frp)} MW`,
latitude: fire.lat,
+2 -2
View File
@@ -16,9 +16,9 @@ export function createFirmsState({ services, config }) {
layerState.scratchWindowCoord = geo.cartesian2.create();
layerState._viewer = null;
layerState._view = null;
layerState._dataSource = null;
layerState._renderer = null;
layerState._renderer = null;
+7 -7
View File
@@ -31,9 +31,9 @@ export function createViewport({
*/
function installMoveEndWatcher() {
if (layerState._moveEndRemover || !layerState._viewer) return;
if (layerState._moveEndRemover || !layerState._view) return;
layerState._moveEndRemover =
layerState._viewer.camera.moveEnd.addEventListener(() => {
layerState._renderer.engine.camera.moveEnd.addEventListener(() => {
if (!layerState._enabled) return;
// Settled-camera exactness for the horizon pass (the throttled preRender
// watcher can last have run up to LOD_CHECK_MS before the camera
@@ -54,7 +54,7 @@ export function createViewport({
function cameraHeight() {
return (
layerState._viewer?.camera?.positionCartographic?.height ??
layerState._view?.camera?.positionCartographic?.height ??
Number.POSITIVE_INFINITY
);
}
@@ -138,13 +138,13 @@ export function createViewport({
}
function installLodWatcher() {
if (layerState._preRenderRemover || !layerState._viewer) return;
if (layerState._preRenderRemover || !layerState._view) return;
// The LOD sweep is throttle-gated inside preRender. When the camera
// settles just inside the throttle window, the final rebuild would wait
// for a frame that idle mode never produces — schedule one. (perf wave 2)
if (!layerState._moveEndSettleRemover) {
layerState._moveEndSettleRemover =
layerState._viewer.camera.moveEnd.addEventListener(() => {
layerState._renderer.engine.camera.moveEnd.addEventListener(() => {
if (!layerState._enabled) return;
clearSettleTimer();
settleTimer = setTimeout(() => {
@@ -158,7 +158,7 @@ export function createViewport({
});
}
layerState._preRenderRemover =
layerState._viewer.scene.preRender.addEventListener(() => {
layerState._renderer.engine.frames.preRender.addEventListener(() => {
// NOTE: `_loading`/empty-data are deliberately NOT part of this guard.
// A refresh has no timeout, and sprites from the previous payload stay
// on screen throughout it — so the horizon pass below must keep running
@@ -172,7 +172,7 @@ export function createViewport({
layerState._lastLodCheck = now;
// Idle camera: two scratch compares and out — no view-rect math, no
// aggregation, no allocation while the user is parked.
const camera = layerState._viewer.camera;
const camera = layerState._view.camera;
if (
layerState._camSnapValid &&
geo.cartesian3.equalsEpsilon(
+2 -1
View File
@@ -25,7 +25,8 @@ function harness() {
const layerState = {
_enabled: true,
_destroyed: false,
_viewer: { camera: { moveEnd }, scene: { preRender } },
_view: { camera: {} },
_renderer: { engine: { camera: { moveEnd }, frames: { preRender } } },
};
const viewport = createViewport({
layerState,