Draw the aircraft family, Wildlife Sightings and the Cockpit through the contract

The layers that still had one Cesium and one Navara implementation, or
drew on Cesium only, now draw through engine.movers, engine.lines and
engine.camera on both engines, and application code holds the engine
instead of guessing it from a viewer.

- Aircraft family: flights, military and local ADS-B share one display
  (src/layers/aircraft/render/display.js). The Cesium and Navara
  renderers are gone. Where they differed, the display follows Cesium:
  - attach and visibility tracking, live disableDepthTestDistance
    changes, the tracked glyph's distance scale, model ids that change,
    local ADS-B markers hidden until shown and its UAT ring as a point;
  - the trail head's hidden alpha is 0.45, the contract's
    depthFailAlpha scaled by the head's 0.9.
  The tracked glyph stays over the fleet, as on Navara. The movers
  contract reports readiness per model and reads model axes as the
  glTF's own on every engine. Cesium's follow takes any native target
  through a proxy entity in the ENU frame and mirrors its readout fields.
- Wildlife Sightings draws badges and the density glow as sprite sets
  and its privacy cells as line outlines (no fill yet). It takes clicks
  from engine.input and its card anchors to the engine's canvas and
  camera, so the layer is in both engines' catalogs again and a switch
  keeps the session's layer set.
- Cockpit: cockpitHost takes the engine only. The ridden aircraft is the
  engine follow's target, hidden through its sprite; only the Cesium
  Viewer's stock double-click is still routed around.
- About forty camera, navigation, share-link, HUD, voice, detection and
  layer-lifecycle callers take the engine. isGlobeEngine and
  engineFromViewer calls outside src/globe fall from 51 to 14.

