Keep the satellites layer's Cesium objects in its rendering part

The point collection and its dots, the baked orbit rings, the tracked
entity, the frame number, the focus publish and the pick decoding now
live in rendering.js, behind small helpers that take ECEF positions and
render-contract colours. The catalog, controls, ingestion, lifecycle,
orbits, policy, records, state, testing and tracking parts no longer
import Cesium or touch the viewer, scene or primitives, and leave the
allow-list. Point styles are [r, g, b, a] colours, converted once per
style; geodetic conversions use the geo helpers; the per-frame tick runs
through the frame port. What the layer draws and how it follows is
unchanged.
This commit is contained in:
Sameh Khamis committed 2026-11-07 03:53:05 -08:00
1 parent d928c30337
commit 4fd1a850f1
19 files changed
+646 -281

No files matched your search

+27 -31
View File
@@ -1,4 +1,4 @@
import * as Cesium from 'cesium';
import { frameOf } from '../../render/rendererOf.js';
import { ISS_OVERLAY_SOURCE_ID } from './policy.js';
export function createLifecycle({
@@ -11,10 +11,17 @@ export function createLifecycle({
const { holdContinuousRender, releaseContinuousRender } = services.render;
const { registerPickOwner, unregisterPickOwner } = services.picking;
/** Run the shared per-frame tick before each frame draws. */
function onEachFrame(frame) {
return frame.on('preRender', () => parts.rendering._preRenderTick());
}
const methods = {
// Catalog data refresh; propagation remains preRender-owned.
async init(viewer) {
// Asked first: a viewer without one fails before anything is built.
const frame = frameOf(viewer);
parts.catalog._abortActiveUpdates();
clearFocusTarget('satellites');
layerState._viewer = viewer;
@@ -47,17 +54,14 @@ export function createLifecycle({
layerState._denseError = null;
layerState._catalogRevision++;
// Point primitives for satellite dots
layerState._pointCollection = new Cesium.PointPrimitiveCollection();
viewer.scene.primitives.add(layerState._pointCollection);
// The collection the satellite dots draw in
parts.rendering._attach(viewer);
parts.interaction._installClickHandler(viewer);
// Pre-render listener for real-time position updates
// (fleet propagation + tracked per-frame dot + orbit ring GMST rotation)
layerState._preRenderListener = viewer.scene.preRender.addEventListener(
parts.rendering._preRenderTick,
);
layerState._preRenderListener = onEachFrame(frame);
console.log('[Data:Satellites] Initialized');
},
@@ -65,18 +69,19 @@ export function createLifecycle({
enable(viewer) {
layerState._enabled = true;
holdContinuousRender('satellites'); // per-frame animator (perf wave 2)
if (layerState._pointCollection)
layerState._pointCollection.show =
parts.controls.satelliteVisualsVisible(
layerState._enabled,
layerState._params.showPoints,
);
// Orbit ring primitives + persistent ISS host label — show them
for (const path of layerState._orbitPaths.values())
path.primitive.show = parts.controls.satelliteVisualsVisible(
parts.rendering._setPointsShown(
parts.controls.satelliteVisualsVisible(
layerState._enabled,
layerState._params.showPoints,
),
);
// Orbit rings + persistent ISS host label — show them
parts.rendering._setOrbitPathsShown(
parts.controls.satelliteVisualsVisible(
layerState._enabled,
layerState._params.showOrbits,
);
),
);
parts.labels._syncIssOverlay();
// Re-attach input handlers and preRender propagation
parts.interaction._installClickHandler(viewer);
@@ -87,9 +92,7 @@ export function createLifecycle({
return Number.isFinite(norad) && layerState._points.has(norad);
});
if (!layerState._preRenderListener && viewer) {
layerState._preRenderListener = viewer.scene.preRender.addEventListener(
parts.rendering._preRenderTick,
);
layerState._preRenderListener = onEachFrame(frameOf(viewer));
}
parts.tracking._applyPendingTrackingRestore();
},
@@ -99,9 +102,8 @@ export function createLifecycle({
parts.tracking._cancelPendingTrackingRestore();
layerState._enabled = false;
releaseContinuousRender('satellites');
if (layerState._pointCollection) layerState._pointCollection.show = false;
for (const path of layerState._orbitPaths.values())
path.primitive.show = false;
parts.rendering._setPointsShown(false);
parts.rendering._setOrbitPathsShown(false);
parts.tracking._clearTracking();
parts.labels._syncIssOverlay();
// Remove click handler + keydown listener + preRender propagation while disabled
@@ -139,14 +141,8 @@ export function createLifecycle({
}
layerState._overlayHost.clearSource(ISS_OVERLAY_SOURCE_ID);
layerState._overlayHost.setVisible(ISS_OVERLAY_SOURCE_ID, false);
if (layerState._pointCollection) {
viewer.scene.primitives.remove(layerState._pointCollection);
layerState._pointCollection = null;
}
// Orbit ring primitives are removed (and destroyed) here
for (const path of layerState._orbitPaths.values()) {
viewer.scene.primitives.remove(path.primitive);
}
// The dots' collection and the orbit rings go (and are destroyed)
parts.rendering._detach(viewer);
layerState._points.clear();
layerState._detectionObjects.clear();
layerState._orbitPaths.clear();