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 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 22:11:49 +07:00
parent 34e9afc8a4
commit d0f22c4ad0
8 changed files with 187 additions and 18 deletions

View File

@@ -1,11 +1,19 @@
import { cancelFrame, frame as frameLoop } from "motion/react";
import { farthestCornerM, layoutFor } from "./layout";
import { createLook, jumpLook, requestLook, stepLook, waveParams, type Look } from "./look";
import { createLook, jumpLook, requestLook, stepLook, styleAt, waveParams, type Look } from "./look";
import { CALIBRATION_SAMPLES, QUALITY_TIERS, chooseTier, initialTier } from "./quality";
import { createBlackholeRenderer, defaultParams, type BlackholeParams } from "./renderer";
/** What the scene tells the renderer each frame. The galaxy loop writes it and calls `wake`. */
export type CoreSignal = { time: number; absorption: number; wake?: () => void };
export type CoreSignal = {
time: number;
absorption: number;
wake?: () => void;
/** The look at a distance from the hole, in gravitational radii: 0 realistic .. 1 radar. Set by the renderer. */
lookAt?: (radiusM: number) => number;
/** Called by the renderer when the look changes, so the overlay can follow the radar wave. Set by the scene. */
onLook?: () => void;
};
export type BlackholeController = {
/** Ask for a redraw. Cheap to call every frame: draws are coalesced and capped by the quality tier. */
@@ -66,6 +74,10 @@ export function createBlackholeController({ canvas, panel, frame, signal, onLost
let sweepClock = 0;
let sweepAmount = 0;
let lastTick = 0;
let wave = waveParams(look, 0);
let lookChanged = true;
let wasWaving = false;
signal.lookAt = (radiusM) => styleAt(wave, radiusM);
const resize = () => {
if (!panel.clientWidth || !panel.clientHeight) return;
@@ -131,7 +143,12 @@ export function createBlackholeController({ canvas, panel, frame, signal, onLost
const width = panel.clientWidth;
const height = panel.clientHeight;
const maxRadius = farthestCornerM({ x: params.centerX * width, y: params.centerY * height }, { width, height }, params.pxPerM);
Object.assign(params, waveParams(look, maxRadius), { styleKind: 1, sweep: sweepClock * 0.8, sweepAmount });
wave = waveParams(look, maxRadius);
Object.assign(params, wave, { styleKind: 1, sweep: sweepClock * 0.8, sweepAmount });
// The orbit overlay follows the wave, and gets one more call after it ends so it settles exactly.
if (waving || wasWaving || lookChanged) signal.onLook?.();
wasWaving = waving;
lookChanged = false;
const time = preset.maxFps > 0 ? signal.time : frozenTime;
params.sway = 0.06 * Math.sin(time * 0.05);
@@ -214,15 +231,18 @@ export function createBlackholeController({ canvas, panel, frame, signal, onLost
if (instant || reduced) jumpLook(look, target);
else requestLook(look, target);
lastTick = 0;
lookChanged = true;
wake(true);
},
setReducedMotion: (value) => {
reduced = value;
if (reduced && look.running) jumpLook(look, look.queued ?? look.to);
lastTick = 0;
lookChanged = true;
wake(true);
},
dispose: () => {
signal.lookAt = undefined;
disposed = true;
cancelFrame(tick);
window.clearTimeout(calibrateTimer);

View File

@@ -8,7 +8,9 @@ export type Box = { left: number; top: number; width: number; height: number };
* ring (128) instead of covering the orbits, while staying in proportion to the shadow.
*/
const SHADOW_SCENE_RADIUS = 34;
const PX_PER_M_SCENE = SHADOW_SCENE_RADIUS / CRITICAL_IMPACT;
/** Scene units per gravitational radius: how far from the hole a marker is, in the renderer's units. */
export const SCENE_UNITS_PER_M = SHADOW_SCENE_RADIUS / CRITICAL_IMPACT;
const PX_PER_M_SCENE = SCENE_UNITS_PER_M;
/** Where the hole sits in the panel, and how big a gravitational radius is, for the current frame. */
export function layoutFor(frame: Box, panel: Box) {

View File

@@ -18,12 +18,12 @@ export type LookTransition = {
};
/** Close to critically damped: the front accelerates away from the hole and settles without overshoot. */
export const WAVE_STIFFNESS = 70;
export const WAVE_DAMPING = 17;
export const WAVE_STIFFNESS = 16;
export const WAVE_DAMPING = 8;
/** Softness of the front, in gravitational radii. */
export const WAVE_FEATHER = 3;
const SETTLED_PROGRESS = 0.999;
const SETTLED_PROGRESS = 0.995;
const SETTLED_SPEED = 0.01;
const SUBSTEP = 0.008;

View File

@@ -61,6 +61,12 @@ export function orbitPose(slot: OrbitSlot, time: number): Vec2 {
};
}
/** Screen direction, in radians, from a marker back along its orbit: where its trail points. */
export function trailAngle(slot: OrbitSlot, time: number): number {
const angle = slot.angle + time * slot.speed;
return Math.atan2(-Math.cos(angle) * slot.radius * ORBIT_TILT, Math.sin(angle) * slot.radius);
}
export function moonPoses(star: Vec2, count: number, distance: number, obstacles: Vec2[] = []): Vec2[] {
const direction = Math.atan2(star.y, star.x);
const margin = distance / 2;