From d0f22c4ad040252506beb600a8ad4bb54625e436 Mon Sep 17 00:00:00 2001 From: Adnan Zahir Date: Fri, 13 Nov 2026 22:11:49 +0700 Subject: [PATCH] feat: draw orbits as stars in the realistic look and follow the radar wave The orbit overlay fit the radar look but read as a diagram laid over the realistic one. Give each look its own grammar over the same data. - Realistic look: each orbit is a star with a bright core, a status-tinted glow and four tapered diffraction spikes, which the sky's own stars never have. Status still shows by shape as well as colour. Tracks recede to a faint trace, hovering a marker reveals its shell, and the selected orbit keeps its dashed ring. Moving markers trail a tapered comet tail along their orbit. - Stars shimmer out of phase on the scene loop that already runs, more for working and failed ones. A stopped map is still, and reduced motion turns it off. Hovering a star enlarges it with the shared spring. - Radar look: plain instrument dots and full-strength tracks, as before. - The overlay takes the look at each marker's and ring's own distance from the hole, so it changes as the radar wave front passes. The renderer exposes this as signal.lookAt and calls signal.onLook while the wave runs. - Slow the wave spring so the front takes about 0.4 s to cross the orbit area instead of 0.2 s, and end it at 99.5% progress. - Test that a marker's trail points back along its motion. Co-Authored-By: Claude Sonnet 5.5 --- docs/UI.md | 1 + web/scripts/galaxy.test.mjs | 15 +- web/src/components/scene/BlackholeGalaxy.tsx | 139 +++++++++++++++++-- web/src/index.css | 8 +- web/src/lib/blackhole/controller.ts | 26 +++- web/src/lib/blackhole/layout.ts | 4 +- web/src/lib/blackhole/look.ts | 6 +- web/src/lib/galaxyLayout.ts | 6 + 8 files changed, 187 insertions(+), 18 deletions(-) diff --git a/docs/UI.md b/docs/UI.md index 1aee8f4..f39ef55 100644 --- a/docs/UI.md +++ b/docs/UI.md @@ -25,6 +25,7 @@ The persistent viewport maps backup jobs and recovery points. The black hole rep - Each pixel is a light ray traced through Schwarzschild spacetime (`geodesic.ts`, mirrored in the GLSL in `shaders.ts`). Rays that fall in are black, rays that cross the disk plane pick up Doppler-beamed disk light, and rays that escape sample the sky. The shadow, the arch of the far side of the disk, the second image and the Einstein ring all come from that, not from artwork. Far from the hole the integrator is skipped for the weak-field deflection. The thin ring hugging the shadow is real: it is light that skimmed the photon sphere. It stays on by default, and `rimCut` can fade it out. - The proportions follow reference imagery of a thin disk seen from a low angle: the disk reaches about 26 M, roughly five times the shadow's radius, the camera sits 8° above the disk plane, the disk is optically thick near the hole and thins toward its rim, and its brightness falls steeply outward. In the app the shadow is 34 scene units across its radius, so the disk ends just past the first orbit ring. The disk plane is not the orbit plane: the orbits keep their own 0.68 tilt. +- The orbit overlay has two looks that follow the radar wave. In the realistic look each orbit is a star: a bright core, a glow tinted by status (mint when healthy, amber while working, ember red when failed) and four diffraction spikes, which the sky's own stars never have, so a marker cannot be mistaken for scenery. The orbit tracks recede to a faint trace; hovering a marker reveals its shell, and the selected orbit keeps its bright dashed ring. While the map flows, each marker trails a tapered comet tail back along its orbit, which lengthens with speed. Stars shimmer: each scales and brightens slightly out of phase with the others, and working and failed stars move the most. The shimmer rides the scene loop that is already running, so a stopped map is perfectly still, and it is off under reduced motion. Hovering a star enlarges it with the shared spring. Status is still carried by shape as well as colour: failed keeps its diamond and busy keeps its dashed ring. In the radar look the markers are plain instrument dots and the tracks are drawn at full strength. Each marker and track ring takes the look at its own distance from the hole, so they change as the wave front passes. The renderer exposes this as `signal.lookAt` and calls `signal.onLook` while the wave runs. - The disk's texture is filtered by how many pixels each feature covers: noise octaves too fine to resolve collapse to their mean and melt into a smooth glow, so thin lines cannot alias into moire. Light bent a long way round the hole is squeezed onto fewer pixels, so it is filtered harder. The gas shears with differential rotation, and the whole pattern flows faster near the hole. - The sky must never rival the orbit markers drawn over it. Point sources in the bake (stars and distant galaxies) are small, few, and capped in brightness (`POINT_CAP`), and every marker has a soft dark backing disc and a dark outline, so it stays readable over any haze. Treat both as a contract: a sky change that adds bright features near the orbits breaks clickability. - The sky is baked once into a cubemap at load and sampled per pixel. It is a procedural galaxy with a bulge, dust lanes, nebulae, distant galaxies and stars. diff --git a/web/scripts/galaxy.test.mjs b/web/scripts/galaxy.test.mjs index a9247fb..cc6cb1b 100644 --- a/web/scripts/galaxy.test.mjs +++ b/web/scripts/galaxy.test.mjs @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { capturePhases, assignOrbitSlots, orbitPose, groupSnapshots, moonPoses } from "../src/lib/galaxyLayout.ts"; +import { capturePhases, assignOrbitSlots, orbitPose, groupSnapshots, moonPoses, trailAngle } from "../src/lib/galaxyLayout.ts"; import { placeLabels } from "../src/lib/galaxyLabelLayout.ts"; test("slot identities survive reordering, insertion and removal", () => { @@ -84,3 +84,16 @@ test("the selected label searches farther when nearby orbit markers crowd it out assert.deepEqual(placeLabels([selected], 300, 300, [cluster]), []); assert.equal(placeLabels([selected], 300, 300, [cluster], selected.id)[0]?.id, selected.id); }); + +test("a marker's trail points back along the direction it came from", () => { + const slots = assignOrbitSlots(Array.from({ length: 30 }, (_, i) => String(i))); + for (const slot of slots.values()) { + for (const time of [0, 3.7, 41]) { + const now = orbitPose(slot, time); + const next = orbitPose(slot, time + 0.01); + const tail = Math.atan2(-(next.y - now.y), -(next.x - now.x)); + const diff = Math.atan2(Math.sin(trailAngle(slot, time) - tail), Math.cos(trailAngle(slot, time) - tail)); + assert.ok(Math.abs(diff) < 0.01, `trail off by ${diff}`); + } + } +}); diff --git a/web/src/components/scene/BlackholeGalaxy.tsx b/web/src/components/scene/BlackholeGalaxy.tsx index dfa56bb..55ea7ef 100644 --- a/web/src/components/scene/BlackholeGalaxy.tsx +++ b/web/src/components/scene/BlackholeGalaxy.tsx @@ -5,13 +5,14 @@ import { orbitStatus } from "../../lib/format"; import { LABEL_HEIGHT, placeLabels, type Rect } from "../../lib/galaxyLabelLayout"; import { assignOrbitSlots, CAPTURE_HIGHLIGHT_START, capturePhases, moonPoses, orbitCapacity, orbitPose, orbitRadii, ORBIT_TILT, - SCENE_HEIGHT, SCENE_WIDTH, spiralPoint, type Vec2, + SCENE_HEIGHT, SCENE_WIDTH, spiralPoint, trailAngle, type Vec2, } from "../../lib/galaxyLayout"; import { useGalaxyMotion } from "../../hooks/useGalaxyMotion"; import { useScreenTransition } from "../../hooks/useScreenTransition"; import { ambientSpring, gentleSpring, uiSpring } from "../../lib/motion"; import { VaultCore } from "./VaultCore"; import type { CoreSignal } from "../../lib/blackhole/controller"; +import { SCENE_UNITS_PER_M } from "../../lib/blackhole/layout"; export type CaptureEffect = { orbitId: string; key: number; snapshotId?: string }; @@ -38,12 +39,23 @@ const MAX_LABELS = 12; const clamp = (value: number) => Math.max(0, Math.min(1, value)); const ACCRETION_SECONDS = 6.4; const TRAIL_WIDTHS = [0.8, 1.4, 2.3]; +/** Star colour by status: cool mint when healthy, amber while working, ember red when failed. */ +/** Glow falloff, close to a gaussian so there is no visible edge. */ +const GLOW_STOPS: [number, number][] = [[0, 0.9], [0.06, 0.6], [0.14, 0.34], [0.26, 0.14], [0.42, 0.045], [0.65, 0.01], [1, 0]]; +/** A diffraction spike: a thin diamond that tapers to nothing at both ends. */ +const SPIKE = "M-14 0 L0 -.7 L14 0 L0 .7Z"; +const STAR_TONES: [string, string][] = [["green", "#b4efd9"], ["amber", "#f2bc80"], ["red", "#ff9484"], ["grey", "#cdd3dc"]]; export function BlackholeGalaxy({ orbits, selectedOrbitId, recentSnapshots, flowing, reducedMotion, bigScreen, captureEffect, captureGlow, signal, svgCore, captureReady, onSelectOrbit, onSelectSnapshot, }: Props) { const frame = useRef(null); - const bodyNodes = useRef(new Map()); + const bodyNodes = useRef(new Map()); + const ambient = useRef(0); + const ringNodes = useRef(new Map()); const slotsBefore = useRef>(undefined); const elapsed = useRef(0); const entrance = useRef(0); @@ -56,6 +68,7 @@ export function BlackholeGalaxy({ const hasRunning = orbits.some(orbit => orbitStatus(orbit.last_status).busy); const trailId = useId(); const knockoutId = useId(); + const starId = useId(); const trail = useRef(null); const trailSegments = useRef<(SVGUseElement | null)[]>([]); const head = useRef(null); @@ -147,6 +160,32 @@ export function BlackholeGalaxy({ const appear = entering ? clamp((entrance.current - Math.min(index * 0.013, 0.33)) / 0.23) : 1; node.setAttribute("transform", `translate(${x} ${y}) scale(${0.95 + depth * 0.08})`); node.setAttribute("opacity", String(appear * (0.88 + depth * 0.12))); + const body = bodyNodes.current.get(node)!; + body.x = x; + body.y = y; + // A short comet tail behind each moving marker. It points back along the orbit, lengthens with speed and + // fades out as the map stops. + body.trail ??= node.querySelector(".marker-trail"); + if (body.trail) { + body.trail.setAttribute("transform", `rotate(${(trailAngle(slot, elapsed.current) * 180) / Math.PI}) scale(${0.55 + 0.45 * Math.min(1, speed)} 1)`); + body.trail.setAttribute("opacity", String(Math.min(1, speed * 1.6) * (1 - body.look))); + } + } + } + // Stars shimmer. It rides the loop that is already running, so a map that has stopped is perfectly still, and it + // is off under reduced motion. Working and failed stars shimmer more, so activity reads at a glance. + if (delta > 0) ambient.current += delta; + if (!reducedMotion && delta > 0) { + const time = ambient.current; + for (const [node, body] of bodyNodes.current) { + body.life ??= node.querySelector(".star-life"); + if (!body.life) continue; + const rate = 0.7 + (0.8 * ((body.index * 7) % 5)) / 4; + const phase = body.index * 2.399; + const wave = 0.6 * Math.sin(time * rate + phase) + 0.4 * Math.sin(time * rate * 2.3 + phase * 1.7); + const depth = body.kind === "busy" ? 0.16 : body.kind === "failed" ? 0.12 : 0.07; + body.life.setAttribute("transform", `scale(${1 + depth * wave})`); + body.life.setAttribute("opacity", String(1 - depth * 0.45 * (1 - wave))); } } if (moving && selectedSlot) { @@ -229,6 +268,29 @@ export function BlackholeGalaxy({ return moving || entering || capturing || (hasRunning && !reducedMotion); }); + // The overlay follows the radar wave: each marker and ring takes the look at its own distance from the hole, so + // stars give way to instrument dots, and quiet tracks to full rings, as the front passes. + const paintLook = () => { + const at = signal.lookAt; + for (const [node, body] of bodyNodes.current) { + body.look = at ? at(Math.hypot(body.x, body.y) / SCENE_UNITS_PER_M) : 0; + node.querySelector(".marker-star")?.setAttribute("opacity", String(1 - body.look)); + node.querySelector(".marker-dot")?.setAttribute("opacity", String(body.look)); + // The dark backing keeps radar dots readable; a glowing star does not need it. + node.querySelector(".orbit-knockout")?.setAttribute("opacity", String(0.08 + 0.92 * body.look)); + if (body.look > 0.99) node.querySelector(".marker-trail")?.setAttribute("opacity", "0"); + } + for (const [radius, ring] of ringNodes.current) { + const look = at ? at(radius / SCENE_UNITS_PER_M) : 0; + ring.style.setProperty("--track", String(0.12 + 0.24 * look)); + } + }; + useLayoutEffect(() => { + signal.onLook = paintLook; + return () => { signal.onLook = undefined; }; + }); + useLayoutEffect(paintLook); + const scale = width / SCENE_WIDTH; const height = SCENE_HEIGHT * scale; const hitRadius = Math.max(12, scale ? 12 / scale : 12); @@ -262,15 +324,20 @@ export function BlackholeGalaxy({ } const focusLabel = labels.find(({ id }) => id === selectedOrbitId); + const revealRing = (radius: number | undefined, on: boolean) => { + if (radius !== undefined) ringNodes.current.get(radius)?.classList.toggle("is-hover", on); + }; + const renderOrbits = visible.map((orbit, index) => { const selected = orbit.id === selectedOrbitId; const status = orbitStatus(orbit.last_status); + const radius = slots.get(orbit.id)?.radius; return ( { if (!node) return; - bodyNodes.current.set(node, { id: orbit.id, index }); + bodyNodes.current.set(node, { id: orbit.id, index, x: 0, y: 0, look: 0, kind: status.tone === "red" ? "failed" : status.busy ? "busy" : "calm" }); return () => { bodyNodes.current.delete(node); }; }} initial={false} @@ -280,12 +347,36 @@ export function BlackholeGalaxy({ className={`orbit-marker orbit-marker--${status.tone}${selected ? " orbit-marker--selected" : ""}`} > + + + {status.tone === "red" && } {status.busy && } - - onSelectOrbit(orbit.id)} /> + {/* Realistic look: a star. Four diffraction spikes set it apart from the sky's own stars, which have none. */} + + + + + + + + + + + + + + + + {/* Radar look: the plain instrument dot. */} + + + + onSelectOrbit(orbit.id)} + onPointerEnter={() => revealRing(radius, true)} onPointerLeave={() => revealRing(radius, false)} /> ); }); @@ -295,14 +386,46 @@ export function BlackholeGalaxy({