From aeaa192b5f60ed809a5a9292922b63ca87658c8b Mon Sep 17 00:00:00 2001 From: Denis Groshev Date: Mon, 16 Nov 2026 19:31:32 +0100 Subject: [PATCH] Review fixes: station panel and model housekeeping, label-box click, telemetry null stamp - Installations: the label-box click fallback reaches the controls' methods (it read an undefined member and never ran). - Station model: the docked-companion scan runs once a second again; the hand-over pass runs once, when the model starts drawing. - Station panel: an unchanged view is not republished every frame; one render pump across slider drags, stopped on destroy; destroying the panel hands the joints back to Automatic, and the joint drivers' reset forgets manual choices and the telemetry lock. - Telemetry relay: a null TimeStamp is no time, not the first second of the year. - Drop issCommandShouldShow and issCommandNoteText, which nothing called. --- server/providers/space/issTelemetry.js | 8 +++- src/layers/installations/selection.js | 2 +- src/layers/satellites/issArticulation.js | 5 +++ src/layers/satellites/issCommand.js | 35 ----------------- src/layers/satellites/issCommand.test.mjs | 30 --------------- src/layers/satellites/stationModel.js | 19 +++++++--- src/layers/satellites/stationPanel.js | 38 ++++++++++++++++--- src/layers/satellites/tiangongArticulation.js | 3 ++ 8 files changed, 63 insertions(+), 77 deletions(-) diff --git a/server/providers/space/issTelemetry.js b/server/providers/space/issTelemetry.js index 4134a2cbbe..9b83e325c1 100644 --- a/server/providers/space/issTelemetry.js +++ b/server/providers/space/issTelemetry.js @@ -228,7 +228,13 @@ export function createIssTelemetryRelay({ createSocket, now = Date.now }) { } const value = raw === null || raw === '' ? Number.NaN : Number(raw); if (!Number.isFinite(value)) return; - values.set(name, { value, at: issTelemetryTimeMs(Number(stamp), at) }); + values.set(name, { + value, + at: + stamp === null || stamp === '' + ? null + : issTelemetryTimeMs(Number(stamp), at), + }); } function connect() { diff --git a/src/layers/installations/selection.js b/src/layers/installations/selection.js index 810df106db..f031d0b065 100644 --- a/src/layers/installations/selection.js +++ b/src/layers/installations/selection.js @@ -62,7 +62,7 @@ export function createSelection({ parts.rendering.ownsSet(hit?.set) ? hit.meta?.installationId : null) ?? - parts.controls?.findAt?.(event.position)?.id ?? + parts.controls?.methods?.findAt?.(event.position)?.id ?? null; if (id && layerState.recordById.has(id) && id !== layerState.selectedId) { selectRecord(id); diff --git a/src/layers/satellites/issArticulation.js b/src/layers/satellites/issArticulation.js index 4dd281a31a..58fd0ffe55 100644 --- a/src/layers/satellites/issArticulation.js +++ b/src/layers/satellites/issArticulation.js @@ -728,6 +728,7 @@ export function createIssArticulation() { if (node) node.matrix = issAxisMatrix(pivot, axis, angle, scratchMatrix); } + /** Forget the model and every manual choice: the next update starts clean. */ function reset() { boundModel = null; nodes = null; @@ -735,6 +736,10 @@ export function createIssArticulation() { dishes = null; armNodes = null; targets = { alpha: 0, gamma: 0 }; + override = null; + dishOverride = null; + telemetryAllowed = true; + armManual = false; } /** diff --git a/src/layers/satellites/issCommand.js b/src/layers/satellites/issCommand.js index be63e0dab1..15b34e1a64 100644 --- a/src/layers/satellites/issCommand.js +++ b/src/layers/satellites/issCommand.js @@ -1,24 +1,4 @@ import { t } from '../../i18n/index.js'; -import { ISS_NORAD, issTrackedOnStation } from './policy.js'; - -/** - * Whether the command panel shows: the ISS selected (tracked), or an object - * docked to it, the layer on and the Cockpit not riding it. - * @param {{enabled: boolean, trackedNorad: number|null, cockpitHeld: boolean, - * docked?: boolean}} input `docked`: the tracked satellite is docked to the - * ISS (issTrackedOnStation). - * @returns {boolean} - */ -export function issCommandShouldShow({ - enabled, - trackedNorad, - cockpitHeld, - docked = false, -}) { - const onStation = - trackedNorad === ISS_NORAD || (Boolean(docked) && trackedNorad !== null); - return Boolean(enabled) && onStation && !cockpitHeld; -} const unit = (v) => { const n = Math.hypot(...v); @@ -55,21 +35,6 @@ export function issCommandStatusText(sunlit) { return sunlit ? t('Now: in sunlight') : t("Now: in the Earth's shadow"); } -/** - * The Automatic mode's note: what moves the joints right now. - * @param {boolean} live Whether the joints are on NASA's telemetry. - * @returns {string} - */ -export function issCommandNoteText(live) { - return live - ? t( - "Arrays, radiators and one dish follow NASA's live telemetry. The other dish holds still and the arms sway for illustration.", - ) - : t( - 'Arrays and radiators follow the Sun, the dishes aim at relay satellites and the arms sway for illustration. Computed, not live telemetry.', - ); -} - /** Beyond this the camera counts as far, and the zoom button is offered. */ export const ISS_COMMAND_FAR_M = 1000; diff --git a/src/layers/satellites/issCommand.test.mjs b/src/layers/satellites/issCommand.test.mjs index 45d1d89c81..c285fed22c 100644 --- a/src/layers/satellites/issCommand.test.mjs +++ b/src/layers/satellites/issCommand.test.mjs @@ -6,20 +6,10 @@ import { issCommandZoomRange, ISS_COMMAND_ZOOM_RANGE_M, issCommandFastOrbit, - issCommandShouldShow, issCommandZoomStep, } from './issCommand.js'; import { ISS_NORAD } from './policy.js'; -test('the panel shows only while the ISS is selected, layer on, Cockpit off', () => { - const base = { enabled: true, trackedNorad: ISS_NORAD, cockpitHeld: false }; - assert.equal(issCommandShouldShow(base), true); - assert.equal(issCommandShouldShow({ ...base, enabled: false }), false); - assert.equal(issCommandShouldShow({ ...base, trackedNorad: 20580 }), false); - assert.equal(issCommandShouldShow({ ...base, trackedNorad: null }), false); - assert.equal(issCommandShouldShow({ ...base, cockpitHeld: true }), false); -}); - test('the zoom eases in to its range and stops there, never past it', () => { let distance = 726_000; let steps = 0; @@ -63,13 +53,6 @@ test('the status line says lit or in shadow, and nothing before the model is pla assert.ok(issCommandStatusText(false).length > 0); }); -test('the note says whether the joints are computed or on live telemetry', async () => { - const { issCommandNoteText } = await import('./issCommand.js'); - assert.match(issCommandNoteText(false), /Computed, not live telemetry/); - assert.match(issCommandNoteText(true), /NASA's live telemetry/); - assert.doesNotMatch(issCommandNoteText(true), /not live telemetry/); -}); - test('an object docked to the ISS is the station too', async () => { const { issTrackedOnStation } = await import('./policy.js'); const NAUKA = 49044; @@ -82,19 +65,6 @@ test('an object docked to the ISS is the station too', async () => { assert.equal(issTrackedOnStation(20580, new Set([20581])), false); assert.equal(issTrackedOnStation(null, new Set([ISS_NORAD])), false); assert.equal(issTrackedOnStation(undefined, undefined), false); - - // The panels show for a docked object as for the ISS, on the same terms. - const command = { enabled: true, trackedNorad: NAUKA, cockpitHeld: false }; - assert.equal(issCommandShouldShow(command), false); - assert.equal(issCommandShouldShow({ ...command, docked: true }), true); - assert.equal( - issCommandShouldShow({ ...command, docked: true, cockpitHeld: true }), - false, - ); - assert.equal( - issCommandShouldShow({ ...command, docked: true, trackedNorad: null }), - false, - ); }); test('the zoom range only ever shortens, settles at the target range and never runs away', () => { diff --git a/src/layers/satellites/stationModel.js b/src/layers/satellites/stationModel.js index c055642bfc..7e154d4da9 100644 --- a/src/layers/satellites/stationModel.js +++ b/src/layers/satellites/stationModel.js @@ -244,6 +244,8 @@ export function createStationModel( const dockedByOrbit = new Set(); /** @type {Set} Docked objects whose dots the model stands in for. */ const handedCompanions = new Set(); + /** Whether the model draws and the docked dots are left to it. */ + let handingOver = false; let lastCompanionScanMs = Number.NEGATIVE_INFINITY; /** Whether the station's orbit ring is hidden for the close-up. */ let orbitHidden = false; @@ -605,14 +607,16 @@ export function createStationModel( function _updateStationModel() { visualValid = false; // The docked set first: whether the model may show (the Cockpit riding - // the station) is read from it, so it is kept current before that. - if (item) _scanCompanions(Date.now(), false); + // the station) is read from it, so it is kept current before that. Once + // a second; the dots are handed over or given back with the scan. + if (item) _scanCompanions(Date.now(), handingOver); const show = _shouldShow(); if (!show) { _hide(); // The dots draw at every distance while the model may not. _releaseDots(); if (handedCompanions.size) _releaseCompanions(); + handingOver = false; _syncOrbitCloseUp(false); return; } @@ -635,9 +639,13 @@ export function createStationModel( _load(dotPosition); return; } - // The docked dots are the model's within its range. - lastCompanionScanMs = Number.NEGATIVE_INFINITY; - _scanCompanions(Date.now(), true); + // The docked dots are the model's within its range: handed over at + // once when the model starts drawing, then with each scan. + if (!handingOver) { + handingOver = true; + lastCompanionScanMs = Number.NEGATIVE_INFINITY; + _scanCompanions(Date.now(), true); + } _handOverDots(); _syncOrbitCloseUp(cameraDistance < spec.orbitHideM); // Out of range the model would not draw anyway: skip the SGP4 sample. @@ -709,6 +717,7 @@ export function createStationModel( telemetry?.destroy(); _releaseDots(); _releaseCompanions(); + handingOver = false; dockedByOrbit.clear(); lastCompanionScanMs = Number.NEGATIVE_INFINITY; _syncOrbitCloseUp(false); diff --git a/src/layers/satellites/stationPanel.js b/src/layers/satellites/stationPanel.js index 035ca8c9cc..a96d9e574f 100644 --- a/src/layers/satellites/stationPanel.js +++ b/src/layers/satellites/stationPanel.js @@ -64,6 +64,11 @@ export function createStationPanel({ let sliders = new Map(); let ticker = null; let zoomTimer = null; + /** The frame pump while a joint glides, and when it stops. */ + let pump = null; + let pumpUntil = 0; + /** The last view published, as text: an unchanged view is not republished. */ + let publishedKey = null; function _stationShown() { if (!layerState._enabled) return null; @@ -88,6 +93,7 @@ export function createStationPanel({ if (!station) { if (view !== null) { view = null; + publishedKey = null; for (const listener of listeners) listener(null); } return; @@ -98,7 +104,7 @@ export function createStationPanel({ ? (findCamera(layerState._viewer)?.pose?.()?.position ?? null) : null; const range = position && eye ? distance(eye, position) : null; - view = { + const next = { key: station.key, title: station.title, subject: station.subjectName(), @@ -143,6 +149,12 @@ export function createStationPanel({ label: station.zoomLabel, }, }; + // Called every frame from the tick: the section re-renders only on a + // change (the age line moves once a second, the rest on an action). + const key = JSON.stringify(next); + if (key === publishedKey) return; + publishedKey = key; + view = next; for (const listener of listeners) listener(view); } @@ -165,17 +177,27 @@ export function createStationPanel({ findFrame(layerState._viewer)?.requestRender('station-panel'); } - /** Keep frames coming while a joint glides to a new pose. */ + /** + * Keep frames coming while a joint glides to a new pose: one pump, run + * until the latest ask (a slider drag asks many times a second). + */ function _renderFor(ms) { if (!findFrame(layerState._viewer)) return; - const until = now() + ms; - const pump = setInterval(() => { + pumpUntil = Math.max(pumpUntil, now() + ms); + if (pump) return; + pump = setInterval(() => { _requestRender(); - if (now() > until) clearInterval(pump); + if (now() > pumpUntil) _stopPump(); }, 33); pump.unref?.(); } + function _stopPump() { + if (pump) clearInterval(pump); + pump = null; + pumpUntil = 0; + } + function _stopZoom() { if (zoomTimer) clearInterval(zoomTimer); zoomTimer = null; @@ -307,7 +329,13 @@ export function createStationPanel({ } function _destroyStationPanel() { + // The joints go back to Automatic with the panel, as on leaving a station. + if (current && mode === 'manual') { + const articulation = current.articulation(); + if (articulation) current.automatic(articulation); + } _stopZoom(); + _stopPump(); if (ticker) clearInterval(ticker); ticker = null; current = null; diff --git a/src/layers/satellites/tiangongArticulation.js b/src/layers/satellites/tiangongArticulation.js index f088c93fd4..257c41d684 100644 --- a/src/layers/satellites/tiangongArticulation.js +++ b/src/layers/satellites/tiangongArticulation.js @@ -406,12 +406,15 @@ export function createTiangongArticulation() { if (node) node.matrix = issAxisMatrix(pivot, axis, angle, scratchMatrix); } + /** Forget the model and every manual choice: the next update starts clean. */ function reset() { boundModel = null; nodes = null; angles = null; targets = null; dish = null; + override = null; + wingManual.clear(); } /**