Read vessel, CCTV and FIRMS billboard state from the app's mirror

The three layers now add their billboards through addBillboard and write
the mirrored fields through setBillboard, so selection, cards, queries,
focus, view thinning and the FIRMS horizon cull read what was pushed from
the app instead of from Cesium. Vessels and FIRMS state their sprites' own
sizes (32 px ship artwork, the glow canvas at twice the core size), which
the mirror needs. A vessel helper, iconPosition, replaces the repeated
mirror-or-visual position lookups, and the vessel visibility pass writes
show only when it changes, as CCTV and FIRMS already did.

A billboard never given a position now has none in the mirror rather than
the origin.
This commit is contained in:
Sameh Khamis committed 2026-11-03 11:14:33 -08:00
1 parent bb91688a62
commit 6639c4bb80
23 files changed
+152 -97

No files matched your search

+2 -1
View File
@@ -16,6 +16,7 @@ import {
poseHash,
requiredPlaneLift,
} from '../../data/cctvFootprint.js';
import { setBillboard } from '../../data/billboardMirror.js';
export function createGeometry({ state: layerState, services, parts, source }) {
const { warmGroundFloor, cachedGroundFloor } = services.ground;
@@ -347,7 +348,7 @@ export function createGeometry({ state: layerState, services, parts, source }) {
record.position = positions.mount;
record.camera.absoluteHeightM = geometry.mount.alt;
if (record.billboard) {
record.billboard.position = positions.mount;
setBillboard(record.billboard, 'position', positions.mount);
}
if (record.coverageEntities?.length >= 5) {
record.coverageEntities[0].polyline.positions = [
+3 -1
View File
@@ -4,6 +4,7 @@ import {
planeSupportPoints,
poseHash,
} from '../../data/cctvFootprint.js';
import { setBillboard } from '../../data/billboardMirror.js';
/** Cooldown before a provisional (geoid-fallback / partial) footprint is retried. */
const FOOTPRINT_RETRY_MS = 60_000;
@@ -238,7 +239,8 @@ export function createGround({ state: layerState, services, parts, source }) {
undefined,
record.position,
);
if (record.billboard) record.billboard.position = record.position;
if (record.billboard)
setBillboard(record.billboard, 'position', record.position);
moved += 1;
}
continue;
+2 -1
View File
@@ -12,6 +12,7 @@ import {
VIEW_MOTION_MIN_TURN_DEG,
VIEW_MOTION_COST_FACTOR,
} from './policy.js';
import { addBillboard } from '../../data/billboardMirror.js';
const MIN_TURN_COS = Math.cos((VIEW_MOTION_MIN_TURN_DEG * Math.PI) / 180);
@@ -237,7 +238,7 @@ export function createLifecycle({
camera.lat,
camera.absoluteHeightM,
);
const billboard = layerState._billboards.add({
const billboard = addBillboard(layerState._billboards, {
id: camera.id,
image: CAMERA_ICON,
position,
+11 -7
View File
@@ -14,6 +14,7 @@ import {
VIEW_ICON_MARGIN,
VIEW_MIN_CELL_M,
} from './policy.js';
import { billboardState, setBillboard } from '../../data/billboardMirror.js';
/** FNV-1a over a camera id: a stable, well-spread order for crowded cells. */
function idHash(id) {
@@ -110,19 +111,20 @@ export function createRendering({
for (const record of records || []) {
const bb = record.billboard;
if (!bb) continue;
const position = bb.position;
const icon = billboardState(bb);
const position = icon.position;
// CCTV never publishes a tracked focus target, so every icon is ambient.
const focus = advanceSpriteFocus(bb, {
// Keep hidden icons in the state/release pass so the active count cannot
// drop while a stale dim alpha remains waiting to reappear.
screenPosition:
bb.show === false || !position ? null : screenPositionFor(position),
icon.show === false || !position ? null : screenPositionFor(position),
cameraDistance: position ? cameraDistanceFor(position) : Number.NaN,
nowMs,
target,
params,
spriteHalfWidthPx: (bb.width || 24) * (bb.scale || 1) * 0.5,
spriteHalfHeightPx: (bb.height || 24) * (bb.scale || 1) * 0.5,
spriteHalfWidthPx: (icon.width || 24) * (icon.scale || 1) * 0.5,
spriteHalfHeightPx: (icon.height || 24) * (icon.scale || 1) * 0.5,
});
transitioning ||= focus.transitioning;
if (focus.active) activeCount += 1;
@@ -200,7 +202,7 @@ export function createRendering({
const shown = [];
const cells = new Map();
for (const record of layerState._records) {
const position = record.billboard?.position;
const position = billboardState(record.billboard)?.position;
if (!position) continue;
const vx = position.x * inverseRadii.x - cx;
const vy = position.y * inverseRadii.y - cy;
@@ -245,7 +247,8 @@ export function createRendering({
const bb = record.billboard;
if (!bb) continue;
const visible = record.viewPass === pass;
if (bb.show !== visible) bb.show = visible;
if (billboardState(bb).show !== visible)
setBillboard(bb, 'show', visible);
}
const previous = layerState._viewRecords;
const changed =
@@ -397,7 +400,8 @@ export function createRendering({
if (!Cesium.Color.equals(record.billboard.color, color))
record.billboard.color = color;
const scale = isActive ? 1.25 : 1.0;
if (record.billboard.scale !== scale) record.billboard.scale = scale;
if (billboardState(record.billboard).scale !== scale)
setBillboard(record.billboard, 'scale', scale);
// disableDepthTestDistance stays POSITIVE_INFINITY for every billboard
// (set at creation) — see the field-test far-zoom submerge fix there.
}
+2 -1
View File
@@ -11,6 +11,7 @@ import {
LIVE_CAMERA_COLOR,
} from './policy.js';
import { isVideoFeedType } from '../../sources/cctvTypes.js';
import { mirrorBillboard } from '../../data/billboardMirror.js';
const FOCUS_FACTOR = 0.5;
@@ -29,7 +30,7 @@ test('focus de-emphasis fades each icon from its own color', () => {
camera: { id, feedType },
// No position, so the pass skips screen projection; the focus stub below
// decides the factor on its own.
billboard: { show: true },
billboard: mirrorBillboard({ show: true }),
});
const idleVideo = record('idle-hls', 'hls');
const idleStill = record('idle-image', 'image');