Galaxy vault: black hole scene with flow/lock interaction

Stars per orbit, snapshot moons when locked, toggle on singularity.
This commit is contained in:
Tessera Agent
2026-11-09 10:48:30 +00:00
parent 50fe4ffffa
commit fa708f545d
5 changed files with 365 additions and 57 deletions

View File

@@ -1,39 +1,32 @@
# Tessera canvas — Space Engine mode
# Tessera canvas — galaxy vault (Space Engine mode)
Diegetic **cockpit HUD** over a persistent **vault viewport**. No admin tabs — systems open as translucent console overlays.
Diegetic **cockpit HUD** over a persistent **galaxy viewport**. The vault is a **black hole** at center; each **orbit** is a **star** on an elliptical path; **snapshots** are **moons** around that star (when locked).
## Viewport (always on)
## Viewport modes
- Starfield + nebula wash, orbital snapshot ring (SVG)
- Corner brackets, scanlines, vignette
- Telemetry strip: link status, tile count, stored mass
- Left rail: last four snapshot targets (mono labels)
- Center action: **CAPTURE NOW**
| Mode | Behavior |
|------|----------|
| **Flowing** (default) | Stars orbit the singularity; accretion disk spins; moons hidden; targets not clickable |
| **Locked** | Click **black hole** once — bodies ease into spaced slots and **stop**; star opens orbit console; moon opens snapshot tile |
## HUD rail (glyph console)
Click the **black hole** again to resume flow. HUD line under telemetry: green “flowing” / amber “locked”.
| Glyph | System | Overlay |
|-------|--------|---------|
| ◎ | Viewport | Dismiss overlays — pure scene |
| ⟳ | Orbits | Right console — schedules, rehearse, create |
| ◉ | Wormhole | Outpost pairing uplink |
| ◇ | Decay | Retention presets in use |
| ↩ | Restore | Bottom console — reconstitute + 12s grace |
## HUD rail
**Esc** closes an open console.
Unchanged — ◎ ⟳ ◉ ◇ ↩ consoles; **Esc** dismisses.
## Overlays (not pages)
## Data
- **Snapshot tile** — slides from left when a ring tile is selected on viewport
- **Orbit / Wormhole / Decay / Reconstitute** — HUD panels with console chrome
- Stars: `GET /api/v1/orbits` (status → star color)
- Moons: `GET /api/v1/snapshots` grouped by `orbit_name`, max 6 per star
## API
## Demo
Unchanged — see prior polish notes; TanStack Query on `/api/v1/*` and `/health`.
`TESSERA_DATA_DIR=... tessera seed-demo --force` for 12+ stars.
## Build
```bash
cd web && npm run build
cargo build --release -p tessera-hub # embeds dist
cargo build --release -p tessera-hub
```

View File

