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:
@@ -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.
|
- 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 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 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 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.
|
- 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.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import test from "node:test";
|
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";
|
import { placeLabels } from "../src/lib/galaxyLabelLayout.ts";
|
||||||
|
|
||||||
test("slot identities survive reordering, insertion and removal", () => {
|
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.deepEqual(placeLabels([selected], 300, 300, [cluster]), []);
|
||||||
assert.equal(placeLabels([selected], 300, 300, [cluster], selected.id)[0]?.id, selected.id);
|
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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import { orbitStatus } from "../../lib/format";
|
|||||||
import { LABEL_HEIGHT, placeLabels, type Rect } from "../../lib/galaxyLabelLayout";
|
import { LABEL_HEIGHT, placeLabels, type Rect } from "../../lib/galaxyLabelLayout";
|
||||||
import {
|
import {
|
||||||
assignOrbitSlots, CAPTURE_HIGHLIGHT_START, capturePhases, moonPoses, orbitCapacity, orbitPose, orbitRadii, ORBIT_TILT,
|
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";
|
} from "../../lib/galaxyLayout";
|
||||||
import { useGalaxyMotion } from "../../hooks/useGalaxyMotion";
|
import { useGalaxyMotion } from "../../hooks/useGalaxyMotion";
|
||||||
import { useScreenTransition } from "../../hooks/useScreenTransition";
|
import { useScreenTransition } from "../../hooks/useScreenTransition";
|
||||||
import { ambientSpring, gentleSpring, uiSpring } from "../../lib/motion";
|
import { ambientSpring, gentleSpring, uiSpring } from "../../lib/motion";
|
||||||
import { VaultCore } from "./VaultCore";
|
import { VaultCore } from "./VaultCore";
|
||||||
import type { CoreSignal } from "../../lib/blackhole/controller";
|
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 };
|
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 clamp = (value: number) => Math.max(0, Math.min(1, value));
|
||||||
const ACCRETION_SECONDS = 6.4;
|
const ACCRETION_SECONDS = 6.4;
|
||||||
const TRAIL_WIDTHS = [0.8, 1.4, 2.3];
|
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({
|
export function BlackholeGalaxy({
|
||||||
orbits, selectedOrbitId, recentSnapshots, flowing, reducedMotion, bigScreen, captureEffect, captureGlow, signal, svgCore, captureReady, onSelectOrbit, onSelectSnapshot,
|
orbits, selectedOrbitId, recentSnapshots, flowing, reducedMotion, bigScreen, captureEffect, captureGlow, signal, svgCore, captureReady, onSelectOrbit, onSelectSnapshot,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const frame = useRef<HTMLDivElement>(null);
|
const frame = useRef<HTMLDivElement>(null);
|
||||||
const bodyNodes = useRef(new Map<SVGGElement, { id: string; index: number }>());
|
const bodyNodes = useRef(new Map<SVGGElement, {
|
||||||
|
id: string; index: number; x: number; y: number; look: number; kind: "calm" | "busy" | "failed";
|
||||||
|
trail?: SVGGElement | null; life?: SVGGElement | null;
|
||||||
|
}>());
|
||||||
|
const ambient = useRef(0);
|
||||||
|
const ringNodes = useRef(new Map<number, SVGEllipseElement>());
|
||||||
const slotsBefore = useRef<ReturnType<typeof assignOrbitSlots>>(undefined);
|
const slotsBefore = useRef<ReturnType<typeof assignOrbitSlots>>(undefined);
|
||||||
const elapsed = useRef(0);
|
const elapsed = useRef(0);
|
||||||
const entrance = useRef(0);
|
const entrance = useRef(0);
|
||||||
@@ -56,6 +68,7 @@ export function BlackholeGalaxy({
|
|||||||
const hasRunning = orbits.some(orbit => orbitStatus(orbit.last_status).busy);
|
const hasRunning = orbits.some(orbit => orbitStatus(orbit.last_status).busy);
|
||||||
const trailId = useId();
|
const trailId = useId();
|
||||||
const knockoutId = useId();
|
const knockoutId = useId();
|
||||||
|
const starId = useId();
|
||||||
const trail = useRef<SVGPathElement>(null);
|
const trail = useRef<SVGPathElement>(null);
|
||||||
const trailSegments = useRef<(SVGUseElement | null)[]>([]);
|
const trailSegments = useRef<(SVGUseElement | null)[]>([]);
|
||||||
const head = useRef<SVGCircleElement>(null);
|
const head = useRef<SVGCircleElement>(null);
|
||||||
@@ -147,6 +160,32 @@ export function BlackholeGalaxy({
|
|||||||
const appear = entering ? clamp((entrance.current - Math.min(index * 0.013, 0.33)) / 0.23) : 1;
|
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("transform", `translate(${x} ${y}) scale(${0.95 + depth * 0.08})`);
|
||||||
node.setAttribute("opacity", String(appear * (0.88 + depth * 0.12)));
|
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<SVGGElement>(".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<SVGGElement>(".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) {
|
if (moving && selectedSlot) {
|
||||||
@@ -229,6 +268,29 @@ export function BlackholeGalaxy({
|
|||||||
return moving || entering || capturing || (hasRunning && !reducedMotion);
|
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 scale = width / SCENE_WIDTH;
|
||||||
const height = SCENE_HEIGHT * scale;
|
const height = SCENE_HEIGHT * scale;
|
||||||
const hitRadius = Math.max(12, scale ? 12 / scale : 12);
|
const hitRadius = Math.max(12, scale ? 12 / scale : 12);
|
||||||
@@ -262,15 +324,20 @@ export function BlackholeGalaxy({
|
|||||||
}
|
}
|
||||||
const focusLabel = labels.find(({ id }) => id === selectedOrbitId);
|
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 renderOrbits = visible.map((orbit, index) => {
|
||||||
const selected = orbit.id === selectedOrbitId;
|
const selected = orbit.id === selectedOrbitId;
|
||||||
const status = orbitStatus(orbit.last_status);
|
const status = orbitStatus(orbit.last_status);
|
||||||
|
const radius = slots.get(orbit.id)?.radius;
|
||||||
return (
|
return (
|
||||||
<motion.g
|
<motion.g
|
||||||
key={orbit.id}
|
key={orbit.id}
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
if (!node) 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); };
|
return () => { bodyNodes.current.delete(node); };
|
||||||
}}
|
}}
|
||||||
initial={false}
|
initial={false}
|
||||||
@@ -280,12 +347,36 @@ export function BlackholeGalaxy({
|
|||||||
className={`orbit-marker orbit-marker--${status.tone}${selected ? " orbit-marker--selected" : ""}`}
|
className={`orbit-marker orbit-marker--${status.tone}${selected ? " orbit-marker--selected" : ""}`}
|
||||||
>
|
>
|
||||||
<circle className="orbit-knockout" r={selected ? 16 : 11} fill={`url(#${knockoutId})`} />
|
<circle className="orbit-knockout" r={selected ? 16 : 11} fill={`url(#${knockoutId})`} />
|
||||||
|
<g className="marker-trail" opacity="0">
|
||||||
|
<path d="M0 -1.8 C8 -1.3 18 -0.5 28 0 C18 0.5 8 1.3 0 1.8Z" fill={`url(#${starId}-trail-${status.tone})`} />
|
||||||
|
</g>
|
||||||
<motion.circle className="orbit-halo" r={selected ? 16 : 10}
|
<motion.circle className="orbit-halo" r={selected ? 16 : 10}
|
||||||
variants={{ idle: { opacity: 0.08 }, hover: { opacity: 0.3 } }} />
|
variants={{ idle: { opacity: 0.08 }, hover: { opacity: 0.3 } }} />
|
||||||
{status.tone === "red" && <path className="orbit-alert" d="M0 -8 8 0 0 8 -8 0Z" />}
|
{status.tone === "red" && <path className="orbit-alert" d="M0 -8 8 0 0 8 -8 0Z" />}
|
||||||
{status.busy && <circle className="orbit-busy" r="8.5" />}
|
{status.busy && <circle className="orbit-busy" r="8.5" />}
|
||||||
|
{/* Realistic look: a star. Four diffraction spikes set it apart from the sky's own stars, which have none. */}
|
||||||
|
<motion.g className="marker-star" initial={false}
|
||||||
|
variants={{ idle: { scale: selected ? 1.3 : 1 }, hover: { scale: selected ? 1.45 : 1.25 } }}>
|
||||||
|
<g className="star-life">
|
||||||
|
<circle className="star-halo" r="28" fill={`url(#${starId}-halo-${status.tone})`} />
|
||||||
|
<circle className="star-glow" r="14" fill={`url(#${starId}-${status.tone})`} />
|
||||||
|
<g className="star-spikes" fill={`url(#${starId}-spike)`}>
|
||||||
|
<path d={SPIKE} />
|
||||||
|
<path d={SPIKE} transform="rotate(90)" />
|
||||||
|
<g opacity=".38" transform="rotate(45) scale(.5)">
|
||||||
|
<path d={SPIKE} />
|
||||||
|
<path d={SPIKE} transform="rotate(90)" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<circle className="star-core" r="3.6" fill={`url(#${starId}-core)`} />
|
||||||
|
</g>
|
||||||
|
</motion.g>
|
||||||
|
{/* Radar look: the plain instrument dot. */}
|
||||||
|
<g className="marker-dot" opacity="0">
|
||||||
<circle className="orbit-light" r="4.6" />
|
<circle className="orbit-light" r="4.6" />
|
||||||
<circle className="orbit-hit" r={hitRadius} onClick={() => onSelectOrbit(orbit.id)} />
|
</g>
|
||||||
|
<circle className="orbit-hit" r={hitRadius} onClick={() => onSelectOrbit(orbit.id)}
|
||||||
|
onPointerEnter={() => revealRing(radius, true)} onPointerLeave={() => revealRing(radius, false)} />
|
||||||
</motion.g>
|
</motion.g>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -295,14 +386,46 @@ export function BlackholeGalaxy({
|
|||||||
<svg viewBox={`${-HALF_WIDTH} ${-HALF_HEIGHT} ${SCENE_WIDTH} ${SCENE_HEIGHT}`} aria-hidden="true">
|
<svg viewBox={`${-HALF_WIDTH} ${-HALF_HEIGHT} ${SCENE_WIDTH} ${SCENE_HEIGHT}`} aria-hidden="true">
|
||||||
<defs>
|
<defs>
|
||||||
<radialGradient id={knockoutId}>
|
<radialGradient id={knockoutId}>
|
||||||
<stop offset="0" stopColor="#0a0c10" stopOpacity=".78" />
|
<stop offset="0" stopColor="#0a0c10" stopOpacity=".62" />
|
||||||
<stop offset=".55" stopColor="#0a0c10" stopOpacity=".62" />
|
<stop offset=".55" stopColor="#0a0c10" stopOpacity=".42" />
|
||||||
<stop offset="1" stopColor="#0a0c10" stopOpacity="0" />
|
<stop offset="1" stopColor="#0a0c10" stopOpacity="0" />
|
||||||
</radialGradient>
|
</radialGradient>
|
||||||
|
{STAR_TONES.map(([tone, color]) => (
|
||||||
|
<g key={tone}>
|
||||||
|
<radialGradient id={`${starId}-${tone}`}>
|
||||||
|
{GLOW_STOPS.map(([offset, opacity]) => <stop key={offset} offset={offset} stopColor={color} stopOpacity={opacity} />)}
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient id={`${starId}-halo-${tone}`}>
|
||||||
|
<stop offset="0" stopColor={color} stopOpacity=".16" />
|
||||||
|
<stop offset=".35" stopColor={color} stopOpacity=".07" />
|
||||||
|
<stop offset="1" stopColor={color} stopOpacity="0" />
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id={`${starId}-trail-${tone}`} gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="28" y2="0">
|
||||||
|
<stop offset="0" stopColor={color} stopOpacity=".8" />
|
||||||
|
<stop offset=".35" stopColor={color} stopOpacity=".32" />
|
||||||
|
<stop offset="1" stopColor={color} stopOpacity="0" />
|
||||||
|
</linearGradient>
|
||||||
|
</g>
|
||||||
|
))}
|
||||||
|
<radialGradient id={`${starId}-core`}>
|
||||||
|
<stop offset="0" stopColor="#fffaf0" stopOpacity="1" />
|
||||||
|
<stop offset=".45" stopColor="#fff3de" stopOpacity=".95" />
|
||||||
|
<stop offset="1" stopColor="#fff3de" stopOpacity="0" />
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient id={`${starId}-spike`} gradientUnits="userSpaceOnUse" x1="-14" y1="0" x2="14" y2="0">
|
||||||
|
<stop offset="0" stopColor="#fff2dc" stopOpacity="0" />
|
||||||
|
<stop offset=".5" stopColor="#fff2dc" stopOpacity=".9" />
|
||||||
|
<stop offset="1" stopColor="#fff2dc" stopOpacity="0" />
|
||||||
|
</linearGradient>
|
||||||
</defs>
|
</defs>
|
||||||
<g className="orbit-tracks" pointerEvents="none">
|
<g className="orbit-tracks" pointerEvents="none">
|
||||||
{orbitRadii.map((radius) => (
|
{orbitRadii.map((radius) => (
|
||||||
<ellipse key={radius} rx={radius} ry={radius * ORBIT_TILT} className={selectedSlot?.radius === radius ? "is-selected" : ""} />
|
<ellipse key={radius} rx={radius} ry={radius * ORBIT_TILT} className={selectedSlot?.radius === radius ? "is-selected" : ""}
|
||||||
|
ref={(node) => {
|
||||||
|
if (!node) return;
|
||||||
|
ringNodes.current.set(radius, node);
|
||||||
|
return () => { ringNodes.current.delete(radius); };
|
||||||
|
}} />
|
||||||
))}
|
))}
|
||||||
</g>
|
</g>
|
||||||
{svgCore ? <VaultCore ref={core} /> : <g ref={core} data-vault-core />}
|
{svgCore ? <VaultCore ref={core} /> : <g ref={core} data-vault-core />}
|
||||||
|
|||||||
@@ -338,14 +338,18 @@ button:disabled { cursor: default; }
|
|||||||
.legend-snapshot { border: 1px solid #dfe4ef; transform: rotate(45deg); }
|
.legend-snapshot { border: 1px solid #dfe4ef; transform: rotate(45deg); }
|
||||||
.galaxy-frame { width: 100%; max-width: calc((var(--workspace-height) - 120px) * 1.375); aspect-ratio: 11 / 8; align-self: center; justify-self: center; }
|
.galaxy-frame { width: 100%; max-width: calc((var(--workspace-height) - 120px) * 1.375); aspect-ratio: 11 / 8; align-self: center; justify-self: center; }
|
||||||
.galaxy-frame > svg { display: block; width: 100%; height: 100%; overflow: hidden; }
|
.galaxy-frame > svg { display: block; width: 100%; height: 100%; overflow: hidden; }
|
||||||
.orbit-tracks { fill: none; stroke: #949eaa; stroke-width: .75; opacity: .36; }
|
.orbit-tracks { fill: none; stroke: #949eaa; stroke-width: .75; }
|
||||||
.orbit-tracks .is-selected { stroke: #eebf92; stroke-dasharray: 3 4; stroke-width: 1.6; }
|
.orbit-tracks ellipse { stroke-opacity: var(--track, .12); }
|
||||||
|
.orbit-tracks .is-hover { stroke-opacity: .5; }
|
||||||
|
.orbit-tracks .is-selected { stroke: #eebf92; stroke-opacity: .85; stroke-dasharray: 3 4; stroke-width: 1.6; }
|
||||||
.orbit-marker { color: #c3c9d0; }
|
.orbit-marker { color: #c3c9d0; }
|
||||||
.orbit-marker--red { color: var(--color-orbit-red); }
|
.orbit-marker--red { color: var(--color-orbit-red); }
|
||||||
.orbit-marker--amber { color: var(--color-orbit-amber); }
|
.orbit-marker--amber { color: var(--color-orbit-amber); }
|
||||||
.orbit-marker--green { color: var(--color-orbit-green); }
|
.orbit-marker--green { color: var(--color-orbit-green); }
|
||||||
.orbit-light, .orbit-halo { fill: currentColor; pointer-events: none; }
|
.orbit-light, .orbit-halo { fill: currentColor; pointer-events: none; }
|
||||||
.orbit-light { stroke: #0a0c10; stroke-width: 1.4; }
|
.orbit-light { stroke: #0a0c10; stroke-width: 1.4; }
|
||||||
|
.marker-trail { pointer-events: none; }
|
||||||
|
.marker-star { pointer-events: none; }
|
||||||
.orbit-knockout { pointer-events: none; }
|
.orbit-knockout { pointer-events: none; }
|
||||||
.orbit-halo { opacity: .08; }
|
.orbit-halo { opacity: .08; }
|
||||||
.orbit-alert, .orbit-selection, .orbit-busy { fill: none; stroke: currentColor; stroke-width: 1.15; pointer-events: none; }
|
.orbit-alert, .orbit-selection, .orbit-busy { fill: none; stroke: currentColor; stroke-width: 1.15; pointer-events: none; }
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
import { cancelFrame, frame as frameLoop } from "motion/react";
|
import { cancelFrame, frame as frameLoop } from "motion/react";
|
||||||
import { farthestCornerM, layoutFor } from "./layout";
|
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 { CALIBRATION_SAMPLES, QUALITY_TIERS, chooseTier, initialTier } from "./quality";
|
||||||
import { createBlackholeRenderer, defaultParams, type BlackholeParams } from "./renderer";
|
import { createBlackholeRenderer, defaultParams, type BlackholeParams } from "./renderer";
|
||||||
|
|
||||||
/** What the scene tells the renderer each frame. The galaxy loop writes it and calls `wake`. */
|
/** 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 = {
|
export type BlackholeController = {
|
||||||
/** Ask for a redraw. Cheap to call every frame: draws are coalesced and capped by the quality tier. */
|
/** 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 sweepClock = 0;
|
||||||
let sweepAmount = 0;
|
let sweepAmount = 0;
|
||||||
let lastTick = 0;
|
let lastTick = 0;
|
||||||
|
let wave = waveParams(look, 0);
|
||||||
|
let lookChanged = true;
|
||||||
|
let wasWaving = false;
|
||||||
|
signal.lookAt = (radiusM) => styleAt(wave, radiusM);
|
||||||
|
|
||||||
const resize = () => {
|
const resize = () => {
|
||||||
if (!panel.clientWidth || !panel.clientHeight) return;
|
if (!panel.clientWidth || !panel.clientHeight) return;
|
||||||
@@ -131,7 +143,12 @@ export function createBlackholeController({ canvas, panel, frame, signal, onLost
|
|||||||
const width = panel.clientWidth;
|
const width = panel.clientWidth;
|
||||||
const height = panel.clientHeight;
|
const height = panel.clientHeight;
|
||||||
const maxRadius = farthestCornerM({ x: params.centerX * width, y: params.centerY * height }, { width, height }, params.pxPerM);
|
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;
|
const time = preset.maxFps > 0 ? signal.time : frozenTime;
|
||||||
params.sway = 0.06 * Math.sin(time * 0.05);
|
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);
|
if (instant || reduced) jumpLook(look, target);
|
||||||
else requestLook(look, target);
|
else requestLook(look, target);
|
||||||
lastTick = 0;
|
lastTick = 0;
|
||||||
|
lookChanged = true;
|
||||||
wake(true);
|
wake(true);
|
||||||
},
|
},
|
||||||
setReducedMotion: (value) => {
|
setReducedMotion: (value) => {
|
||||||
reduced = value;
|
reduced = value;
|
||||||
if (reduced && look.running) jumpLook(look, look.queued ?? look.to);
|
if (reduced && look.running) jumpLook(look, look.queued ?? look.to);
|
||||||
lastTick = 0;
|
lastTick = 0;
|
||||||
|
lookChanged = true;
|
||||||
wake(true);
|
wake(true);
|
||||||
},
|
},
|
||||||
dispose: () => {
|
dispose: () => {
|
||||||
|
signal.lookAt = undefined;
|
||||||
disposed = true;
|
disposed = true;
|
||||||
cancelFrame(tick);
|
cancelFrame(tick);
|
||||||
window.clearTimeout(calibrateTimer);
|
window.clearTimeout(calibrateTimer);
|
||||||
|
|||||||
@@ -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.
|
* ring (128) instead of covering the orbits, while staying in proportion to the shadow.
|
||||||
*/
|
*/
|
||||||
const SHADOW_SCENE_RADIUS = 34;
|
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. */
|
/** 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) {
|
export function layoutFor(frame: Box, panel: Box) {
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ export type LookTransition = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Close to critically damped: the front accelerates away from the hole and settles without overshoot. */
|
/** Close to critically damped: the front accelerates away from the hole and settles without overshoot. */
|
||||||
export const WAVE_STIFFNESS = 70;
|
export const WAVE_STIFFNESS = 16;
|
||||||
export const WAVE_DAMPING = 17;
|
export const WAVE_DAMPING = 8;
|
||||||
/** Softness of the front, in gravitational radii. */
|
/** Softness of the front, in gravitational radii. */
|
||||||
export const WAVE_FEATHER = 3;
|
export const WAVE_FEATHER = 3;
|
||||||
|
|
||||||
const SETTLED_PROGRESS = 0.999;
|
const SETTLED_PROGRESS = 0.995;
|
||||||
const SETTLED_SPEED = 0.01;
|
const SETTLED_SPEED = 0.01;
|
||||||
const SUBSTEP = 0.008;
|
const SUBSTEP = 0.008;
|
||||||
|
|
||||||
|
|||||||
@@ -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[] {
|
export function moonPoses(star: Vec2, count: number, distance: number, obstacles: Vec2[] = []): Vec2[] {
|
||||||
const direction = Math.atan2(star.y, star.x);
|
const direction = Math.atan2(star.y, star.x);
|
||||||
const margin = distance / 2;
|
const margin = distance / 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user