refactor(launches): Cesium rendering behind a renderer interface

This commit is contained in:
German Khokhlov committed 2026-10-23 00:32:10 +04:00
1 parent 1839d62160
commit 4baefeb8f9
31 files changed
+1202 -420

No files matched your search

+17 -1
View File
@@ -8,6 +8,7 @@
// military:synthetic[:count] readsb rows, `count` aircraft (1 000); the
// first 25 are also synthetic civil flights
// vessels:fixture 12 000 AIS rows, or those within an area
// launches:fixture three LL2 missions; also supplies the satellite dependency
// satellites:fixture 839 core TLEs + 6000 dense points
// local-adsb:fixture the local receivers' answer (server format,
// /api/local-receivers/aircraft): 40 aircraft
@@ -24,6 +25,8 @@ import {
syntheticMilitary,
syntheticVessels,
} from '../../bench/w1Feeds.js';
import { launchFixture } from '../../bench/launchFixture.js';
import { createLaunchSource } from '../../layers/launches/source.js';
import { satelliteFixture } from '../../bench/satelliteFixture.js';
import { createSatelliteSource } from '../../layers/satellites/source.js';
import { createLocalReceiverFeeds } from '../../layers/localAdsb/feeds.js';
@@ -33,6 +36,7 @@ const KINDS = Object.freeze({
military: new Set(['synthetic']),
vessels: new Set(['fixture']),
satellites: new Set(['fixture']),
launches: new Set(['fixture']),
'local-adsb': new Set(['fixture']),
});
@@ -48,7 +52,7 @@ export function parseQaFeed(search = '') {
(count !== null && !(Number.isInteger(count) && count > 0))
)
throw new TypeError(
`qaFeed: unknown entry "${item}" (flights:synthetic[:count], military:synthetic[:count], vessels:fixture, satellites:fixture, local-adsb:fixture)`,
`qaFeed: unknown entry "${item}" (flights:synthetic[:count], military:synthetic[:count], vessels:fixture, satellites:fixture, launches:fixture, local-adsb:fixture)`,
);
return { layer, kind, count };
});
@@ -64,6 +68,18 @@ const json = (payload) =>
export function createQaSources(entries, { now = () => Date.now() } = {}) {
const sources = {};
for (const { layer, count } of entries) {
if (layer === 'launches') {
sources.launches = createLaunchSource({
fetchImpl: async (url) =>
String(url).includes('/celestrak/')
? new Response(satelliteFixture('stations'))
: json(launchFixture()),
});
sources.satellites ??= createSatelliteSource({
fetchImpl: async (url) =>
new Response(satelliteFixture(String(url).split('/').at(-1))),
});
}
if (layer === 'satellites')
sources.satellites = createSatelliteSource({
fetchImpl: async (url) =>
+2
View File
@@ -1,3 +1,4 @@
import { createLaunchesCesiumRenderer } from '../../layers/launches/render/cesium.js';
// Which engine draws which layer: the layer renderer registry (plan, "layer
// renderer interface") and the layer availability API built on it.
//
@@ -88,6 +89,7 @@ export const layerAvailableOn = (layerId, engineKind) =>
/** Cesium renderers extracted from their layers (render/cesium.js). */
export const CESIUM_LAYER_RENDERERS = Object.freeze({
'rocket-launches': createLaunchesCesiumRenderer,
satellites: createSatellitesCesiumRenderer,
flights: createFlightsCesiumRenderer,
military: createMilitaryCesiumRenderer,
+2 -1
View File
@@ -56,8 +56,9 @@ test('the default registry: every layer on Cesium, none yet on Navara', () => {
}
});
test('the aircraft, vessels and satellites have extracted Cesium renderers; the others still draw themselves', () => {
test('the aircraft, vessels, satellites and launches have extracted Cesium renderers; the others still draw themselves', () => {
assert.deepEqual(Object.keys(CESIUM_LAYER_RENDERERS), [
'rocket-launches',
'satellites',
'flights',
'military',
+13 -2
View File
@@ -1,12 +1,23 @@
import { rendererFor } from './renderers.js';
import { createLaunchesCesiumRenderer } from '../../layers/launches/render/cesium.js';
import { createRocketLaunchesLayer } from '../../layers/launches/index.js';
import * as geometry from '../../celestialRing.js';
import * as overlays from '../../overlays/worldOverlay.js';
import * as render from '../../renderGovernor.js';
/** Construct one layer using the application scene owners and a supplied source. */
export function createApplicationLaunches({ source, satellites }) {
export function createApplicationLaunches({
source,
satellites,
renderer = {
create: ({ engine = null, ...options }) =>
engine
? rendererFor('rocket-launches', engine, options)
: createLaunchesCesiumRenderer(null, options),
},
}) {
return createRocketLaunchesLayer({
source,
services: { satellites, geometry, overlays, render },
services: { satellites, geometry, overlays, render, renderer },
});
}