The coupling baseline drops accordingly: layer renderer lines from
5239/12331 to 4546/11106 (Cesium/Navara), `viewer` lines from 2424 to
2209, Cesium-importing files from 69 to 66.
This commit is contained in:
German Khokhlov committed 2026-11-07 02:34:34 +04:00
1 parent 48988015f1
commit 35e70ec280
145 files changed
+4716 -4212

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ export function createApplicationBikeshare({ source }) {
rendererFactory: ({ engine, ...context }) =>
engine?.kind === 'navara'
? rendererFor('bikeshare', engine, context)
: createBikeshareCesiumRenderer(context),
: createBikeshareCesiumRenderer({ ...context, engine }),
services: { render, sprites, picking, overlays },
});
}
+4 -8
View File
@@ -4,7 +4,6 @@ import * as selection from '../../data/selectionDispatcher.js';
import * as aircraftPresentation from '../../data/tr3bRegistry.js';
import * as trackedCamera from '../../data/trackedCamera.js';
import { rendererFor } from './renderers.js';
import { createFlightsCesiumRenderer } from '../../layers/flights/render/cesium.js';
import * as labels from '../../data/detectionDraw.js';
import * as geoid from '../../data/geoid.js';
import * as focus from '../../data/focusDeemphasis.js';
@@ -20,12 +19,10 @@ export function createApplicationFlights({
militaryRegistry,
resolveAsset = (url) =>
`${import.meta.env?.BASE_URL || '/'}${url.replace(/^\//, '')}`,
// Test seam: the renderer factory (default: the engine's, from the registry).
// Test seam: the renderer factory (default: the engine's, from the
// registry: the flights display on every engine).
renderer = {
create: ({ viewer, engine = null, adopt }) =>
engine
? rendererFor('flights', engine, { viewer, adopt })
: createFlightsCesiumRenderer(null, { viewer, adopt }),
create: ({ engine = null } = {}) => rendererFor('flights', engine),
},
}) {
const { groundFloor, meshFloor, groundSnap } = surface;
@@ -35,8 +32,7 @@ export function createApplicationFlights({
services: {
picking,
selection,
// The engine's flights renderer from the registry (render/cesium.js on
// Cesium); a bare viewer without an engine (unit tests) draws on Cesium.
// The engine's flights renderer from the registry (render/display.js).
renderer,
aircraftPresentation,
camera: trackedCamera,
+4 -11
View File
@@ -6,8 +6,6 @@ import * as context from '../../data/contextStore.js';
import * as picking from '../../data/pickRegistry.js';
import * as selection from '../../data/selectionDispatcher.js';
import { rendererFor } from './renderers.js';
import { createLocalAdsbCesiumRenderer } from '../../layers/localAdsb/render/cesium.js';
import * as trails from '../../data/trailRenderer.js';
import * as geoid from '../../data/geoid.js';
import { markDetectionSourcesChanged } from '../../data/detection.js';
import { refreshTrackedReadout } from '../../data/trackedReadout.js';
@@ -30,12 +28,10 @@ export function createApplicationLocalAdsb({
displayParams = null,
resolveAsset = (url) =>
`${import.meta.env?.BASE_URL || '/'}${url.replace(/^\//, '')}`,
// Test seam: the renderer factory (default: the engine's, from the registry).
// Test seam: the renderer factory (default: the engine's, from the
// registry: the Local ADS-B display on every engine).
renderer = {
create: ({ engine = null, ...options }) =>
engine
? rendererFor('local-adsb', engine, options)
: createLocalAdsbCesiumRenderer(null, options),
create: ({ engine = null } = {}) => rendererFor('local-adsb', engine),
},
} = {}) {
return createLocalAdsbLayer({
@@ -47,11 +43,8 @@ export function createApplicationLocalAdsb({
context,
picking,
selection,
// The engine's Local ADS-B renderer from the registry (render/cesium.js
// on Cesium); a bare viewer without an engine (unit tests) draws on
// Cesium.
// The engine's Local ADS-B renderer from the registry (render/display.js).
renderer,
trails,
geoid,
groundSnap: surface?.groundSnap || null,
enrichment,
+4 -9
View File
@@ -4,7 +4,6 @@ import * as selection from '../../data/selectionDispatcher.js';
import * as aircraftPresentation from '../../data/tr3bRegistry.js';
import * as trackedCamera from '../../data/trackedCamera.js';
import { rendererFor } from './renderers.js';
import { createMilitaryCesiumRenderer } from '../../layers/military/render/cesium.js';
import * as labels from '../../data/detectionDraw.js';
import * as geoid from '../../data/geoid.js';
import * as focus from '../../data/focusDeemphasis.js';
@@ -20,12 +19,10 @@ export function createApplicationMilitary({
militaryRegistry,
resolveAsset = (url) =>
`${import.meta.env?.BASE_URL || '/'}${url.replace(/^\//, '')}`,
// Test seam: the renderer factory (default: the engine's, from the registry).
// Test seam: the renderer factory (default: the engine's, from the
// registry: the military display on every engine).
renderer = {
create: ({ viewer, engine = null, adopt }) =>
engine
? rendererFor('military', engine, { viewer, adopt })
: createMilitaryCesiumRenderer(null, { viewer, adopt }),
create: ({ engine = null } = {}) => rendererFor('military', engine),
},
}) {
const { groundFloor, meshFloor, groundSnap } = surface;
@@ -35,9 +32,7 @@ export function createApplicationMilitary({
services: {
picking,
selection,
// The engine's military renderer from the registry (render/cesium.js
// on Cesium); a bare viewer without an engine (unit tests) draws on
// Cesium.
// The engine's military renderer from the registry (render/display.js).
renderer,
aircraftPresentation,
camera: trackedCamera,
+8 -7
View File
@@ -10,7 +10,8 @@ import { createLaunchesCesiumRenderer } from '../../layers/launches/render/cesiu
// availability API built on it.
//
// A renderer factory `(engine, options) => renderer` draws one layer on one
// engine kind (`render/cesium.js`, `render/navara.js` of a layer). Cesium
// engine kind (`render/cesium.js`, `render/navara.js` of a layer), or on
// every kind (its `render/display.js`, registered for each). Cesium
// layers without a render/cesium.js draw themselves: they are registered as
// CESIUM_BUILTIN. Cesium entries are registered here, statically (main
// chunk); Navara factories are registered by the Navara mode after its
@@ -32,9 +33,9 @@ import { createLaunchesCesiumRenderer } from '../../layers/launches/render/cesiu
// `availability` provider (`{ engine, unavailable() }` is the part it reads).
import { APPLICATION_LAYER_DIRECTORY } from './directory.js';
import { createFlightsCesiumRenderer } from '../../layers/flights/render/cesium.js';
import { createMilitaryCesiumRenderer } from '../../layers/military/render/cesium.js';
import { createLocalAdsbCesiumRenderer } from '../../layers/localAdsb/render/cesium.js';
import { createFlightsDisplay } from '../../layers/flights/render/display.js';
import { createMilitaryDisplay } from '../../layers/military/render/display.js';
import { createLocalAdsbDisplay } from '../../layers/localAdsb/render/display.js';
import { createSatellitesCesiumRenderer } from '../../layers/satellites/render/cesium.js';
import { createVesselsCesiumRenderer } from '../../layers/vessels/render/cesium.js';
@@ -107,9 +108,9 @@ export const CESIUM_LAYER_RENDERERS = Object.freeze({
'local-firms': createFirmsCesiumRenderer,
'rocket-launches': createLaunchesCesiumRenderer,
satellites: createSatellitesCesiumRenderer,
flights: createFlightsCesiumRenderer,
military: createMilitaryCesiumRenderer,
'local-adsb': createLocalAdsbCesiumRenderer,
flights: createFlightsDisplay,
military: createMilitaryDisplay,
'local-adsb': createLocalAdsbDisplay,
'ais-live-vessels': createVesselsCesiumRenderer,
});
+36 -7
View File
@@ -1,4 +1,5 @@
import test from 'node:test';
import { readFileSync } from 'node:fs';
import assert from 'node:assert/strict';
import {
CESIUM_BUILTIN,
@@ -9,6 +10,7 @@ import {
layerAvailableOn,
} from './renderers.js';
import { APPLICATION_LAYER_DIRECTORY } from './directory.js';
import { createFakeEngine } from '../../globe/testing/fakeEngine.js';
test('a registry knows which engine renders which layer', () => {
const registry = createRendererRegistry();
@@ -80,16 +82,43 @@ test('the aircraft, vessels, satellites, launches and earthquakes have extracted
},
);
assert.equal(vessels.kind, 'cesium');
const viewer = { scene: {}, camera: {} };
const renderer = rendererFor('flights', { kind: 'cesium' }, { viewer });
assert.equal(renderer.kind, 'cesium');
assert.equal(renderer.viewer, viewer);
const military = rendererFor('military', { kind: 'cesium' }, { viewer });
assert.equal(military.kind, 'cesium');
assert.equal(military.viewer, viewer);
assert.equal(rendererFor('satellites', { kind: 'cesium' }).kind, 'cesium');
});
test('the aircraft family draws through one display, the same factory on every engine', async () => {
const displays = {
flights: ['flights', 'createFlightsDisplay'],
military: ['military', 'createMilitaryDisplay'],
'local-adsb': ['localAdsb', 'createLocalAdsbDisplay'],
};
// The Navara mode registers the same modules' factories.
const navaraMode = readFileSync(
new URL('../navaraMode.js', import.meta.url),
'utf8',
);
const drawAtlas = async () => ({ canvas: {}, cells: {} });
for (const [id, [directory, name]] of Object.entries(displays)) {
const factory = (
await import(`../../layers/${directory}/render/display.js`)
)[name];
assert.equal(CESIUM_LAYER_RENDERERS[id], factory, id);
assert.match(
navaraMode,
new RegExp(
`'?${id}'?: async \\(\\) =>\\s*\\(await import\\('[^']+/render/display\\.js'\\)\\)\\s*\\.${name}\\b`,
),
id,
);
for (const kind of ['cesium', 'navara']) {
const engine = createFakeEngine({ kind });
const display = factory(engine, { drawAtlas });
assert.equal(display.engine, engine, `${id} on ${kind}`);
display.destroy();
engine.destroy();
}
}
});
test('the layer availability API: engine, isAvailable, available, unavailable', () => {
const registry = createRendererRegistry();
registry.register('navara', { flights: () => ({}) });
+1 -1
View File
@@ -30,7 +30,7 @@ export function createApplicationTransit({
rendererFactory = ({ engine, ...context }) =>
engine?.kind === 'navara'
? rendererFor('transit', engine, context)
: createTransitCesiumRenderer(context),
: createTransitCesiumRenderer({ ...context, engine }),
}) {
if (!surface?.groundFloor || !surface?.meshFloor)
throw new TypeError('Transit needs the application surface services');
+1 -6
View File
@@ -1,14 +1,12 @@
import * as Cesium from 'cesium';
import { createWildlifeSightingsLayer } from '../../layers/wildlifeSightings/index.js';
import * as picking from '../../data/pickRegistry.js';
import * as overlays from '../../overlays/worldOverlay.js';
import * as sprites from '../../data/spriteOrder.js';
import * as render from '../../renderGovernor.js';
import * as context from '../../data/contextStore.js';
import * as focus from '../../worldFocus.js';
import { isPointerFree } from '../../data/inputOwnership.js';
/** Bind the wildlife layer to the application's scene and selection owners. */
/** Bind the wildlife layer to the application's selection and overlay owners. */
export function createApplicationWildlifeSightings(options) {
return createWildlifeSightingsLayer({
overlayHost: {
@@ -17,11 +15,8 @@ export function createApplicationWildlifeSightings(options) {
clearSource: overlays.clearOverlaySource,
hitTest: overlays.hitTestWorldOverlay,
},
screenSpaceEventHandlerFactory: (viewer) =>
new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas),
picking,
pointer: { isPointerFree },
sprites,
render,
context,
focus,