@@ -29,6 +29,7 @@ export default function App() {
const [mode, setMode] = useState<HUDMode>("scene");
const [selectedSnap, setSelectedSnap] = useState<string | null>(null);
const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null);
const [galaxyFlowing, setGalaxyFlowing] = useState(true);
const qc = useQueryClient();
const health = useQuery({
@@ -81,27 +82,19 @@ export default function App() {
return (
<div className="h-[100dvh] w-full overflow-hidden bg-space-950 text-star-100 relative">
{/* Scene always visible */}
<QueryGate
query={snaps}
empty={
<VaultScene snapshots={[]} onSelect={() => {}} capturing={capturing} />
}
>
{(data) => (
<VaultScene
snapshots={data}
orbits={orbits.data ?? []}
snapshots={snaps.data ?? []}
flowing={galaxyFlowing}
onToggleFlow={() => setGalaxyFlowing((f) => !f)}
capturing={capturing || capture.isPending}
onCapture={() => {
if (!(orbits.data?.length ?? 0)) setMode("orbits");
else capture.mutate();
}}
onSelect={(id) => {
setSelectedSnap(id);
selectedSnapshotId={selectedSnap}
onSelect={(id) => setSelectedSnap(id)}
onSelectOrbit={() => {
setGalaxyFlowing(false);
setMode("orbits");
}}
/>
)}
</QueryGate>
<CockpitFrame>
<TelemetryStrip

View File

@@ -0,0 +1,267 @@
import { useEffect, useMemo, useRef, useState } from "react";
import type { Orbit, Snapshot } from "../../api";
import { easeOutCubic, useGalaxyTime } from "../../hooks/useGalaxyMotion";
const MAX_STARS = 20;
const MAX_MOONS = 6;
type StarLayout = {
orbit: Orbit;
rx: number;
ry: number;
speed: number;
phase: number;
size: number;
};
function statusColor(status: string): string {
if (status === "failed") return "#f87171";
if (status === "running" || status === "rehearsed") return "#f0c468";
if (status === "completed") return "#4ade9a";
return "#94a3d4";
}
function groupSnaps(snaps: Snapshot[]): Map<string, Snapshot[]> {
const m = new Map<string, Snapshot[]>();
for (const s of snaps) {
const list = m.get(s.orbit_name) ?? [];
list.push(s);
m.set(s.orbit_name, list);
}
for (const [k, v] of m) {
v.sort((a, b) => b.taken_at.localeCompare(a.taken_at));
m.set(k, v.slice(0, MAX_MOONS));
}
return m;
}
export function BlackholeGalaxy({
orbits,
snapshots,
flowing,
onToggleFlow,
onSelectSnapshot,
onSelectOrbit,
selectedSnapshotId,
}: {
orbits: Orbit[];
snapshots: Snapshot[];
flowing: boolean;
onToggleFlow: () => void;
onSelectSnapshot: (id: string) => void;
onSelectOrbit: (id: string) => void;
selectedSnapshotId?: string | null;
}) {
const t = useGalaxyTime(!flowing);
const [blend, setBlend] = useState(1);
const blendStart = useRef(0);
const wasFlowing = useRef(flowing);
useEffect(() => {
if (wasFlowing.current !== flowing) {
blendStart.current = performance.now();
wasFlowing.current = flowing;
}
let raf = 0;
const tick = () => {
const dt = (performance.now() - blendStart.current) / 600;
setBlend(flowing ? Math.min(1, dt) : Math.max(0, 1 - easeOutCubic(Math.min(1, dt))));
if (dt < 1) raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [flowing]);
const stars = useMemo((): StarLayout[] => {
const list = orbits.slice(0, MAX_STARS);
return list.map((orbit, i) => {
const n = Math.max(list.length, 1);
const tier = i % 3;
return {
orbit,
rx: 92 + tier * 22 + (i % 4) * 6,
ry: 56 + tier * 14 + (i % 3) * 8,
speed: 0.08 + (i % 7) * 0.012,
phase: (i / n) * Math.PI * 2,
size: 5 + (orbit.name.length % 3),
};
});
}, [orbits]);
const snapsByOrbit = useMemo(() => groupSnaps(snapshots), [snapshots]);
return (
<div className="w-full h-full flex items-center justify-center pb-24 pointer-events-auto">
<svg
viewBox="-250 -250 500 500"
className="w-full max-w-[min(100vmin,520px)] h-auto max-h-[70dvh]"
role="application"
aria-label="Galaxy vault viewport"
>
<defs>
<radialGradient id="bhCore" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#000" />
<stop offset="45%" stopColor="#0a0614" />
<stop offset="100%" stopColor="transparent" />
</radialGradient>
<radialGradient id="bhDisk" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#a78bfa" stopOpacity="0.7" />
<stop offset="40%" stopColor="#f0c468" stopOpacity="0.35" />
<stop offset="100%" stopColor="transparent" />
</radialGradient>
<filter id="glow">
<feGaussianBlur stdDeviation="2" result="b" />
<feMerge>
<feMergeNode in="b" />
<feMergeNode in="SourceGraphic" />
</feMerge>
</filter>
</defs>
{/* faint orbital guides */}
{stars.map((s, i) => (
<ellipse
key={`path-${s.orbit.id}`}
cx="0"
cy="0"
rx={s.rx}
ry={s.ry}
fill="none"
stroke="#2d3a6b"
strokeOpacity={flowing ? 0.12 : 0.22}
strokeWidth="0.6"
strokeDasharray="3 6"
transform={`rotate(${(i * 17) % 40 - 20})`}
/>
))}
<BlackHoleCore t={t} flowing={flowing} onToggle={onToggleFlow} />
{stars.map((s, i) => {
const n = stars.length;
const slotAngle = (i / n) * Math.PI * 2 - Math.PI / 2;
const flowAngle = s.phase + t * s.speed;
const angle = flowAngle * blend + slotAngle * (1 - blend);
const x = Math.cos(angle) * s.rx;
const y = Math.sin(angle) * s.ry;
const moons = snapsByOrbit.get(s.orbit.name) ?? [];
const color = statusColor(s.orbit.last_status);
return (
<g key={s.orbit.id} filter="url(#glow)">
<circle
cx={x}
cy={y}
r={s.size + 8}
fill="transparent"
className="cursor-pointer"
onClick={(e) => {
e.stopPropagation();
if (!flowing) onSelectOrbit(s.orbit.id);
}}
/>
<circle
cx={x}
cy={y}
r={s.size}
fill={color}
fillOpacity={0.85}
stroke="#eef1ff"
strokeOpacity={0.35}
strokeWidth="0.6"
className={!flowing ? "cursor-pointer" : "pointer-events-none"}
onClick={(e) => {
e.stopPropagation();
if (!flowing) onSelectOrbit(s.orbit.id);
}}
/>
{!flowing &&
moons.map((moon, mi) => {
const mAngle = (mi / Math.max(moons.length, 1)) * Math.PI * 2 + 0.3;
const mx = x + Math.cos(mAngle) * 14;
const my = y + Math.sin(mAngle) * 10;
const sel = moon.id === selectedSnapshotId;
return (
<g key={moon.id}>
<circle
cx={mx}
cy={my}
r={sel ? 5 : 3.5}
fill={sel ? "#a78bfa" : "#1e2647"}
stroke={sel ? "#c9d2f5" : color}
strokeWidth="0.8"
className="cursor-pointer"
onClick={(e) => {
e.stopPropagation();
onSelectSnapshot(moon.id);
}}
/>
</g>
);
})}
{!flowing && (
<text
x={x}
y={y - s.size - 6}
textAnchor="middle"
fill="#94a3d4"
fontSize="7"
className="font-mono pointer-events-none"
>
{s.orbit.name.length > 14
? `${s.orbit.name.slice(0, 12)}…`
: s.orbit.name}
</text>
)}
</g>
);
})}
</svg>
</div>
);
}
function BlackHoleCore({
t,
flowing,
onToggle,
}: {
t: number;
flowing: boolean;
onToggle: () => void;
}) {
const diskRot = flowing ? t * 28 : 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="72" fill="url(#bhCore)" />
<ellipse
cx="0"
cy="0"
rx="52"
ry="14"
fill="none"
stroke="url(#bhDisk)"
strokeWidth="10"
opacity="0.55"
transform={`rotate(${diskRot})`}
/>
<ellipse
cx="0"
cy="0"
rx="38"
ry="9"
fill="url(#bhDisk)"
opacity="0.4"
transform={`rotate(${-diskRot * 1.3 + 20})`}
/>
<circle cx="0" cy="0" r="18" fill="#000" stroke="#a78bfa" strokeOpacity="0.5" strokeWidth="1" />
<circle cx="0" cy="0" r="48" fill="none" stroke="#a78bfa" strokeOpacity={flowing ? 0.15 : 0.35} strokeWidth="0.8" strokeDasharray="4 8">
{!flowing && null}
</circle>
<text y="4" textAnchor="middle" fill="#6b7ab8" fontSize="8" className="font-mono pointer-events-none">
VAULT
</text>
</g>
);
}

View File

@@ -1,34 +1,55 @@
import { motion } from "motion/react";
import type { Snapshot } from "../../api";
import { VaultRing } from "../vault/VaultRing";
import type { Orbit, Snapshot } from "../../api";
import { Starfield } from "./Starfield";
import { BlackholeGalaxy } from "./BlackholeGalaxy";
export function VaultScene({
orbits,
snapshots,
flowing,
onToggleFlow,
onSelect,
onCapture,
onSelectOrbit,
selectedSnapshotId,
capturing,
}: {
orbits: Orbit[];
snapshots: Snapshot[];
flowing: boolean;
onToggleFlow: () => void;
onSelect: (id: string) => void;
onCapture?: () => void;
onSelectOrbit: (id: string) => void;
selectedSnapshotId?: string | null;
capturing?: boolean;
}) {
return (
<div className="absolute inset-0 overflow-hidden">
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(30,38,71,0.45)_0%,rgba(4,5,12,0.95)_65%)]" />
<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%)]" />
<Starfield />
<motion.div
className="absolute top-1/4 left-1/2 -translate-x-1/2 w-[80vmin] h-[40vmin] rounded-full bg-wormhole-violet/5 blur-3xl"
animate={{ opacity: [0.3, 0.55, 0.3], scale: [1, 1.05, 1] }}
transition={{ duration: 8, repeat: Infinity }}
className="absolute top-1/3 left-1/2 -translate-x-1/2 w-[90vmin] h-[50vmin] rounded-full bg-wormhole-violet/8 blur-3xl"
animate={{
opacity: capturing ? [0.5, 0.9, 0.5] : [0.25, 0.45, 0.25],
scale: capturing ? [1, 1.08, 1] : [1, 1.03, 1],
}}
transition={{ duration: capturing ? 2 : 8, repeat: Infinity }}
/>
<div className="relative z-10 h-full w-full pb-28">
<VaultRing
<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"
initial={false}
animate={{ color: flowing ? "#4ade9a" : "#f0c468" }}
>
{flowing ? "◉ vault flowing — click singularity to lock" : "◉ vault locked — select stars & moons"}
</motion.p>
<div className="relative z-10 h-full w-full">
<BlackholeGalaxy
orbits={orbits}
snapshots={snapshots}
onSelect={onSelect}
onCapture={onCapture}
capturing={capturing}
flowing={flowing}
onToggleFlow={onToggleFlow}
onSelectSnapshot={onSelect}
onSelectOrbit={onSelectOrbit}
selectedSnapshotId={selectedSnapshotId}
/>
</div>
</div>

View File

@@ -0,0 +1,34 @@
import { useEffect, useRef, useState } from "react";
/** Seconds since mount, frozen while paused. */
export function useGalaxyTime(paused: boolean): number {
const [t, setT] = useState(0);
const start = useRef(performance.now());
const frozen = useRef(0);
const wasPaused = useRef(paused);
useEffect(() => {
if (paused) {
frozen.current = (performance.now() - start.current) / 1000;
wasPaused.current = true;
return;
}
if (wasPaused.current) {
start.current = performance.now() - frozen.current * 1000;
wasPaused.current = false;
}
let raf = 0;
const tick = () => {
setT((performance.now() - start.current) / 1000);
raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [paused]);
return paused ? frozen.current : t;
}
export function easeOutCubic(x: number): number {
return 1 - Math.pow(1 - x, 3);
}