Preserve radio playback and imagery comparisons when switching planets

This commit is contained in:
German Khokhlov committed 2026-11-03 04:16:00 +04:00
1 parent b98cbeebf2
commit b01f1ee7dc
9 files changed
+246 -18

No files matched your search

+24 -4
View File
@@ -17,6 +17,15 @@ export function createLifecycle({
const methods = {
/** Initialize scene resources and the single audio element. */
init(viewer, options = {}) {
this.attachRenderer(viewer, options);
layerState._sessionGeneration += 1;
parts.clustering.resetRadioClusterOverlayIdentities();
parts.playback.installAudio();
clearOverlaySource(RADIO_OVERLAY_SOURCE_ID);
setOverlaySourceVisible(RADIO_OVERLAY_SOURCE_ID, false);
},
attachRenderer(viewer, options = {}) {
if (parts.renderer?.ready)
throw new Error('Radio layer is already initialized');
if (typeof rendererFactory !== 'function')
@@ -29,11 +38,22 @@ export function createLifecycle({
engine: options.engine,
});
parts.renderer.init(viewer, options);
layerState._sessionGeneration += 1;
parts.clustering.resetRadioClusterOverlayIdentities();
parts.playback.installAudio();
if (layerState._enabled) {
parts.rendering.drawStations(layerState._stations);
parts.interaction.syncRadioLifecyclePresentation();
}
},
detachRenderer() {
parts.interaction.removeInteraction();
clearTimeout(layerState._overlayPublishTimer);
layerState._overlayPublishTimer = null;
parts.renderer?.destroy();
parts.renderer = null;
layerState._renderById.clear();
layerState._selectedPosition = null;
layerState._lastHorizonCameraPosition = null;
clearOverlaySource(RADIO_OVERLAY_SOURCE_ID);
setOverlaySourceVisible(RADIO_OVERLAY_SOURCE_ID, false);
},
/** Show stations. Enabling or preset restoration never starts audio. */
+8 -2
View File
@@ -46,7 +46,7 @@ export function createRendering({
function publishRadioOverlayEntries() {
layerState._overlayPublishTimer = null;
if (!parts.interaction.radioPresentationAllowed()) {
if (!parts.renderer?.ready || !parts.interaction.radioPresentationAllowed()) {
parts.clustering.resetRadioClusterOverlayIdentities();
layerState._overlayDiagnostics =
parts.clustering.emptyRadioOverlayDiagnostics();
@@ -257,7 +257,12 @@ export function createRendering({
layerState._selectedId = null;
}
parts.renderer?.clearStations();
drawStations(stations);
}
function drawStations(stations) {
if (!parts.renderer?.ready) return;
parts.renderer.clearStations();
layerState._renderById.clear();
for (const station of stations) {
const position = markerPosition(station);
@@ -278,5 +283,6 @@ export function createRendering({
scheduleRadioOverlayPublish,
updateRenderVisibility,
reconcileStations,
drawStations,
};
}