Apply the eight galaxy visual refinements from the review

This commit is contained in:
Tessera Agent
2026-11-09 12:19:04 +00:00
parent 5b40536e37
commit 0ee32fcf8f
4 changed files with 172 additions and 96 deletions

View File

@@ -89,7 +89,7 @@ export function BlackholeGalaxy({
const lockLayout = useMemo(() => { const lockLayout = useMemo(() => {
const n = starOrbits.length; const n = starOrbits.length;
if (!n) { if (!n) {
return { stars: [] as { x: number; y: number }[], moons: [] as { x: number; y: number }[][], labels: [] as { x: number; y: number }[] }; return { stars: [] as { x: number; y: number }[], moons: [] as ({ x: number; y: number } | null)[][], labels: [] as { x: number; y: number }[] };
} }
const stars = Array.from({ length: n }, (_, i) => const stars = Array.from({ length: n }, (_, i) =>
lockedSlot(i, n), lockedSlot(i, n),
@@ -163,9 +163,8 @@ export function BlackholeGalaxy({
d={arcs.back} d={arcs.back}
fill="none" fill="none"
stroke="#6d84c4" stroke="#6d84c4"
strokeOpacity={flowing ? 0.08 : 0.1} strokeOpacity={flowing ? 0.035 : 0.02}
strokeWidth={0.7} strokeWidth={0.6}
strokeDasharray="2 10"
/> />
); );
})} })}
@@ -195,9 +194,9 @@ export function BlackholeGalaxy({
d={arcs.front} d={arcs.front}
fill="none" fill="none"
stroke="#9aafdf" stroke="#9aafdf"
strokeOpacity={flowing ? 0.2 : 0.12} strokeOpacity={flowing ? 0.18 : 0.05}
strokeWidth={0.9} strokeWidth={0.85}
strokeDasharray="2 8" strokeDasharray="3 14"
/> />
); );
})} })}
@@ -240,7 +239,7 @@ function StarLayer({
starOrbits: Orbit[]; starOrbits: Orbit[];
snapsByOrbit: Map<string, Snapshot[]>; snapsByOrbit: Map<string, Snapshot[]>;
lockLayout: { lockLayout: {
moons: { x: number; y: number }[][]; moons: ({ x: number; y: number } | null)[][];
labels: { x: number; y: number }[]; labels: { x: number; y: number }[];
}; };
selectedSnapshotId?: string | null; selectedSnapshotId?: string | null;
@@ -266,20 +265,26 @@ function StarLayer({
const color = statusColor(orbit.last_status); const color = statusColor(orbit.last_status);
const depthScale = pose.scale * blend + (1 - blend); const depthScale = pose.scale * blend + (1 - blend);
const starR = (flowing ? STAR_R_FLOW : STAR_R_LOCK) * depthScale; const starR = (flowing ? STAR_R_FLOW : STAR_R_LOCK) * depthScale;
const dim = 0.55 + ((pose.z + 1) / 2) * 0.45; const facing = (pose.z + 1) / 2;
const behind = pose.z < -0.08 ? 0.45 : 1;
const dim = (0.2 + facing * 0.8) * behind;
const opacity = dim * blend + (1 - blend); const opacity = dim * blend + (1 - blend);
const interactive = !flowing || blend < 0.15; const interactive = !flowing || blend < 0.15;
const label = lockLayout.labels[i]; const label = lockLayout.labels[i];
const flowOff = flowMoonOffsets(moons.length, t, 32); const flowOff = flowMoonOffsets(moons.length, t, 46);
const lockMoons = lockLayout.moons[i] ?? []; const lockMoons = lockLayout.moons[i] ?? [];
const moonNodes = moons.map((moon, mi) => { const nearMoon = flowOff.reduce(
(best, off, mi) => (off.z > best.z ? { z: off.z, mi } : best),
{ z: -Infinity, mi: 0 },
).mi;
const moonNodes = moons.flatMap((moon, mi) => {
const off = flowOff[mi]; const off = flowOff[mi];
const lockMp = lockMoons[mi]; const lockMp = lockMoons[mi];
if (!lockMp && blend < 0.4) return [];
const flowMp = { x: x + off.x * depthScale, y: y + off.y * depthScale }; const flowMp = { x: x + off.x * depthScale, y: y + off.y * depthScale };
const mp = lockMp ? lerpPos(flowMp, lockMp, blend) : flowMp; const mp = lockMp ? lerpPos(flowMp, lockMp, blend) : flowMp;
const localZ = off.z; return [{ moon, mp, localZ: off.z, off, mi, showRing: blend < 0.45 || mi === nearMoon }];
return { moon, mp, localZ, off };
}); });
const moonsBehind = moonNodes.filter((m) => m.localZ < 0 || blend < 0.5); const moonsBehind = moonNodes.filter((m) => m.localZ < 0 || blend < 0.5);
const moonsAhead = blend < 0.5 ? [] : moonNodes.filter((m) => m.localZ >= 0); const moonsAhead = blend < 0.5 ? [] : moonNodes.filter((m) => m.localZ >= 0);
@@ -298,6 +303,8 @@ function StarLayer({
r={mr} r={mr}
hitR={flowing ? mr : MOON_HIT_LOCK} hitR={flowing ? mr : MOON_HIT_LOCK}
rim={color} rim={color}
ring={node.mi * 37 - 20}
showRing={node.showRing || !flowing}
selected={sel} selected={sel}
locked={!flowing} locked={!flowing}
onClick={(e) => { onClick={(e) => {
@@ -397,32 +404,17 @@ function StarBody({
cy={y} cy={y}
r={r} r={r}
fill="none" 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} stroke={color}
strokeOpacity={0.35} strokeOpacity={locked ? 0.7 : 0.28}
strokeWidth={0.6} strokeWidth={locked ? 1.1 : 0.55}
/> />
<line <circle
x1={x} cx={x - r * 0.28}
y1={y - r * 1.4} cy={y - r * 0.32}
x2={x} r={Math.max(1.1, r * 0.22)}
y2={y + r * 1.4} fill="#ffffff"
stroke={color} opacity={locked ? 0.7 : 0.4}
strokeOpacity={0.35}
strokeWidth={0.6}
/> />
</>
)}
</g> </g>
); );
} }
@@ -433,6 +425,8 @@ function MoonBody({
r, r,
hitR, hitR,
rim, rim,
ring = -18,
showRing = true,
selected, selected,
locked, locked,
opacity = 1, opacity = 1,
@@ -443,6 +437,8 @@ function MoonBody({
r: number; r: number;
hitR: number; hitR: number;
rim: string; rim: string;
ring?: number;
showRing?: boolean;
selected: boolean; selected: boolean;
locked: boolean; locked: boolean;
opacity?: number; opacity?: number;
@@ -457,6 +453,7 @@ function MoonBody({
{locked && ( {locked && (
<circle cx={x} cy={y} r={hitR} fill="transparent" /> <circle cx={x} cy={y} r={hitR} fill="transparent" />
)} )}
{showRing && (
<ellipse <ellipse
cx={x} cx={x}
cy={y} cy={y}
@@ -464,10 +461,11 @@ function MoonBody({
ry={r * 0.38} ry={r * 0.38}
fill="none" fill="none"
stroke={selected ? "#e8ecff" : rim} stroke={selected ? "#e8ecff" : rim}
strokeOpacity={locked ? 0.45 : 0.3} strokeOpacity={locked ? 0.45 : 0.35}
strokeWidth={0.7} strokeWidth={0.7}
transform={`rotate(-18 ${x} ${y})`} transform={`rotate(${ring} ${x} ${y})`}
/> />
)}
<circle <circle
cx={x} cx={x}
cy={y} cy={y}
@@ -534,16 +532,6 @@ function BlackHoleCore({
<g> <g>
<circle cx="0" cy="0" r={148 * breathe} fill="url(#bhHalo)" opacity={0.5} /> <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} /> <circle cx="0" cy="0" r="132" fill="url(#bhCore)" opacity={0.92} />
<ellipse
cx="0"
cy="0"
rx="124"
ry="124"
fill="none"
stroke="#e8b86a"
strokeOpacity={0.42}
strokeWidth="1.2"
/>
<ellipse <ellipse
cx={wobble} cx={wobble}
cy="0" cy="0"
@@ -564,17 +552,13 @@ function BlackHoleCore({
opacity={0.38} opacity={0.38}
transform={`rotate(${-diskRot * 1.35 + 12})`} transform={`rotate(${-diskRot * 1.35 + 12})`}
/> />
<ellipse <path
cx="0" d="M -86 12 A 108 34 0 0 0 86 12"
cy="0"
rx="76"
ry="76"
fill="none" fill="none"
stroke="#f0c468" stroke="#f4d48a"
strokeOpacity={0.22} strokeOpacity={0.7}
strokeWidth="0.8" strokeWidth="1.35"
strokeDasharray="2 6" strokeLinecap="round"
transform={`rotate(${diskRot * 2})`}
/> />
<g className="cursor-pointer" onClick={onToggle}> <g className="cursor-pointer" onClick={onToggle}>
<title> <title>

View File

@@ -21,6 +21,10 @@ export function SpaceBackdrop() {
aria-hidden aria-hidden
> >
<div className="absolute inset-0 bg-[radial-gradient(ellipse_120%_80%_at_50%_45%,rgba(22,28,58,0.55)_0%,rgba(4,5,12,1)_72%)]" /> <div className="absolute inset-0 bg-[radial-gradient(ellipse_120%_80%_at_50%_45%,rgba(22,28,58,0.55)_0%,rgba(4,5,12,1)_72%)]" />
<div
className="absolute left-1/2 top-1/2 h-[22vmin] w-[78vmin] -translate-x-1/2 -translate-y-1/2 rounded-full bg-gradient-to-r from-violet-500/10 via-amber-200/16 to-violet-400/10 blur-3xl"
aria-hidden
/>
<div className="absolute -left-[20%] top-[10%] h-[55vmin] w-[55vmin] rounded-full bg-indigo-900/12 blur-[100px]" /> <div className="absolute -left-[20%] top-[10%] h-[55vmin] w-[55vmin] rounded-full bg-indigo-900/12 blur-[100px]" />
<div className="absolute -right-[15%] bottom-[5%] h-[45vmin] w-[50vmin] rounded-full bg-violet-900/10 blur-[90px]" /> <div className="absolute -right-[15%] bottom-[5%] h-[45vmin] w-[50vmin] rounded-full bg-violet-900/10 blur-[90px]" />
<div className="absolute left-[30%] bottom-[20%] h-[30vmin] w-[40vmin] rounded-full bg-cyan-950/8 blur-[80px]" /> <div className="absolute left-[30%] bottom-[20%] h-[30vmin] w-[40vmin] rounded-full bg-cyan-950/8 blur-[80px]" />

View File

@@ -74,6 +74,61 @@ export function layoutLockLabels(
} }
} }
const yMin = -160;
const yMax = 108;
const xMin = -230;
const xMax = 230;
for (let i = 0; i < labels.length; i++) {
const star = starPositions[i];
const hitsChrome =
labels[i].y < yMin ||
labels[i].y > yMax ||
labels[i].x < xMin ||
labels[i].x > xMax;
const hitsNeighbor = starPositions.some(
(other, k) => k !== i && dist(labels[i], other) < starR + 20,
);
if (hitsChrome || hitsNeighbor) {
const ang = Math.atan2(star.y, star.x);
labels[i] = {
x: star.x - Math.cos(ang) * (starR + 34),
y: star.y - Math.sin(ang) * (starR + 34),
};
}
labels[i].x = Math.max(xMin, Math.min(xMax, labels[i].x));
labels[i].y = Math.max(yMin, Math.min(yMax, labels[i].y));
const gap = dist(labels[i], star);
if (gap < starR + 16) {
const ang = Math.atan2(labels[i].y - star.y, labels[i].x - star.x) || 0;
labels[i].x = star.x + Math.cos(ang) * (starR + 18);
labels[i].y = Math.max(
yMin,
Math.min(yMax, star.y + Math.sin(ang) * (starR + 18)),
);
}
}
for (let iter = 0; iter < 24; iter++) {
for (let i = 0; i < labels.length; i++) {
for (let j = i + 1; j < labels.length; j++) {
const wi = labelWidth(names[i]);
const wj = labelWidth(names[j]);
const dx = labels[j].x - labels[i].x;
const dy = labels[j].y - labels[i].y;
const needX = (wi + wj) / 2 + 8;
const needY = LABEL_H + 6;
if (Math.abs(dx) < needX && Math.abs(dy) < needY) {
const push = (needX - Math.abs(dx)) * 0.55 + 1;
const dir = dx === 0 ? (i % 2 === 0 ? -1 : 1) : Math.sign(dx);
labels[i].x -= dir * push;
labels[j].x += dir * push;
}
}
labels[i].x = Math.max(xMin, Math.min(xMax, labels[i].x));
labels[i].y = Math.max(yMin, Math.min(yMax, labels[i].y));
}
}
return labels; return labels;
} }

View File

@@ -43,11 +43,12 @@ export function positionOnEllipse(angle: number, phys: OrbitPhysics): Pose3 {
const x = lx * Math.cos(node) - yInc * Math.sin(node); const x = lx * Math.cos(node) - yInc * Math.sin(node);
const y = lx * Math.sin(node) + yInc * Math.cos(node); const y = lx * Math.sin(node) + yInc * Math.cos(node);
const depth = zRaw / Math.max(phys.rx, 1); const depth = zRaw / Math.max(phys.rx, 1);
const facing = (depth + 1) / 2;
return { return {
x, x,
y, y,
z: depth, z: depth,
scale: 0.7 + (depth + 1) * 0.3, scale: 0.38 + facing * 1.05,
}; };
} }
@@ -160,11 +161,11 @@ export function flowMoonOffsets(
spread = 30, spread = 30,
): Pose3[] { ): Pose3[] {
const out: Pose3[] = []; const out: Pose3[] = [];
const inc = 0.85; const inc = 0.55;
for (let mi = 0; mi < count; mi++) { for (let mi = 0; mi < count; mi++) {
const ang = const ang =
(mi / Math.max(count, 1)) * Math.PI * 2 + time * (1.05 + mi * 0.08); (mi / Math.max(count, 1)) * Math.PI * 2 + time * (1.05 + mi * 0.08);
const rad = spread * (0.82 + (mi % 3) * 0.1); const rad = Math.max(spread, 44) * (1 + mi * 0.05);
const lx = Math.cos(ang) * rad; const lx = Math.cos(ang) * rad;
const ly = Math.sin(ang) * rad; const ly = Math.sin(ang) * rad;
const y = ly * Math.cos(inc); const y = ly * Math.cos(inc);
@@ -191,16 +192,13 @@ export function moonPositions(
const outward = Math.atan2(cy, cx); const outward = Math.atan2(cy, cx);
for (let mi = 0; mi < count; mi++) { for (let mi = 0; mi < count; mi++) {
const slice = (mi / Math.max(count, 1)) * Math.PI * 2; const slice = (mi / Math.max(count, 1)) * Math.PI * 2;
const span = Math.PI * 0.7;
const fan = const fan =
count <= 1 count <= 1 ? 0 : (mi / Math.max(count - 1, 1) - 0.5) * span;
? 0 const angle = flowing ? slice + time * (0.85 + mi * 0.08) : outward + fan;
: (mi - (count - 1) / 2) * (flowing ? 0.55 : 0.42);
const angle = flowing
? slice + time * (0.85 + mi * 0.08)
: outward + fan;
const dist = flowing const dist = flowing
? baseSpread * (0.72 + (mi % 3) * 0.08) ? Math.max(baseSpread, 44)
: baseSpread + 8 + mi * 6; : 48 + mi * 8;
out.push({ out.push({
angle, angle,
x: cx + Math.cos(angle) * dist, x: cx + Math.cos(angle) * dist,
@@ -210,27 +208,48 @@ export function moonPositions(
return out; return out;
} }
/** Push overlapping moons apart in lock mode (all stars). */ /**
* Keep lock moons on the outward side of their star, outside the corona.
* A moon that would cross a neighbor star is dropped (null).
*/
export function relaxLockedMoons( export function relaxLockedMoons(
stars: Vec2[], stars: Vec2[],
moonsByStar: Vec2[][], moonsByStar: Vec2[][],
): Vec2[][] { ): (Vec2 | null)[][] {
const flat: { p: Vec2; star: number; moon: number }[] = []; const flat: { p: Vec2; star: number; moon: number; drop: boolean }[] = [];
for (let si = 0; si < moonsByStar.length; si++) { for (let si = 0; si < moonsByStar.length; si++) {
for (let mi = 0; mi < moonsByStar[si].length; mi++) { for (let mi = 0; mi < moonsByStar[si].length; mi++) {
flat.push({ p: { ...moonsByStar[si][mi] }, star: si, moon: mi }); flat.push({ p: { ...moonsByStar[si][mi] }, star: si, moon: mi, drop: false });
} }
} }
const minMoon = 22; const minMoon = 20;
const minStarMoon = 28; const minStarMoon = 46;
for (let iter = 0; iter < 40; iter++) { for (let iter = 0; iter < 28; iter++) {
for (let i = 0; i < flat.length; i++) { for (let i = 0; i < flat.length; i++) {
const s = stars[flat[i].star];
const outward = Math.atan2(s.y, s.x);
const ang = Math.atan2(flat[i].p.y - s.y, flat[i].p.x - s.x);
let delta = ang - outward;
while (delta > Math.PI) delta -= Math.PI * 2;
while (delta < -Math.PI) delta += Math.PI * 2;
if (Math.abs(delta) > Math.PI * 0.42) {
const clamped = outward + Math.sign(delta || 1) * Math.PI * 0.42;
const ds = Math.max(dist(flat[i].p, s), minStarMoon);
flat[i].p.x = s.x + Math.cos(clamped) * ds;
flat[i].p.y = s.y + Math.sin(clamped) * ds;
}
const ds = dist(flat[i].p, s);
if (ds < minStarMoon) {
const a = Math.atan2(flat[i].p.y - s.y, flat[i].p.x - s.x);
flat[i].p.x = s.x + Math.cos(a) * minStarMoon;
flat[i].p.y = s.y + Math.sin(a) * minStarMoon;
}
for (let j = i + 1; j < flat.length; j++) { for (let j = i + 1; j < flat.length; j++) {
const d = dist(flat[i].p, flat[j].p); const d = dist(flat[i].p, flat[j].p);
if (d < minMoon && d > 0.001) { if (d < minMoon && d > 0.001) {
const push = (minMoon - d) * 0.55; const push = (minMoon - d) * 0.5;
const ux = (flat[i].p.x - flat[j].p.x) / d; const ux = (flat[i].p.x - flat[j].p.x) / d;
const uy = (flat[i].p.y - flat[j].p.y) / d; const uy = (flat[i].p.y - flat[j].p.y) / d;
flat[i].p.x += ux * push; flat[i].p.x += ux * push;
@@ -239,19 +258,33 @@ export function relaxLockedMoons(
flat[j].p.y -= uy * push; flat[j].p.y -= uy * push;
} }
} }
const s = stars[flat[i].star]; }
const ds = dist(flat[i].p, s); }
if (ds < minStarMoon && ds > 0.001) {
const ang = Math.atan2(flat[i].p.y - s.y, flat[i].p.x - s.x); for (const moon of flat) {
flat[i].p.x = s.x + Math.cos(ang) * minStarMoon; const parent = stars[moon.star];
flat[i].p.y = s.y + Math.sin(ang) * minStarMoon; for (let si = 0; si < stars.length; si++) {
if (si === moon.star) continue;
if (dist(moon.p, stars[si]) < 40) {
moon.drop = true;
break;
}
}
if (dist(moon.p, parent) < 40) moon.drop = true;
if (moon.p.y > 128 || moon.p.y < -185) {
const side = moon.p.x >= parent.x ? 1 : -1;
const ds = Math.max(dist(moon.p, parent), 46);
moon.p.x = parent.x + side * ds;
moon.p.y = Math.max(-175, Math.min(120, parent.y));
for (let si = 0; si < stars.length; si++) {
if (si !== moon.star && dist(moon.p, stars[si]) < 40) moon.drop = true;
} }
} }
} }
const out = moonsByStar.map((row) => row.map(() => ({ x: 0, y: 0 }))); const out: (Vec2 | null)[][] = moonsByStar.map((row) => row.map(() => null));
for (const f of flat) { for (const f of flat) {
out[f.star][f.moon] = f.p; out[f.star][f.moon] = f.drop ? null : f.p;
} }
return out; return out;
} }