tools(rpo-replay): v5 — critic fixes: relative-view inset, corrected copy, laps readout, hook into shadow, portrait layout

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0187rSCa4AKJPGw6uiuPSGyX
This commit is contained in:
Claude committed 2026-11-08 05:58:35 +00:00
1 parent fff5d5a479
commit a93f2bb4d7
5 files changed
+368 -118

No files matched your search

+62 -39
View File
@@ -4,10 +4,13 @@
// except label placement, which carries state between consecutive frames so
// labels hold their side (hysteresis) and ease instead of jumping.
import { createInset } from './inset.js';
export function createHud(ctx) {
const { D, W, H, U, PORTRAIT, sec, rate, sOfTau, CA_T, VANTOR_T, BURNS, CUTS, SHOTS, shotAt, DUR, project } = ctx;
const { D, W, H, U, PORTRAIT, sec, rate, sOfTau, CA_T, VANTOR_T, BURNS, CUTS, SHOTS, shotAt, DUR, project, relAt } = ctx;
const $ = (q) => document.querySelector(q);
const CA_M = Math.round(D.ca.m / 5) * 5;
// Element sets can't resolve tens of metres: quote the pass to the nearest 50 m.
const CA_M = Math.round(D.ca.m / 50) * 50;
const END = SHOTS.find((x) => x.id === 'end').s0;
// -------------------------------------------------------------------------
@@ -26,33 +29,33 @@ export function createHud(ctx) {
];
const cap = (id, title, body, extra = {}) => ({ s0: span(id)[0], s1: span(id)[1], title, body, ...extra });
const CAPTIONS = [
cap('hook', `A Russian military satellite came within <span class="c-cos nw">~${CA_M} m</span> of a U.S.-registered one`,
'This is how it got there, rebuilt from public tracking data.', { hook: true, s0: -1 }),
cap('hook', 'A Russian military satellite came within about half a kilometre of a U.S. radar satellite',
'Rebuilt from public tracking data.', { hook: true, s0: -1 }),
cap('climb', 'Climb higher to fall behind',
'Same orbit, a quarter-orbit apart. Two burns lift <b class="c-cos">Cosmos 2612</b> <b>47 km</b>, and a higher orbit is a slower one.'),
cap('lap', 'Fall behind, and lap it',
'Drifting back <b>~6,700 km a day</b>, it laps almost twice, passing over <b class="c-x36">X36</b> on Oct 5 and Oct 12, as its orbit plane swings into line.'),
'Two burns lift <b class="c-cos">Cosmos 2612</b> <b>47 km</b>. A higher orbit is a longer lap, so it falls behind.'),
cap('lap', 'Lapped, twice',
'Losing <b>~6,700 km a day</b>, it is lapped by <b class="c-x36">X36</b> on Oct 5 and Oct 12, while Earth\'s bulge swings the two orbits into line.'),
cap('drop', 'Drop into the same orbit',
'Oct 12: from <b>47 km</b> directly overhead it dives into X36\'s orbit, and lands about <b>480 km behind</b>.'),
'Oct 12: from <b>54 km</b> directly overhead it dives into X36\'s orbit, landing <b>~500 km behind</b>.'),
cap('close', 'Speed up, then brake',
'A 2 km dip makes it faster, closing <b>~350 km a day</b>. Then it brakes 3 km behind.'),
'A 2 km dip makes it faster, closing <b>~350 km a day</b>. Then it brakes <b>~10 km</b> behind.'),
cap('dance', 'The dance',
'Every orbit is a day and a night. Each one, Cosmos loops <b>~1.5 km</b> around X36, 3 km behind it.'),
'Every orbit is a day and a night. Each one, Cosmos traces a <b>~1.5 km</b> loop as it edges in from 8 to 3 km behind.'),
cap('dance-ff', 'Flatten the loops',
'A tiny burn puts Cosmos almost exactly in X36\'s path. It creeps in <b>~3 km a day</b>.'),
cap('approach', 'Closing in, slowly',
'Creeping in at <b>a few centimetres per second</b>, while both fly at <b>27,000 km/h</b>.'),
'Creeping in at <b>a few centimetres a second</b>, while both fly at <b>27,000 km/h</b>.'),
cap('ca', `Closest pass: <span class="c-cos nw">~${CA_M} m</span>`,
'True size. LeoLabs measured <b>~500 m</b>; other estimates run <b>150 to 650 m</b>.'),
'In Earth\'s shadow, ~01:17 UTC. LeoLabs radar: <b>~500 m</b>. Public estimates: <b>150–650 m</b>.'),
cap('sunrise', 'Then the sun comes up',
'Twenty minutes later both leave Earth\'s shadow. Within hours, Cosmos backs away.'),
'Twenty minutes later both leave Earth\'s shadow. Within the hour, Cosmos backs away.'),
cap('leave', 'Back off, and wait',
'It drifts back <b>~350 km a day</b>. By Oct 25 it sat <b>~480 km behind</b>, in the same orbit.'),
'It drifts back <b>~350 km a day</b>, then matches orbits again. By Oct 25 it sat <b>~480 km behind</b>.'),
];
const BURN_NOTES = {
'Phasing raise': 'raises its orbit 46 km',
'Phasing raise': 'two burns raise its orbit 46 km',
'Plane trim': 'tilts its orbit into line',
'Descent to X36 orbit': 'drops 47 km into X36\'s orbit',
'Descent to X36 orbit': 'drops 48 km into X36\'s orbit',
'Closing burn': 'dips 2.3 km to speed up',
'Braking burn': 'rises 2.5 km to stop',
'Back-off': 'rises 140 m and starts to drift back',
@@ -68,7 +71,7 @@ export function createHud(ctx) {
{ t: sec('2026-10-05T12:28:00Z'), kind: 'note', title: 'Passes overhead', sub: '55 km above its target' },
{ t: sec('2026-10-12T00:30:00Z'), kind: 'note', title: 'Directly overhead', sub: '54 km above its target' },
{ t: VANTOR_T, kind: 'vantor', title: 'Vantor photographs the pair', sub: `from its own satellite · ~${D.vantor.km.toFixed(0)} km apart · Oct 17` },
{ t: CA_T, kind: 'ca', title: 'Closest approach', sub: `${D.ca.t.slice(11, 16)} UTC, Oct 18 · in Earth's shadow` },
{ t: CA_T, kind: 'ca', title: 'Closest approach', sub: '~01:17 UTC, Oct 18 · in Earth\'s shadow' },
].map((e) => ({ ...e, s: sOfTau(e.t) })).filter((e) => e.s !== null).sort((a, b) => a.s - b.s);
const caS = EVENTS.find((e) => e.kind === 'ca')?.s ?? 1e9;
@@ -135,6 +138,13 @@ export function createHud(ctx) {
return `${(r / 86400).toFixed(1)} days`.replace('.0 days', ' days');
}
// "Seen from X36" inset (relative frame).
const insetEl = $('#inset');
insetEl.width = Math.round(insetEl.clientWidth * 2);
insetEl.height = Math.round(insetEl.clientHeight * 2);
const inset = createInset({ D, U, relAt, canvas: insetEl });
if (PORTRAIT) $('#readout').prepend($('#clock .light'));
// Label placement memory (hysteresis).
const memo = { tagX: null, tagC: null, lastS: -1 };
@@ -143,7 +153,7 @@ export function createHud(ctx) {
// -------------------------------------------------------------------------
function update(s, t, b, st) {
const sh = shotAt(s);
const endA = fade(s, END, 99, 0.5);
const endA = fade(s, END - 0.15, 99, 0.25);
const live = 1 - endA;
if (Math.abs(s - memo.lastS) > 0.2 || CUTS.some((c) => memo.lastS < c && s >= c)) {
memo.tagX = null;
@@ -191,27 +201,32 @@ export function createHud(ctx) {
$('#clock .rate').innerHTML = `1 sec = ${perSecond(rate(s))}`;
$('#clock .ff').style.display = sh.mode === 'ff' ? 'inline-block' : 'none';
const lit = st.lx > 0.5;
const light = $('#clock .light');
const light = $('.light');
light.className = `light ${lit ? 'day' : 'night'}`;
light.innerHTML = lit ? '<i></i>In sunlight' : '<i></i>In Earth\'s shadow';
const orbitN = sh.id === 'dance' ? Math.floor((t - sh.tauF(sh.s0)) / 5730) + 1 : 0;
light.innerHTML = (lit ? '<i></i>Day' : '<i></i>Night · Earth\'s shadow') + (orbitN ? ` · orbit ${orbitN}` : '');
light.style.display = sh.mode === 'true' && sh.id !== 'climb' && sh.id !== 'end' ? 'inline-flex' : 'none';
$('#clock').style.opacity = live;
// Distance readout
const ro = $('#readout');
ro.style.opacity = fade(s, climbS + 0.6, END, 0.4);
ro.querySelector('.val').innerHTML = fmtSep(st.sep);
const lapMode = sh.id === 'climb' || sh.id === 'lap';
ro.querySelector('.label').textContent = lapMode ? 'GAP ALONG THE ORBIT' : 'DISTANCE APART';
ro.querySelector('.val').innerHTML = lapMode
? `${(-st.rel[1] / (2 * Math.PI * D.a_ref_km * 1000)).toFixed(2)}<small>laps</small>`
: fmtSep(st.sep);
const [r, tt0] = st.rel;
const circ = 2 * Math.PI * D.a_ref_km * 1000;
const tt = ((tt0 % circ) + circ * 1.5) % circ - circ / 2;
let ctxLine;
if (st.sep < 1500) ctxLine = `≈ ${Math.max(1, Math.round(st.sep / 100))} football fields`;
else if (st.sep < 2e6) ctxLine = `${Math.abs(tt) >= 1e4 ? fmtNum(Math.abs(tt) / 1000) + ' km' : (Math.abs(tt) / 1000).toFixed(1) + ' km'} ${tt < 0 ? 'behind' : 'ahead'}${Math.abs(r) > 20e3 ? ` · ${fmtNum(Math.abs(r) / 1000)} km ${r > 0 ? 'higher' : 'lower'}` : ''}`;
else ctxLine = `${Math.abs(r) > 20e3 ? `${fmtNum(Math.abs(r) / 1000)} km higher · ` : ''}a quarter-orbit or more apart`;
else ctxLine = `${Math.abs(r) > 20e3 ? `${fmtNum(Math.abs(r) / 1000)} km higher · ` : ''}${fmtNum(st.sep / 1000)} km apart in a straight line`;
if (s > caS && s < span('leave')[0] + 0.5) ctxLine += ` · closest ${CA_M} m`;
ro.querySelector('.ctx').textContent = ctxLine;
ro.querySelector('.ctx').textContent = lapMode ? `${Math.abs(r) > 20e3 ? `${fmtNum(Math.abs(r) / 1000)} km higher · ` : ''}behind X36` : ctxLine;
const relLine = ro.querySelector('.rel');
relLine.textContent = st.sep < 2e4 && sh.mode === 'true' ? (st.relSpeed < 0.2 ? `relative speed ${Math.round(st.relSpeed * 100)} cm/s` : `relative speed ${st.relSpeed.toFixed(1)} m/s`) : '';
relLine.textContent = st.sep < 2e4 && sh.mode === 'true' ? (st.relSpeed < 0.2 ? `relative speed ~${Math.max(1, Math.round(st.relSpeed * 100))} cm/s (modelled)` : `relative speed ~${st.relSpeed.toFixed(1)} m/s (modelled)`) : '';
// Scale chip
const magEl = $('#mag');
@@ -219,7 +234,13 @@ export function createHud(ctx) {
const trueSize = !enlarged && st.camDistX < 200;
magEl.style.opacity = (enlarged || trueSize) ? fade(s, climbS, END, 0.3) : 0;
magEl.classList.toggle('enlarged', enlarged);
magEl.textContent = enlarged ? `Satellites enlarged ${Math.round(st.mag)}×` : 'True size';
magEl.textContent = enlarged ? `Satellites enlarged ${Math.round(st.mag)}×` : sh.id === 'ca' ? 'True size · faint bar: ±1.5 km tracking uncertainty' : 'True size';
const relChip = $('#relchip');
relChip.style.opacity = ['drop', 'close', 'dance', 'dance-ff', 'approach', 'leave'].includes(sh.id) ? fade(s, sh.s0, sh.s1, 0.3) : 0;
// Inset
const insA = sh.inset && s < END - 0.1 ? fade(s, Math.max(sh.s0, climbS + 0.8), END, 0.3) : 0;
inset.draw(s, t, (st.sepG || st.sep) / 1000, { alpha: insA * live, trailHours: sh.inset || 1, cut: CUTS.some((c) => Math.abs(s - c) < 0.05) });
// Timeline
const px = timeline.x(Math.min(Math.max(t, TL.t0), TL.t1));
@@ -244,16 +265,19 @@ export function createHud(ctx) {
const pC = project(st.cosW);
const tX = tag('tagX', 'ICEYE-X36', 'c-x36');
const tC = tag('tagC', 'COSMOS 2612', 'c-cos');
const tagA = fade(s, span('climb')[0] + 0.6, END, 0.4);
const tagA = fade(s, 0.3, END, 0.3);
const onScreen = (p) => p && p.x > -40 && p.y > -40 && p.x < W + 40 && p.y < H + 40;
const speedX = `${(st.vX / 1000).toFixed(2)} km/s`;
const speedC = `${(st.vC / 1000).toFixed(2)} km/s`;
tX.querySelector('.meta').textContent = pX?.hidden ? 'far side of Earth' : `U.S.-registered radar sat · ${speedX}`;
tC.querySelector('.meta').textContent = pC?.hidden ? 'far side of Earth' : `Russian military · ${speedC}`;
const speedShot = ['climb', 'lap', 'drop'].includes(sh.id);
tX.querySelector('.meta').textContent = speedShot ? `U.S. radar satellite · ${speedX}` : sh.id === 'hook' ? 'U.S. radar satellite' : '';
tC.querySelector('.meta').textContent = speedShot ? `Russian military · ${speedC}` : sh.id === 'hook' ? 'Russian military' : '';
tX.querySelector('.meta').style.display = tX.querySelector('.meta').textContent ? '' : 'none';
tC.querySelector('.meta').style.display = tC.querySelector('.meta').textContent ? '' : 'none';
let svg = '';
const M = 24 * U;
const obstacles = [];
for (const q of ['#logo', '#clock', '#caption', '#readout', '#tlwrap', '#chapters', '#mag']) {
for (const q of ['#logo', '#clock', '#caption', '#readout', '#tlwrap', '#chapters', '#mag', '#inset', '#relchip']) {
const el = $(q);
if (Number(el.style.opacity || 1) > 0.05) obstacles.push(el.getBoundingClientRect());
}
@@ -290,9 +314,8 @@ export function createHud(ctx) {
// Tags: keep the previous quadrant unless it has been blocked for a while;
// ease the label toward its target so it never jumps.
const place = (key, el, p, prefer, color) => {
if (!onScreen(p)) {
if (!onScreen(p) || p.hidden) {
el.style.opacity = 0;
memo[key] = null;
return;
}
el.style.opacity = tagA;
@@ -310,9 +333,9 @@ export function createHud(ctx) {
let q = m ? [m.sx, m.sy] : prefer;
let cand = rectFor(q);
if (m) {
m.blocked = cand.cost > 2000 * U * U ? m.blocked + 1 : 0;
m.blocked = cand.cost > 4000 * U * U ? m.blocked + 1 : 0;
}
if (!m || m.blocked > 8) {
if (!m || m.blocked > 20) {
const quads = [q, prefer, [prefer[0], -prefer[1]], [-prefer[0], prefer[1]], [-prefer[0], -prefer[1]]];
for (const qq of quads) {
const c = rectFor(qq);
@@ -353,7 +376,7 @@ export function createHud(ctx) {
// Dip at cuts
let dip = 0;
for (const c of CUTS) dip = Math.max(dip, 1 - Math.abs(s - c) / 0.12);
$('#dip').style.opacity = Math.max(0, dip);
// End card
@@ -364,13 +387,13 @@ export function createHud(ctx) {
ec.dataset.built = '1';
ec.innerHTML = `<div class="panel">
<div class="big">~${CA_M} m</div>
<div class="range">rebuilt from public element sets · LeoLabs ~500 m · published range 150–650 m</div>
<div class="lead">Closest pass between Cosmos 2612 and ICEYE-X36 · Oct 18, in Earth's shadow</div>
<div class="range">closest pass, Oct 18, in Earth's shadow · LeoLabs ~500 m · estimates 150–650 m</div>
<div class="stats">
<div><b>22</b><span>days in pursuit</span></div>
<div><b>${BURNS.length}</b><span>engine burns</span></div>
<div><b>${Math.max(1, Math.round((D.ca.v || 0.05) * 100))} cm/s</b><span>relative speed at closest pass</span></div>
<div><b>18</b><span>days from first burn to closest pass</span></div>
<div><b>${BURNS.length}</b><span>manoeuvres</span></div>
<div><b>~${Math.round(D.total_dv)} m/s</b><span>of thrust spent</span></div>
</div>
<div class="why">U.S. officials called it <b>"consistent with on-orbit weapons operations."</b><br>By Oct 25 it was still parked ~480 km behind, in the same orbit.</div>
</div>`;
}
$('#endlogo').style.opacity = endA;