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

+24 -68
View File
@@ -1,72 +1,28 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { orderWeatherImagery } from './imageryOrder.js';
import { WEATHER_IMAGERY_Z } from './imageryOrder.js';
import { fakeGlobePort } from '../../testSupport/fakeGlobePort.mjs';
test('weather compositing remains consistent when scalar, observation and history arrive out of order', () => {
const base = { name: 'basemap' },
radar = { name: 'radar' },
cloud = { name: 'cloud' },
wind = { name: 'wind' },
lightning = { name: 'lightning' };
const items = [base];
const collection = {
get length() {
return items.length;
},
get: (i) => items[i],
raiseToTop(layer) {
items.push(...items.splice(items.indexOf(layer), 1));
},
};
for (const [layer, priority] of [
[radar, 2],
[cloud, 1],
[lightning, 3],
[wind, 0],
]) {
items.push(layer);
orderWeatherImagery(collection, layer, priority);
}
assert.deepEqual(items, [base, wind, cloud, radar, lightning]);
const next = { name: 'new radar history frame' };
items.push(next);
orderWeatherImagery(collection, next, 2);
assert.deepEqual(items, [base, wind, cloud, radar, next, lightning]);
});
test('tileset imagery collection preserves scalar, infrared, radar and lightning order', async () => {
const { ImageryLayerCollection, ImageryLayer } = await import('cesium');
const tileset = { imageryLayers: new ImageryLayerCollection() };
const layers = Array.from({ length: 4 }, () => new ImageryLayer());
for (const priority of [3, 2, 0, 1]) {
tileset.imageryLayers.add(layers[priority]);
orderWeatherImagery(tileset.imageryLayers, layers[priority], priority);
}
assert.deepEqual(
layers.map((_, i) => tileset.imageryLayers.get(i)),
layers,
);
tileset.imageryLayers.destroy();
});
test('already ordered imagery adds and repeated ordering cause no collection churn', () => {
const items = [];
let raises = 0;
const collection = {
get length() {
return items.length;
},
get: (i) => items[i],
raiseToTop(layer) {
raises++;
items.push(...items.splice(items.indexOf(layer), 1));
},
};
for (const priority of [0, 1, 1, 2, 3]) {
const layer = {};
items.push(layer);
orderWeatherImagery(collection, layer, priority);
orderWeatherImagery(collection, layer, priority);
}
assert.equal(raises, 0);
test('wind, infrared, radar, then lightning, above zOrder 0, whatever the enable order', () => {
const globe = fakeGlobePort();
const add = (name) =>
globe.imagery.add({
kind: 'xyz',
url: `https://${name}.invalid/{z}/{x}/{y}`,
zOrder: WEATHER_IMAGERY_Z[name],
});
const lightning = add('lightning');
const overlay = globe.imagery.add({ kind: 'xyz', url: 'https://o.invalid' });
const radar = add('radar');
const wind = add('wind');
const clouds = add('clouds');
const regional = add('clouds-regional');
assert.deepEqual(globe.layers, [
overlay,
wind,
clouds,
regional,
radar,
lightning,
]);
});