diff --git a/src/layers/satellites/issArticulation.js b/src/layers/satellites/issArticulation.js index 58fd0ffe55..8af50fd8ea 100644 --- a/src/layers/satellites/issArticulation.js +++ b/src/layers/satellites/issArticulation.js @@ -502,7 +502,8 @@ export function createIssArticulation() { /** Whether the last update had the station in sunlight; null before one. */ let lastSunlit = null; /** Command panel state: the arm is being posed by hand, so the sway is off. */ - let armManual = false; + /** The arm joints posed by hand (command panel); the rest keep swaying. */ + const manualJoints = new Set(); let armNodes = null; /** Command panel state: how far the arrays are rolled out, 0.05 to 1. */ let deploy = 1; @@ -697,10 +698,10 @@ export function createIssArticulation() { dishes = nextDishes; // Arm: an illustrative sway (see ISS_ARM_JOINTS). - if (!armManual) { + { const arm = issArmAngles(nowMs / 1000, ISS_SWAY_JOINTS); ISS_SWAY_JOINTS.forEach((joint, i) => { - if (!joint.sway) return; + if (!joint.sway || manualJoints.has(joint.node)) return; const node = (armNodes ??= ISS_SWAY_JOINTS.map( (entry) => model.getNode(entry.node) ?? null, ))[i]; @@ -723,7 +724,7 @@ export function createIssArticulation() { * @param {number} angle Radians. */ function setJoint(name, pivot, axis, angle) { - armManual = true; + manualJoints.add(name); const node = boundModel?.getNode(name); if (node) node.matrix = issAxisMatrix(pivot, axis, angle, scratchMatrix); } @@ -739,7 +740,7 @@ export function createIssArticulation() { override = null; dishOverride = null; telemetryAllowed = true; - armManual = false; + manualJoints.clear(); } /** @@ -802,7 +803,7 @@ export function createIssArticulation() { /** Command panel: hand the arm back to its sway. */ function resumeArm() { - armManual = false; + manualJoints.clear(); } return { diff --git a/src/layers/satellites/rendering.js b/src/layers/satellites/rendering.js index 0d9232d072..06c797a955 100644 --- a/src/layers/satellites/rendering.js +++ b/src/layers/satellites/rendering.js @@ -214,7 +214,7 @@ export function createRendering({ function _setOrbitPathShown(noradId, show) { const path = layerState._orbitPaths.get(noradId); - if (!path) return; + if (!path || path.item.show === show) return; path.item.show = show; sets?.rings.upsert([path.item]); } diff --git a/src/layers/satellites/stationModel.js b/src/layers/satellites/stationModel.js index dcd77a6ef1..274d2fa6b8 100644 --- a/src/layers/satellites/stationModel.js +++ b/src/layers/satellites/stationModel.js @@ -633,7 +633,6 @@ export function createStationModel( if ( !loading && !failed && - resolveAsset && dotPosition && cameraDistance <= spec.maxDistanceM * 1.5 ) @@ -657,7 +656,10 @@ export function createStationModel( const frame = _stationFrame(scratchPosition); if (!frame) { + // Nowhere to draw the model (the orbit would not propagate): the dots + // draw at every distance rather than nothing at all. _hide(); + _releaseDots(); return; } const { date, axes } = frame; diff --git a/src/layers/satellites/tracking.js b/src/layers/satellites/tracking.js index 7c3cd2977b..b3313452c8 100644 --- a/src/layers/satellites/tracking.js +++ b/src/layers/satellites/tracking.js @@ -393,9 +393,17 @@ export function createTracking({ state: layerState, services, parts, source }) { // republished every frame. const clearPx = modelFor(parts, layerState._trackedNorad)?._cardClearPx?.() ?? null; - // The overlay's gap is twice the anchor radius, so half the clearance. - const anchorRadiusPx = clearPx ? Math.round(clearPx / 8) * 4 : null; const current = readEntityRecord(layerState._trackedEntity)?.labelModel; + // The overlay's gap is twice the anchor radius, so half the clearance, + // in 4 px steps. The step kept stands until the clearance has moved a + // pixel past the step's edge: at an edge, sub-pixel jitter in the range + // would otherwise flip it, and republish the card, every frame. + const kept = current?.anchorRadiusPx ?? null; + const anchorRadiusPx = !clearPx + ? null + : kept !== null && Math.abs(clearPx / 2 - kept) < 3 + ? kept + : Math.round(clearPx / 8) * 4; // Compare the WHOLE detail array: comparing only `details[0]` swallowed any // change confined to the companions line, so the card would never republish. const unchanged = diff --git a/src/render/cesium/draw.test.mjs b/src/render/cesium/draw.test.mjs index a593aa47d0..6f80bf8a59 100644 --- a/src/render/cesium/draw.test.mjs +++ b/src/render/cesium/draw.test.mjs @@ -7082,7 +7082,8 @@ test('a model poses its named nodes once ready, writes only what changed, and gi ), set matrix(m) { writes.push(name); - this.current = m; + // As Cesium's runtime node does: a copy, not the matrix handed in. + this.current = Cesium.Matrix4.clone(m); }, }; model.getNode = (name) => { diff --git a/src/render/cesium/drawModels.js b/src/render/cesium/drawModels.js index 80e9e7c8e1..d3a7b64392 100644 --- a/src/render/cesium/drawModels.js +++ b/src/render/cesium/drawModels.js @@ -60,6 +60,9 @@ export const RECEDE_WRITE_EPSILON = 0.005; * written, so an update that keeps a node's matrix writes nothing. */ const posedNodes = new WeakMap(); +/** A posed name the model has no node for: looked up once, then skipped. */ +const NO_NODE = Symbol('no such node'); +const scratchNodeMatrix = new Cesium.Matrix4(); /** * Write the item's node transforms to `model` once it is ready: changed @@ -75,18 +78,25 @@ function poseNodes(item, model) { for (const [name, last] of posed) { if (wanted && Object.hasOwn(wanted, name)) continue; posed.delete(name); + if (last === NO_NODE) continue; const node = model.getNode(name); - if (node && last) node.matrix = Cesium.Matrix4.clone(node.originalMatrix); + if (node) node.matrix = Cesium.Matrix4.clone(node.originalMatrix); } if (!wanted) return; for (const name of Object.keys(wanted)) { const matrix = wanted[name]; if (!matrix || matrix.length < 16) continue; const last = posed.get(name); + if (last === NO_NODE) continue; if (last && sameMatrix(last, matrix)) continue; const node = model.getNode(name); - posed.set(name, node ? Array.from(matrix).slice(0, 16) : null); - if (node) node.matrix = Cesium.Matrix4.fromArray(matrix); + if (!node) { + posed.set(name, NO_NODE); + continue; + } + posed.set(name, Array.from(matrix).slice(0, 16)); + // The node copies the matrix it is given. + node.matrix = Cesium.Matrix4.fromArray(matrix, 0, scratchNodeMatrix); } }