Graphics pass: calm space backdrop, refined BH/stars, label solver

This commit is contained in:
Tessera Agent
2026-11-09 11:10:39 +00:00
parent 2085b35cfa
commit 6646c12ab1
5 changed files with 463 additions and 102 deletions

View File

@@ -7,11 +7,15 @@ import {
moonPositions,
positionOnEllipse,
} from "../../lib/galaxyLayout";
import {
layoutLockLabels,
shortenOrbitName,
} from "../../lib/galaxyLabelLayout";
import { easeOutCubic, useGalaxyTime } from "../../hooks/useGalaxyMotion";
const MAX_STARS = 20;
const MAX_MOONS = 6;
const STAR_R_FLOW = 7.5;
const STAR_R_FLOW = 8;
const STAR_R_LOCK = 12;
const HIT_R_LOCK = 20;
const MOON_HIT_LOCK = 14;
@@ -76,13 +80,19 @@ export function BlackholeGalaxy({
return () => cancelAnimationFrame(raf);
}, [flowing]);
const starOrbits = useMemo(
() => orbits.slice(0, MAX_STARS),
[orbits],
);
const starOrbits = useMemo(() => orbits.slice(0, MAX_STARS), [orbits]);
const snapsByOrbit = useMemo(() => groupSnaps(snapshots), [snapshots]);
const lockLabels = useMemo(() => {
const positions = starOrbits.map((_, i) =>
lockedSlot(i, starOrbits.length),
);
const names = starOrbits.map((o) => o.name);
return layoutLockLabels(positions, names, STAR_R_LOCK);
}, [starOrbits]);
const showLabels = !flowing || blend < 0.35;
return (
<div className="absolute inset-0 flex items-center justify-center pt-16 pb-24 px-6 sm:px-10 pointer-events-auto">
<svg
@@ -95,21 +105,35 @@ export function BlackholeGalaxy({
<defs>
<radialGradient id="bhCore" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#000" />
<stop offset="55%" stopColor="#0a0614" />
<stop offset="45%" stopColor="#08040f" />
<stop offset="100%" stopColor="transparent" />
</radialGradient>
<radialGradient id="bhDisk" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#c4b5fd" stopOpacity="0.85" />
<stop offset="45%" stopColor="#f0c468" stopOpacity="0.45" />
<radialGradient id="bhHalo" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#a78bfa" stopOpacity="0.35" />
<stop offset="70%" stopColor="#4a3d7a" stopOpacity="0.08" />
<stop offset="100%" stopColor="transparent" />
</radialGradient>
<filter id="glow">
<feGaussianBlur stdDeviation="2.5" result="b" />
<linearGradient id="bhDiskWarm" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stopColor="#c4b5fd" stopOpacity="0.35" />
<stop offset="38%" stopColor="#f0c468" stopOpacity="0.95" />
<stop offset="62%" stopColor="#e8b86a" stopOpacity="0.9" />
<stop offset="100%" stopColor="#7c6abf" stopOpacity="0.25" />
</linearGradient>
<radialGradient id="moonRock" cx="35%" cy="30%" r="65%">
<stop offset="0%" stopColor="#2a3558" />
<stop offset="55%" stopColor="#12182f" />
<stop offset="100%" stopColor="#070a14" />
</radialGradient>
<filter id="glow" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur stdDeviation="2.2" result="b" />
<feMerge>
<feMergeNode in="b" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
<filter id="corona" x="-80%" y="-80%" width="260%" height="260%">
<feGaussianBlur stdDeviation="4" />
</filter>
</defs>
{starOrbits.map((orbit, i) => {
@@ -122,10 +146,10 @@ export function BlackholeGalaxy({
rx={phys.rx}
ry={phys.ry}
fill="none"
stroke="#3d4f8c"
strokeOpacity={flowing ? 0.1 : 0.22}
strokeWidth="0.8"
strokeDasharray="4 8"
stroke="#4a5f9e"
strokeOpacity={flowing ? 0.07 : 0.16}
strokeWidth="0.7"
strokeDasharray="3 10"
transform={`rotate(${phys.tiltDeg})`}
/>
);
@@ -148,6 +172,7 @@ export function BlackholeGalaxy({
const color = statusColor(orbit.last_status);
const starR = flowing ? STAR_R_FLOW : STAR_R_LOCK;
const interactive = !flowing || blend < 0.15;
const label = lockLabels[i];
const moonPts = moonPositions(
x,
@@ -159,7 +184,7 @@ export function BlackholeGalaxy({
);
return (
<g key={orbit.id} filter="url(#glow)">
<g key={orbit.id}>
{!flowing && (
<circle
cx={x}
@@ -173,16 +198,14 @@ export function BlackholeGalaxy({
}}
/>
)}
<circle
cx={x}
cy={y}
<StarBody
id={orbit.id}
x={x}
y={y}
r={starR}
fill={color}
fillOpacity={0.9}
stroke="#eef1ff"
strokeOpacity={0.4}
strokeWidth={flowing ? 0.5 : 1}
className={interactive ? "cursor-pointer" : "pointer-events-none"}
color={color}
locked={!flowing}
interactive={interactive}
onClick={(e) => {
e.stopPropagation();
if (!flowing) onSelectOrbit(orbit.id);
@@ -191,53 +214,31 @@ export function BlackholeGalaxy({
{moons.map((moon, mi) => {
const mp = moonPts[mi];
const sel = moon.id === selectedSnapshotId;
const mr = flowing ? 3.5 : sel ? 8 : 6;
const mr = flowing ? 3.8 : sel ? 7.5 : 6;
const hit = flowing ? mr : MOON_HIT_LOCK;
return (
<g key={moon.id}>
{!flowing && (
<circle
cx={mp.x}
cy={mp.y}
r={hit}
fill="transparent"
className="cursor-pointer"
onClick={(e) => {
e.stopPropagation();
onSelectSnapshot(moon.id);
}}
/>
)}
<circle
cx={mp.x}
cy={mp.y}
r={mr}
fill={sel ? "#a78bfa" : "#12182f"}
stroke={sel ? "#e8ecff" : color}
strokeWidth={flowing ? 0.5 : 1}
className={!flowing ? "cursor-pointer" : "pointer-events-none"}
opacity={flowing ? 0.55 : 1}
onClick={(e) => {
e.stopPropagation();
if (!flowing) onSelectSnapshot(moon.id);
}}
/>
</g>
<MoonBody
key={moon.id}
x={mp.x}
y={mp.y}
r={mr}
hitR={hit}
rim={color}
selected={sel}
locked={!flowing}
onClick={(e) => {
e.stopPropagation();
if (!flowing) onSelectSnapshot(moon.id);
}}
/>
);
})}
{!flowing && (
<text
x={x}
y={y - starR - 10}
textAnchor="middle"
fill="#c9d2f5"
fontSize="11"
className="font-mono pointer-events-none"
>
{orbit.name.length > 16
? `${orbit.name.slice(0, 14)}…`
: orbit.name}
</text>
{showLabels && (
<LockLabel
x={label.x}
y={label.y}
text={shortenOrbitName(orbit.name)}
/>
)}
</g>
);
@@ -247,6 +248,167 @@ export function BlackholeGalaxy({
);
}
function StarBody({
id,
x,
y,
r,
color,
locked,
interactive,
onClick,
}: {
id: string;
x: number;
y: number;
r: number;
color: string;
locked: boolean;
interactive: boolean;
onClick: (e: React.MouseEvent<SVGGElement>) => void;
}) {
const gradId = `star-${id.slice(0, 8)}`;
return (
<g
filter={locked ? "url(#glow)" : undefined}
className={interactive ? "cursor-pointer" : "pointer-events-none"}
onClick={onClick}
>
<defs>
<radialGradient id={gradId} cx="38%" cy="32%" r="65%">
<stop offset="0%" stopColor="#ffffff" stopOpacity={0.95} />
<stop offset="35%" stopColor={color} stopOpacity={1} />
<stop offset="100%" stopColor={color} stopOpacity={0.15} />
</radialGradient>
</defs>
<circle
cx={x}
cy={y}
r={r * 1.65}
fill={color}
opacity={locked ? 0.22 : 0.14}
filter="url(#corona)"
/>
<circle cx={x} cy={y} r={r} fill={`url(#${gradId})`} />
<circle
cx={x}
cy={y}
r={r}
fill="none"
stroke="#eef1ff"
strokeOpacity={locked ? 0.55 : 0.25}
strokeWidth={locked ? 1.2 : 0.6}
/>
{locked && (
<>
<line
x1={x - r * 1.4}
y1={y}
x2={x + r * 1.4}
y2={y}
stroke={color}
strokeOpacity={0.35}
strokeWidth={0.6}
/>
<line
x1={x}
y1={y - r * 1.4}
x2={x}
y2={y + r * 1.4}
stroke={color}
strokeOpacity={0.35}
strokeWidth={0.6}
/>
</>
)}
</g>
);
}
function MoonBody({
x,
y,
r,
hitR,
rim,
selected,
locked,
onClick,
}: {
x: number;
y: number;
r: number;
hitR: number;
rim: string;
selected: boolean;
locked: boolean;
onClick: (e: React.MouseEvent<SVGGElement>) => void;
}) {
return (
<g className={locked ? "cursor-pointer" : "pointer-events-none"} onClick={onClick}>
{locked && (
<circle cx={x} cy={y} r={hitR} fill="transparent" />
)}
<ellipse
cx={x}
cy={y}
rx={r * 1.9}
ry={r * 0.38}
fill="none"
stroke={selected ? "#e8ecff" : rim}
strokeOpacity={locked ? 0.45 : 0.3}
strokeWidth={0.7}
transform={`rotate(-18 ${x} ${y})`}
/>
<circle
cx={x}
cy={y}
r={r}
fill={selected ? "#a78bfa" : "url(#moonRock)"}
stroke={selected ? "#e8ecff" : rim}
strokeWidth={locked ? 1 : 0.5}
opacity={locked ? 1 : 0.6}
/>
<circle
cx={x - r * 0.25}
cy={y - r * 0.28}
r={r * 0.22}
fill="#eef1ff"
opacity={0.12}
/>
</g>
);
}
function LockLabel({ x, y, text }: { x: number; y: number; text: string }) {
const w = Math.max(text.length * 6.4 + 10, 36);
return (
<g className="pointer-events-none">
<rect
x={x - w / 2}
y={y - 8}
width={w}
height={16}
rx={4}
fill="#04050c"
fillOpacity={0.72}
stroke="#1e2647"
strokeWidth={0.6}
/>
<text
x={x}
y={y + 4}
textAnchor="middle"
fill="#c9d2f5"
fontSize="10"
className="font-mono"
>
{text}
</text>
</g>
);
}
function BlackHoleCore({
t,
flowing,
@@ -256,45 +418,84 @@ function BlackHoleCore({
flowing: boolean;
onToggle: () => void;
}) {
const diskRot = flowing ? t * 22 : 0;
const diskRot = flowing ? t * 18 : 0;
const breathe = 0.92 + 0.08 * Math.sin(t * 1.15);
const wobble = flowing ? Math.sin(t * 0.7) * 2 : 0;
return (
<g className="cursor-pointer" onClick={onToggle}>
<title>{flowing ? "Click to lock vault for targeting" : "Click to resume galaxy flow"}</title>
<circle cx="0" cy="0" r="132" fill="url(#bhCore)" opacity="0.85" />
<g>
<circle cx="0" cy="0" r={148 * breathe} fill="url(#bhHalo)" opacity={0.5} />
<circle cx="0" cy="0" r="132" fill="url(#bhCore)" opacity={0.92} />
<ellipse
cx="0"
cy="0"
rx="118"
ry="32"
rx="124"
ry="124"
fill="none"
stroke="url(#bhDisk)"
strokeWidth="16"
opacity="0.7"
stroke="#e8b86a"
strokeOpacity={0.42}
strokeWidth="1.2"
/>
<ellipse
cx={wobble}
cy="0"
rx="118"
ry="34"
fill="none"
stroke="url(#bhDiskWarm)"
strokeWidth="14"
opacity={0.78}
transform={`rotate(${diskRot})`}
/>
<ellipse
cx="0"
cx={-wobble * 0.6}
cy="0"
rx="86"
ry="22"
fill="url(#bhDisk)"
opacity="0.55"
transform={`rotate(${-diskRot * 1.4 + 14})`}
rx="88"
ry="24"
fill="url(#bhDiskWarm)"
opacity={0.38}
transform={`rotate(${-diskRot * 1.35 + 12})`}
/>
<circle cx="0" cy="0" r="38" fill="#000" stroke="#a78bfa" strokeOpacity="0.7" strokeWidth="2" />
<circle
<ellipse
cx="0"
cy="0"
r="122"
rx="76"
ry="76"
fill="none"
stroke="#a78bfa"
strokeOpacity={flowing ? 0.12 : 0.28}
strokeWidth="1"
strokeDasharray="6 10"
stroke="#f0c468"
strokeOpacity={0.22}
strokeWidth="0.8"
strokeDasharray="2 6"
transform={`rotate(${diskRot * 2})`}
/>
<text y="6" textAnchor="middle" fill="#94a3d4" fontSize="14" className="font-mono pointer-events-none">
VAULT
</text>
<g className="cursor-pointer" onClick={onToggle}>
<title>
{flowing
? "Click to lock vault for targeting"
: "Click to resume galaxy flow"}
</title>
<circle cx="0" cy="0" r="40" fill="#000" stroke="#a78bfa" strokeOpacity="0.75" strokeWidth="2" />
<circle
cx="0"
cy="0"
r="122"
fill="none"
stroke="#a78bfa"
strokeOpacity={flowing ? 0.1 : 0.32}
strokeWidth="1"
strokeDasharray="5 12"
/>
<text
y="5"
textAnchor="middle"
fill="#b8c0e8"
fontSize="13"
className="font-mono pointer-events-none"
opacity={0.9}
>
VAULT
</text>
</g>
</g>
);
}