Draw the weather and wind imagery through the renderer's globe port

Radar, satellite clouds and lightning frames are imagery layers of the
globe port instead of Cesium providers in the viewer's collection. A frame
stages as a transparent layer on the globe's surface and counts its tiles
through the layer's admit hook; the global infrared mosaic draws each tile
of the geographic grid from the decoded canvas, the regional infrared
transfer runs as the layer's tile transform on the upright tile, and
throttled tiles are fetched again by the renderer. Readiness reads the
port's imagery settling, the camera port gives the view and its move end,
and the frame's credit, which a refreshed manifest can still change in
place, is owed through the credits port while the layer is shown.
Without a host the shown frame is hidden rather than detached.

Wind's colour field is a port layer too, so the draw order is a zOrder per
product (wind, infrared, radar, lightning), above the port's other
imagery, and the raise-to-top helper goes. The Cesium port keeps a tile
transform's bitmaps in straight alpha and closes the copies it spends,
and a provider that fails to build is told as an error of its root tile.

The weather rendering and raster tile modules no longer reach Cesium and
leave the allow-list; the 3D Tiles shell still does.
This commit is contained in:
Sameh Khamis committed 2026-11-06 20:06:33 -08:00
1 parent 9e1f9a1c3d
commit 76880f6eae
15 files changed
+735 -721

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
/**
* A globe port for tests of code that drapes imagery through the renderer's
* globe port (`src/render/contract/globe.d.ts`): it records each layer and
* its spec, orders layers by `zOrder` as the contract says, and lets a test
* drive tile requests through a layer's hooks and raise its tile errors.
*/
/**
* @param {{settled?: (kind: string) => boolean}} [options]
* `settled`: what `isSettled` answers.
*/
export function fakeGlobePort({ settled = () => true } = {}) {
/** Live layers, bottom to top. */
const layers = [];
/** Every layer ever added, in the order added. */
const added = [];
let split = 0;
let globeVisible = true;
function add(spec, index) {
const listeners = { tileError: new Set(), frameReady: new Set() };
const layer = {
spec,
alpha: 1,
show: true,
split: 'none',
drapeOn: 'all',
lit: true,
removed: false,
on(event, cb) {
listeners[event]?.add(cb);
return () => listeners[event]?.delete(cb);
},
raise() {
const i = layers.indexOf(layer);
if (i < 0 || i === layers.length - 1) return;
layers.splice(i, 1);
layers.splice(i + 1, 0, layer);
},
lower() {
const i = layers.indexOf(layer);
if (i <= 0) return;
layers.splice(i, 1);
layers.splice(i - 1, 0, layer);
},
remove() {
if (layer.removed) return;
layer.removed = true;
layers.splice(layers.indexOf(layer), 1);
listeners.tileError.clear();
listeners.frameReady.clear();
},
/**
* Ask for a tile as the renderer would: `admit` decides, and an issued
* request runs `fetch` (the renderer's own fetch) then `tileTransform`.
* @param {{x: number, y: number, level: number}} tile
* @param {() => Promise<unknown> | undefined} fetch
*/
request(tile, fetch) {
const issue = () => {
const started = fetch();
if (!started || !spec.tileTransform) return started;
return Promise.resolve(started).then((image) =>
spec.tileTransform(tile, image),
);
};
return spec.admit ? spec.admit(tile, issue) : issue();
},
/** Tell the layer's `tileError` listeners. */
fail(error) {
for (const cb of [...listeners.tileError]) cb(error);
},
listenerCount: (event) => listeners[event]?.size ?? 0,
};
let at = index;
if (at === undefined) {
const z = Number.isFinite(spec.zOrder) ? spec.zOrder : 0;
at = layers.length;
while (at > 0 && (layers[at - 1].spec.zOrder ?? 0) > z) at -= 1;
}
layers.splice(Math.max(0, Math.min(at, layers.length)), 0, layer);
added.push(layer);
return layer;
}
return {
layers,
added,
imagery: {
add,
list: () => layers.slice(),
getSplit: () => split,
setSplit: (x01) => {
split = Math.min(1, Math.max(0, Number(x01)));
},
},
isSettled: (kind) => settled(kind),
setGlobeVisible(visible) {
globeVisible = Boolean(visible);
},
get globeVisible() {
return globeVisible;
},
on: () => () => {},
};
}