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

@@ -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);

View File

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

View File

@@ -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 (
<div
className="pointer-events-none absolute inset-0 overflow-hidden select-none"
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-[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]" />
<div className="stars-drift-slow absolute inset-0 -top-[80px] h-[calc(100%+160px)]">
{stars.map((s) => (
<span
key={s.id}
className="absolute rounded-full bg-star-200"
style={{
left: s.left,
top: s.top,
width: s.size,
height: s.size,
opacity: s.opacity,
animation: `twinkle-calm 14s ease-in-out ${s.delay} infinite alternate`,
}}
/>
))}
</div>
<style>{`
.stars-drift-slow {
animation: drift-slow 180s linear infinite;
}
@keyframes drift-slow {
from { transform: translateY(0); }
to { transform: translateY(-80px); }
}
@keyframes twinkle-calm {
from { opacity: 0.08; }
to { opacity: 0.55; }
}
`}</style>
</div>
);
}

View File

@@ -1,6 +1,6 @@
import { motion } from "motion/react"; import { motion } from "motion/react";
import type { Orbit, Snapshot } from "../../api"; import type { Orbit, Snapshot } from "../../api";
import { Starfield } from "./Starfield"; import { SpaceBackdrop } from "./SpaceBackdrop";
import { BlackholeGalaxy } from "./BlackholeGalaxy"; import { BlackholeGalaxy } from "./BlackholeGalaxy";
export function VaultScene({ export function VaultScene({
@@ -23,16 +23,15 @@ export function VaultScene({
capturing?: boolean; capturing?: boolean;
}) { }) {
return ( return (
<div className="absolute inset-0 overflow-hidden"> <div className="absolute inset-0 overflow-hidden bg-space-950">
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(30,38,71,0.35)_0%,rgba(4,5,12,0.98)_70%)]" /> <SpaceBackdrop />
<Starfield />
<motion.div <motion.div
className="absolute top-1/3 left-1/2 -translate-x-1/2 w-[90vmin] h-[50vmin] rounded-full bg-wormhole-violet/8 blur-3xl" className="pointer-events-none absolute top-1/3 left-1/2 -translate-x-1/2 w-[70vmin] h-[38vmin] rounded-full bg-wormhole-violet/6 blur-3xl"
animate={{ animate={{
opacity: capturing ? [0.5, 0.9, 0.5] : [0.25, 0.45, 0.25], opacity: capturing ? [0.35, 0.65, 0.35] : [0.12, 0.22, 0.12],
scale: capturing ? [1, 1.08, 1] : [1, 1.03, 1], scale: capturing ? [1, 1.06, 1] : [1, 1.02, 1],
}} }}
transition={{ duration: capturing ? 2 : 8, repeat: Infinity }} transition={{ duration: capturing ? 2 : 14, repeat: Infinity }}
/> />
<motion.p <motion.p
className="absolute top-20 left-1/2 -translate-x-1/2 z-20 text-[10px] font-mono tracking-widest uppercase pointer-events-none" className="absolute top-20 left-1/2 -translate-x-1/2 z-20 text-[10px] font-mono tracking-widest uppercase pointer-events-none"

View File

@@ -0,0 +1,82 @@
import type { Vec2 } from "./galaxyLayout";
export type LabelPlacement = {
x: number;
y: number;
};
const CHAR_W = 6.4;
const LABEL_H = 14;
const LABEL_PAD = 6;
function labelWidth(name: string): number {
const n = name.length > 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;
}