Take the launches lifecycle off Cesium

The layer's entity data source is now created and removed by the
rendering part, which owns the entities and stays on Cesium: the replay
vehicle and the live payload move every frame, the selected site is the
viewer's selected entity, and the orbits draw with their own materials.
The hover keeps its pending pointer position as a plain point.

Lifecycle leaves the allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 22:57:55 -08:00
1 parent e2dea507b9
commit db2c579265
4 files changed
+42 -13

No files matched your search

+11
View File
@@ -112,6 +112,17 @@ async function fixture({ legacySource = false } = {}) {
destroyLaunchPadZonePrimitive: noop, destroyLaunchPadZonePrimitive: noop,
}, },
rendering: { rendering: {
// As the rendering part owns the entities' data source.
attach(target) {
state._dataSource = new Cesium.CustomDataSource('rocket-launches');
state._dataSource.show = false;
target.dataSources.add(state._dataSource);
},
detach(target) {
if (state._dataSource)
target.dataSources.remove(state._dataSource, true);
state._dataSource = null;
},
updateMissionFrame: noop, updateMissionFrame: noop,
addLaunchEntity(record) { addLaunchEntity(record) {
state._dataSource.entities.add({ state._dataSource.entities.add({
+11 -12
View File
@@ -1,4 +1,3 @@
import * as Cesium from 'cesium';
import { isPointerFree } from '../../data/inputOwnership.js'; import { isPointerFree } from '../../data/inputOwnership.js';
import { inputFor } from '../../input/dispatcher.js'; import { inputFor } from '../../input/dispatcher.js';
@@ -91,11 +90,15 @@ export function createLaunchHover({
const at = now(); const at = now();
const wait = HOVER_PICK_INTERVAL_MS - (at - lastPick); const wait = HOVER_PICK_INTERVAL_MS - (at - lastPick);
if (wait > 0) { if (wait > 0) {
// Cesium reuses the movement object, so keep a copy of the position. // The input source may reuse the movement object, so keep a copy of
pendingPosition = Cesium.Cartesian2.clone( // the position.
movement.endPosition, const end = movement.endPosition;
pendingPosition ?? undefined, if (end == null) pendingPosition = undefined;
); else {
pendingPosition ??= { x: 0, y: 0 };
pendingPosition.x = end.x;
pendingPosition.y = end.y;
}
if (trailingTimer === null) trailingTimer = setTimer(trailing, wait); if (trailingTimer === null) trailingTimer = setTimer(trailing, wait);
return; return;
} }
@@ -127,9 +130,7 @@ export function createLifecycle({
layerState._enabled = false; layerState._enabled = false;
parts.panel.createMissionPanel(); parts.panel.createMissionPanel();
parts.overlays.createReplayVehicleOverlay(); parts.overlays.createReplayVehicleOverlay();
layerState._dataSource = new Cesium.CustomDataSource('rocket-launches'); parts.rendering.attach(viewer);
layerState._dataSource.show = false;
viewer.dataSources.add(layerState._dataSource);
layerState._count = 0; layerState._count = 0;
layerState._lastUpdate = null; layerState._lastUpdate = null;
layerState._stale = false; layerState._stale = false;
@@ -256,9 +257,7 @@ export function createLifecycle({
layerState._replayTracks.clear(); layerState._replayTracks.clear();
parts.panel.clearMissionPanel(); parts.panel.clearMissionPanel();
layerState._viewer = null; layerState._viewer = null;
if (layerState._dataSource) parts.rendering.detach(viewer);
viewer.dataSources.remove(layerState._dataSource, true);
layerState._dataSource = null;
layerState._count = 0; layerState._count = 0;
layerState._orbitMatches = 0; layerState._orbitMatches = 0;
layerState._lastUpdate = null; layerState._lastUpdate = null;
+20
View File
@@ -37,6 +37,24 @@ export function createRendering({
if (current !== next) graphic.show = next; if (current !== next) graphic.show = next;
} }
/**
* The layer's entities, hidden until enabled. They stay entities: the
* replay vehicle and the live payload move every frame, the selected site
* is the viewer's selected entity, and the orbits draw with their own
* materials.
*/
function attach(viewer) {
layerState._dataSource = new Cesium.CustomDataSource('rocket-launches');
layerState._dataSource.show = false;
viewer.dataSources.add(layerState._dataSource);
}
function detach(viewer) {
if (layerState._dataSource)
viewer.dataSources.remove(layerState._dataSource, true);
layerState._dataSource = null;
}
/** Make a launch's site marker the viewer's selected entity, or none. */ /** Make a launch's site marker the viewer's selected entity, or none. */
function selectLaunchEntity(launchId) { function selectLaunchEntity(launchId) {
const viewer = layerState._viewer; const viewer = layerState._viewer;
@@ -626,6 +644,8 @@ export function createRendering({
} }
} }
return { return {
attach,
detach,
setGraphicVisibility, setGraphicVisibility,
selectLaunchEntity, selectLaunchEntity,
isolateMission, isolateMission,
-1
View File
@@ -75,7 +75,6 @@
"src/layers/installations/namedMarkers.js", "src/layers/installations/namedMarkers.js",
"src/layers/installations/rendering.js", "src/layers/installations/rendering.js",
"src/layers/launches/launchPad.js", "src/layers/launches/launchPad.js",
"src/layers/launches/lifecycle.js",
"src/layers/launches/orbitRendering.js", "src/layers/launches/orbitRendering.js",
"src/layers/launches/overlays.js", "src/layers/launches/overlays.js",
"src/layers/launches/rendering.js", "src/layers/launches/rendering.js",