diff --git a/web/scripts/capture-galaxy.mjs b/web/scripts/capture-galaxy.mjs new file mode 100644 index 0000000..76304d0 --- /dev/null +++ b/web/scripts/capture-galaxy.mjs @@ -0,0 +1,21 @@ +import { chromium } from "playwright"; + +const base = process.env.TESSERA_URL ?? "http://127.0.0.1:8787/"; +const outFlow = + process.env.FLOW_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-flow-polish.png"; +const outLock = + process.env.LOCK_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-locked-polish.png"; + +const browser = await chromium.launch({ headless: true }); +const page = await browser.newPage({ viewport: { width: 1440, height: 900 } }); +await page.goto(base, { waitUntil: "networkidle", timeout: 30_000 }); +await page.waitForTimeout(2500); +await page.screenshot({ path: outFlow, fullPage: false }); +const svg = page.locator('[aria-label="Galaxy vault viewport"]'); +const box = await svg.boundingBox(); +if (!box) throw new Error("galaxy svg not found"); +await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2); +await page.waitForTimeout(1400); +await page.screenshot({ path: outLock, fullPage: false }); +await browser.close(); +console.log("saved", outFlow, outLock); diff --git a/web/src/components/scene/BlackholeGalaxy.tsx b/web/src/components/scene/BlackholeGalaxy.tsx index f321f97..02f729e 100644 --- a/web/src/components/scene/BlackholeGalaxy.tsx +++ b/web/src/components/scene/BlackholeGalaxy.tsx @@ -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 (
- + - - - + + + - - + + + + + + + + + + + + + + + + {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 ( - + {!flowing && ( )} - { 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 ( - - {!flowing && ( - { - e.stopPropagation(); - onSelectSnapshot(moon.id); - }} - /> - )} - { - e.stopPropagation(); - if (!flowing) onSelectSnapshot(moon.id); - }} - /> - + { + e.stopPropagation(); + if (!flowing) onSelectSnapshot(moon.id); + }} + /> ); })} - {!flowing && ( - - {orbit.name.length > 16 - ? `${orbit.name.slice(0, 14)}…` - : orbit.name} - + {showLabels && ( + )} ); @@ -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) => void; +}) { + const gradId = `star-${id.slice(0, 8)}`; + return ( + + + + + + + + + + + + {locked && ( + <> + + + + )} + + ); +} + +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) => void; +}) { + return ( + + {locked && ( + + )} + + + + + ); +} + +function LockLabel({ x, y, text }: { x: number; y: number; text: string }) { + const w = Math.max(text.length * 6.4 + 10, 36); + return ( + + + + {text} + + + ); +} + 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 ( - - {flowing ? "Click to lock vault for targeting" : "Click to resume galaxy flow"} - + + + + - - - - VAULT - + + + {flowing + ? "Click to lock vault for targeting" + : "Click to resume galaxy flow"} + + + + + VAULT + + ); } diff --git a/web/src/components/scene/SpaceBackdrop.tsx b/web/src/components/scene/SpaceBackdrop.tsx new file mode 100644 index 0000000..481784f --- /dev/null +++ b/web/src/components/scene/SpaceBackdrop.tsx @@ -0,0 +1,58 @@ +import { useMemo } from "react"; + +/** Calm, non-interactive deep-space layer behind the galaxy SVG. */ +export function SpaceBackdrop() { + const stars = useMemo( + () => + Array.from({ length: 28 }, (_, i) => ({ + id: i, + left: `${(i * 19 + 5) % 100}%`, + top: `${(i * 29 + 13) % 100}%`, + size: i % 5 === 0 ? 1.5 : 1, + opacity: 0.12 + (i % 4) * 0.06, + delay: `${(i % 11) * 0.9}s`, + })), + [], + ); + + return ( +
+
+
+
+
+
+ {stars.map((s) => ( + + ))} +
+ +
+ ); +} diff --git a/web/src/components/scene/VaultScene.tsx b/web/src/components/scene/VaultScene.tsx index 6891d04..9633b5a 100644 --- a/web/src/components/scene/VaultScene.tsx +++ b/web/src/components/scene/VaultScene.tsx @@ -1,6 +1,6 @@ import { motion } from "motion/react"; import type { Orbit, Snapshot } from "../../api"; -import { Starfield } from "./Starfield"; +import { SpaceBackdrop } from "./SpaceBackdrop"; import { BlackholeGalaxy } from "./BlackholeGalaxy"; export function VaultScene({ @@ -23,16 +23,15 @@ export function VaultScene({ capturing?: boolean; }) { return ( -
-
- +
+ 16 ? 15 : name.length; + return n * CHAR_W; +} + +function dist(a: LabelPlacement, b: LabelPlacement): number { + return Math.hypot(a.x - b.x, a.y - b.y); +} + +/** Radial outward labels with simple bbox separation (lock mode). */ +export function layoutLockLabels( + starPositions: Vec2[], + names: string[], + starR: number, +): LabelPlacement[] { + const vaultPad = 52; + const labels: LabelPlacement[] = starPositions.map((p, i) => { + const ang = Math.atan2(p.y, p.x); + const base = starR + 20; + return { + x: p.x + Math.cos(ang) * base, + y: p.y + Math.sin(ang) * base, + }; + }); + + for (let iter = 0; iter < 28; iter++) { + for (let i = 0; i < labels.length; i++) { + const p = starPositions[i]; + const r = dist(labels[i], { x: 0, y: 0 }); + if (r < vaultPad) { + const ang = Math.atan2(labels[i].y, labels[i].x); + labels[i].x = Math.cos(ang) * vaultPad; + labels[i].y = Math.sin(ang) * vaultPad; + } + + 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 + LABEL_PAD; + const needY = LABEL_H + LABEL_PAD; + if (Math.abs(dx) < needX && Math.abs(dy) < needY) { + const push = (needX - Math.abs(dx) + needY - Math.abs(dy)) * 0.35; + const ang = Math.atan2(dy, dx) || 0; + labels[i].x -= Math.cos(ang) * push; + labels[i].y -= Math.sin(ang) * push; + labels[j].x += Math.cos(ang) * push; + labels[j].y += Math.sin(ang) * push; + } + } + + const outward = Math.atan2( + labels[i].y - starPositions[i].y, + labels[i].x - starPositions[i].x, + ); + const minDist = starR + 16; + const dStar = dist(labels[i], starPositions[i]); + if (dStar < minDist) { + labels[i].x = starPositions[i].x + Math.cos(outward) * minDist; + labels[i].y = starPositions[i].y + Math.sin(outward) * minDist; + } + } + } + + return labels; +} + +export function shortenOrbitName(name: string): string { + return name.length > 16 ? `${name.slice(0, 14)}…` : name; +}