Move the flights and military layers onto the renderer ports

The flights and military layers now reach the renderer only through its
ports: motion, queries, state, tracking, enrichment, evidence and policy
read the camera pose, project through the query port, request and
suspend frames through the frame port, and key per-frame caches on the
frames drawn rather than the scene's frame number. Policy is plain data,
the enrichment view test is pose-based, and the tracked aircraft is an
icon in a draw-port set with a plain holder standing in for the entity
that Cockpit, the tracked card and share links read.

The mesh floor sampler can sample through the query port, excluding
named draw sets, and both layers use it that way. A pick of another
layer's tracked icon is never taken for one of a layer's own contacts.

Twelve layer files leave the Cesium allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-07 18:49:23 -08:00
1 parent 00a0a0dbc7
commit 23d56f8393
40 files changed
+1638 -908

No files matched your search

+18 -24
View File
@@ -1,6 +1,8 @@
import { classifyAircraft } from '../../data/aircraftClass.js';
import { horizonOccluder } from '../../data/iconOrientation.js';
import * as Cesium from 'cesium';
import { findCamera } from '../../render/rendererOf.js';
import { frustumPlanes, sphereOutside } from '../../geo/frustum.js';
import { horizonFrom } from '../../geo/horizon.js';
import { distanceSquared, vec } from '../../geo/vector.js';
import {
ENRICH_MAX_INFLIGHT,
ENRICH_DISPATCH_GAP_MS,
@@ -10,6 +12,9 @@ import {
ENRICH_AMBIENT_PER_SWEEP,
} from './policy.js';
/** A contact counts as on screen while a sphere this big around it is (m). */
const AMBIENT_CULL_RADIUS_M = 1;
export function createEnrichment({
flightState,
services,
@@ -183,14 +188,14 @@ export function createEnrichment({
)
return;
try {
const camera = flightState._viewer.camera;
const camPos = camera.positionWC;
const occluder = horizonOccluder(camera);
const cull = camera.frustum.computeCullingVolume(
camPos,
camera.directionWC,
camera.upWC,
);
// What is on screen, from the camera's pose: past the limb or outside
// the view frustum is not looked at.
const pose = findCamera(flightState._viewer)?.pose();
if (!pose) return;
const camPos = pose.position;
const occluder = horizonFrom(camPos);
const planes = frustumPlanes(pose);
const position = vec();
const cand = [];
const icons = flightState._icons;
const t = parts.icons._displayMs();
@@ -198,21 +203,10 @@ export function createEnrichment({
if (flightState._enrichSeen.has(`t:${icao24}`)) continue; // answered / queued / negative this session
if (!/^[0-9a-f]{6}$/i.test(icao24)) continue; // adsbdb keys are 6-char hex only
if (flightState.records.data.get(icao24)?.onGround) continue; // ground traffic never spends ambient budget (click-to-enrich still works)
const position = icons.position(
icao24,
t,
flightState._scratchModelBS.center,
);
if (!icons.position(icao24, t, position)) continue;
if (!occluder.isPointVisible(position)) continue; // beyond the limb
if (
cull.computeVisibility(flightState._scratchModelBS) ===
Cesium.Intersect.OUTSIDE
)
continue; // off-screen
cand.push([
icao24,
Cesium.Cartesian3.distanceSquared(camPos, position),
]);
if (sphereOutside(planes, position, AMBIENT_CULL_RADIUS_M)) continue; // off-screen
cand.push([icao24, distanceSquared(camPos, position)]);
}
cand.sort((a, b) => a[1] - b[1]); // nearest first — what the user is looking at resolves first
const n = Math.min(