diff --git a/web/src/components/scene/BlackholeGalaxy.tsx b/web/src/components/scene/BlackholeGalaxy.tsx index af84b2d..08d2954 100644 --- a/web/src/components/scene/BlackholeGalaxy.tsx +++ b/web/src/components/scene/BlackholeGalaxy.tsx @@ -89,7 +89,7 @@ export function BlackholeGalaxy({ const lockLayout = useMemo(() => { const n = starOrbits.length; 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) => lockedSlot(i, n), @@ -163,9 +163,8 @@ export function BlackholeGalaxy({ d={arcs.back} fill="none" stroke="#6d84c4" - strokeOpacity={flowing ? 0.08 : 0.1} - strokeWidth={0.7} - strokeDasharray="2 10" + strokeOpacity={flowing ? 0.035 : 0.02} + strokeWidth={0.6} /> ); })} @@ -195,9 +194,9 @@ export function BlackholeGalaxy({ d={arcs.front} fill="none" stroke="#9aafdf" - strokeOpacity={flowing ? 0.2 : 0.12} - strokeWidth={0.9} - strokeDasharray="2 8" + strokeOpacity={flowing ? 0.18 : 0.05} + strokeWidth={0.85} + strokeDasharray="3 14" /> ); })} @@ -240,7 +239,7 @@ function StarLayer({ starOrbits: Orbit[]; snapsByOrbit: Map; lockLayout: { - moons: { x: number; y: number }[][]; + moons: ({ x: number; y: number } | null)[][]; labels: { x: number; y: number }[]; }; selectedSnapshotId?: string | null; @@ -266,20 +265,26 @@ function StarLayer({ const color = statusColor(orbit.last_status); const depthScale = pose.scale * blend + (1 - blend); 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 interactive = !flowing || blend < 0.15; 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 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 lockMp = lockMoons[mi]; + if (!lockMp && blend < 0.4) return []; const flowMp = { x: x + off.x * depthScale, y: y + off.y * depthScale }; const mp = lockMp ? lerpPos(flowMp, lockMp, blend) : flowMp; - const localZ = off.z; - return { moon, mp, localZ, off }; + return [{ moon, mp, localZ: off.z, off, mi, showRing: blend < 0.45 || mi === nearMoon }]; }); const moonsBehind = moonNodes.filter((m) => m.localZ < 0 || blend < 0.5); const moonsAhead = blend < 0.5 ? [] : moonNodes.filter((m) => m.localZ >= 0); @@ -298,6 +303,8 @@ function StarLayer({ r={mr} hitR={flowing ? mr : MOON_HIT_LOCK} rim={color} + ring={node.mi * 37 - 20} + showRing={node.showRing || !flowing} selected={sel} locked={!flowing} onClick={(e) => { @@ -397,32 +404,17 @@ function StarBody({ cy={y} r={r} fill="none" - stroke="#eef1ff" - strokeOpacity={locked ? 0.55 : 0.25} - strokeWidth={locked ? 1.2 : 0.6} + stroke={color} + strokeOpacity={locked ? 0.7 : 0.28} + strokeWidth={locked ? 1.1 : 0.55} + /> + - {locked && ( - <> - - - - )} ); } @@ -433,6 +425,8 @@ function MoonBody({ r, hitR, rim, + ring = -18, + showRing = true, selected, locked, opacity = 1, @@ -443,6 +437,8 @@ function MoonBody({ r: number; hitR: number; rim: string; + ring?: number; + showRing?: boolean; selected: boolean; locked: boolean; opacity?: number; @@ -457,17 +453,19 @@ function MoonBody({ {locked && ( )} - + {showRing && ( + + )} - - diff --git a/web/src/components/scene/SpaceBackdrop.tsx b/web/src/components/scene/SpaceBackdrop.tsx index 481784f..07230c0 100644 --- a/web/src/components/scene/SpaceBackdrop.tsx +++ b/web/src/components/scene/SpaceBackdrop.tsx @@ -21,6 +21,10 @@ export function SpaceBackdrop() { 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 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 -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]" /> diff --git a/web/src/lib/galaxyLabelLayout.ts b/web/src/lib/galaxyLabelLayout.ts index a7ed9e0..8c053e2 100644 --- a/web/src/lib/galaxyLabelLayout.ts +++ b/web/src/lib/galaxyLabelLayout.ts @@ -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; } diff --git a/web/src/lib/galaxyLayout.ts b/web/src/lib/galaxyLayout.ts index ea36142..1852682 100644 --- a/web/src/lib/galaxyLayout.ts +++ b/web/src/lib/galaxyLayout.ts @@ -43,11 +43,12 @@ export function positionOnEllipse(angle: number, phys: OrbitPhysics): Pose3 { const x = lx * Math.cos(node) - yInc * Math.sin(node); const y = lx * Math.sin(node) + yInc * Math.cos(node); const depth = zRaw / Math.max(phys.rx, 1); + const facing = (depth + 1) / 2; return { x, y, z: depth, - scale: 0.7 + (depth + 1) * 0.3, + scale: 0.38 + facing * 1.05, }; } @@ -160,11 +161,11 @@ export function flowMoonOffsets( spread = 30, ): Pose3[] { const out: Pose3[] = []; - const inc = 0.85; + const inc = 0.55; for (let mi = 0; mi < count; mi++) { const ang = (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 ly = Math.sin(ang) * rad; const y = ly * Math.cos(inc); @@ -191,16 +192,13 @@ export function moonPositions( const outward = Math.atan2(cy, cx); for (let mi = 0; mi < count; mi++) { const slice = (mi / Math.max(count, 1)) * Math.PI * 2; + const span = Math.PI * 0.7; const fan = - count <= 1 - ? 0 - : (mi - (count - 1) / 2) * (flowing ? 0.55 : 0.42); - const angle = flowing - ? slice + time * (0.85 + mi * 0.08) - : outward + fan; + count <= 1 ? 0 : (mi / Math.max(count - 1, 1) - 0.5) * span; + const angle = flowing ? slice + time * (0.85 + mi * 0.08) : outward + fan; const dist = flowing - ? baseSpread * (0.72 + (mi % 3) * 0.08) - : baseSpread + 8 + mi * 6; + ? Math.max(baseSpread, 44) + : 48 + mi * 8; out.push({ angle, x: cx + Math.cos(angle) * dist, @@ -210,27 +208,48 @@ export function moonPositions( 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( stars: Vec2[], moonsByStar: Vec2[][], -): Vec2[][] { - const flat: { p: Vec2; star: number; moon: number }[] = []; +): (Vec2 | null)[][] { + const flat: { p: Vec2; star: number; moon: number; drop: boolean }[] = []; for (let si = 0; si < moonsByStar.length; si++) { 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 minStarMoon = 28; + const minMoon = 20; + 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++) { + 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++) { const d = dist(flat[i].p, flat[j].p); 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 uy = (flat[i].p.y - flat[j].p.y) / d; flat[i].p.x += ux * push; @@ -239,19 +258,33 @@ export function relaxLockedMoons( 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); - flat[i].p.x = s.x + Math.cos(ang) * minStarMoon; - flat[i].p.y = s.y + Math.sin(ang) * minStarMoon; + } + } + + for (const moon of flat) { + const parent = stars[moon.star]; + 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) { - out[f.star][f.moon] = f.p; + out[f.star][f.moon] = f.drop ? null : f.p; } return out; }