Draw Radio stations and their clusters through the draw port and take the Radio renderer off the Cesium list

The stations, the cluster dots and the selected station's dot and bracket
are draw-port point and icon sets. Stations drawn too close together on
screen are grouped by geo/screenCluster.js as the default renderer's
entity clustering grouped them: the same boxes and screen coordinates, the
same reuse of the last pass's clusters when the eye comes lower, a pass
whenever the camera moves enough or a station is shown or hidden, and
stations a pass passes over hidden until the next. A cluster dot names its
seed station, so a click plays it as before. The Radio QA script reads the
drawn sets; the unused cluster-collection internals helper is gone.
This commit is contained in:
Sameh Khamis committed 2026-11-08 11:11:50 -08:00
1 parent b2502d6f37
commit a59f9b10b2
17 files changed
+1134 -352

No files matched your search

+93
View File
@@ -3009,6 +3009,99 @@ test('the FIRMS layer draws its fire glows as one GPU icon set on a viewer of it
assert.equal(scene.added.length, 0);
});
test('the Radio layer draws its stations, clusters and selected marker as point and billboard sets', async () => {
const { withRadioLayer, radioStationRow } =
await import('../../testSupport/radioLayerHarness.mjs');
const { radioLayer, radioStationIdFromPick } =
await import('../../data/radio.js');
const { fromDegrees, toLonLatH, WGS84 } =
await import('../../geo/ellipsoid.js');
const scene = fakeScene();
const part = createCesiumDraw({
scene,
report: (error) => assert.fail(error),
});
// A flat projection, 1000 CSS px a degree from (-98, 31) at the top left.
const renderer = {
draw: part.port,
canvas: { clientWidth: 2000, clientHeight: 1000 },
camera: {
pose: () => ({ position: fromDegrees(-97, 30, 1e6), height: 1e6 }),
on: () => () => {},
},
query: {
project(p) {
const { lon, lat } = toLonLatH(p, WGS84);
return { x: (lon + 98) * 1000, y: (31 - lat) * 1000 };
},
},
};
const station = (n, lon, lat) =>
radioStationRow({
id: `00000000-0000-4000-8000-0000000000${String(n).padStart(2, '0')}`,
name: `Station ${n}`,
lon,
lat,
tags: ['news'],
streamUrl: `https://radio.example.com/${n}.mp3`,
});
const stations = [
station(1, -97.0, 30.0),
station(2, -96.98, 30.0),
station(3, -97.0, 29.98),
station(4, -96.5, 30.0),
];
await withRadioLayer({ stations, renderer }, async () => {
const rows = (pattern) => {
const out = [];
for (const host of scene.added) {
const collections =
host instanceof Cesium.PrimitiveCollection
? [host.get(0), host.get(1)]
: [host];
for (const collection of collections)
for (let i = 0; i < (collection?.length ?? 0); i += 1) {
const primitive = collection.get(i);
if (pattern.test(primitive.id?.set)) out.push(primitive);
}
}
return out;
};
const dots = rows(/^radio:\d+:stations$/);
assert.equal(dots.length, 4);
assert.ok(dots.every((dot) => dot instanceof Cesium.PointPrimitive));
const lone = dots.find((dot) => dot.show);
assert.equal(lone.id.id, `radio:${stations[3].id}`, 'the others are in a cluster');
assert.equal(lone.pixelSize, 13);
assert.equal(lone.outlineWidth, 1);
assert.ok(Math.abs(lone.color.alpha - 0.86) < 1e-6);
assert.equal(lone.disableDepthTestDistance, Number.POSITIVE_INFINITY);
assert.equal(lone.distanceDisplayCondition.far, 50_000_000);
assert.equal(lone.scaleByDistance.nearValue, 1.15);
assert.equal(radioStationIdFromPick({ primitive: lone, id: lone.id }), stations[3].id);
const [cluster] = rows(/^radio:\d+:clusters$/);
assert.deepEqual(
cluster.id.meta.stationIds,
stations.slice(0, 3).map((s) => s.id),
);
assert.equal(cluster.pixelSize, 12 + Math.log2(3) * 1.6);
assert.equal(cluster.outlineWidth, 2);
assert.equal(radioStationIdFromPick({ primitive: cluster, id: cluster.id }), stations[0].id);
radioLayer.selectStation(stations[3].id, { autoplay: false, focus: false });
const [selected] = rows(/^radio:\d+:selected$/);
const [bracket] = rows(/^radio:\d+:selected-bracket$/);
assert.equal(selected.pixelSize, 14);
assert.equal(selected.id.id, `radio:selected:${stations[3].id}`);
assert.ok(bracket instanceof Cesium.Billboard);
assert.equal(bracket.width, 40);
assert.equal(bracket.scaleByDistance.farValue, 0.72);
assert.equal(radioStationIdFromPick({ primitive: bracket, id: bracket.id }), stations[3].id);
});
assert.equal(scene.added.length, 0, 'gone with the layer');
});
test('vessels on a host with no sprite-set registry still draw, and say so once', async (t) => {
const warnings = [];
t.mock.method(console, 'warn', (...args) => warnings.push(args.join(' ')));
-9
View File
@@ -46,15 +46,6 @@ export function billboardCollectionOf(billboard) {
return billboard?._billboardCollection;
}
/**
* The point collection an `EntityCluster` draws its cluster markers into.
* @param {object} clustering Cesium EntityCluster.
* @returns {object|null} Cesium PointPrimitiveCollection.
*/
export function clusterPointCollection(clustering) {
return clustering?._clusterPointCollection || null;
}
/**
* Close the widget's pending render-loop latch after `useDefaultRenderLoop`
* is set false, so a callback already queued sees the loop as stopped and
-7
View File
@@ -10,7 +10,6 @@ import {
billboardLoadError,
cameraFlightActive,
closeRenderLoopLatch,
clusterPointCollection,
commandExtents,
creditDisplayContents,
defaultView,
@@ -43,7 +42,6 @@ test('every private field the app reaches is still declared by the installed Ces
[ENGINE, 'Scene/Picking.js', '_pickOffscreenView'],
[ENGINE, 'Scene/View.js', '_commandExtents'],
[ENGINE, 'Scene/Billboard.js', '_billboardCollection'],
[ENGINE, 'DataSources/EntityCluster.js', '_clusterPointCollection'],
[ENGINE, 'Widget/CesiumWidget.js', '_renderLoopRunning'],
[WIDGETS, 'Viewer/Viewer.js', '_cesiumWidget'],
[ENGINE, 'Renderer/Context.js', '_gl'],
@@ -125,11 +123,6 @@ test('the helpers read and write exactly those fields', () => {
billboardCollectionOf({ _billboardCollection: collection }),
collection,
);
assert.equal(
clusterPointCollection({ _clusterPointCollection: collection }),
collection,
);
assert.equal(clusterPointCollection(undefined), null);
const widget = { _renderLoopRunning: true };
closeRenderLoopLatch({ _cesiumWidget: widget });
assert.equal(widget._renderLoopRunning, false);
-1
View File
@@ -15,7 +15,6 @@
"src/layers/launches/launchPad.js",
"src/layers/launches/orbitRendering.js",
"src/layers/launches/rendering.js",
"src/layers/radio/rendering.js",
"src/layers/recentImagery/rendering.js",
"src/layers/satellites/rendering.js",
"src/layers/traffic/rendering.js",
+3
View File
@@ -92,6 +92,9 @@ const DRAW_FROM_CALLER = new Set([
// Its heat cells and fire glows draw through `drawOf`; its cards and LOD
// watcher read the eye, projection and frames through the ports.
'./layers/firms',
// Its station dots, clusters and selected marker draw through `drawOf`;
// it clusters them on screen through the camera and query ports.
'./layers/radio',
// Its data packs draw through `drawOf`; its flights ask `cameraOf`, which
// throws until then too.
'./scenes',