Files
gods-eye-view/src/layers/cctv/ingestion.js
T
Sameh Khamis 1d08043bf9 Draw CCTV camera icons through the renderer ports and take rendering.js off the Cesium list
The camera icons are now a draw-port icon set kept by an icon book; only
icons a view pass or restyle changes are written, in one write per pass.
Picks read the renderer's hit, the view pass and focus pass project
through the camera pose (geo/frustum.js poseProjector, matching the
renderer's projection and near clip) and the query port, and tile
readiness for ground sampling comes from the globe port.
2026-11-08 09:38:24 -08:00

58 lines
2.3 KiB
JavaScript

export function createIngestion({
state: layerState,
services,
parts,
source,
}) {
const methods = {
/**
* Periodic update tick: syncs health state and runs auto-hop logic. Ground
* geometry is NOT resampled here — v2 grounds each camera once via the
* staggered load queue (see startGeometryLoadQueue/updateRecordGeometry)
* and never resamples on a timer. The ONE exception is a one-shot
* completion pass: the enable-time drain can run while 3D tiles are still
* streaming (each such pass keeps the fabricated catalog height and leaves
* the record `!groundResolved`), so the FIRST tick that sees
* projectionTilesReady() re-enqueues those records once — each then takes
* its single real sample and freezes (design §4). Guarded by a boolean
* latch (`_tilesReadyReenqueued`), NOT a timer loop: after it fires, no
* tick ever samples anything again.
*/
async update() {
if (!layerState._enabled) return;
const now = Date.now();
layerState._lastUpdate = now;
if (
!layerState._tilesReadyReenqueued &&
parts.model.projectionTilesReady()
) {
layerState._tilesReadyReenqueued = true;
// Per-regime resolution (Task 5): only records unresolved for the
// CURRENT surface regime need the completion pass. On globe stacks
// projectionTilesReady() is false (only drawn photoreal tiles can be
// ready), so this latch fires for the google-3d regime alone —
// terrain-globe records resolve from the prior in their drain pass.
const unresolved = parts.geometryQueue
.geometryWorkingSet()
.filter(
(record) =>
!parts.ground.isGroundResolved(record) &&
parts.geometryQueue.withinViewBudget(record),
);
if (unresolved.length)
parts.geometryQueue.enqueueGeometryRefresh(unresolved);
}
await parts.health.syncHealthState();
// New health can change which camera wins a crowded cell.
if (layerState._enabled && parts.rendering.refreshHorizonCulling()) {
parts.geometryQueue.enqueueViewGeometry();
parts.cards.refreshAmbientCards();
}
parts.navigation.maybeAutoHop(now);
parts.presentation.notifyListeners();
},
};
return { methods };
}