Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

6.3 KB
Raw Blame

Task 05 — The Commons (3D scaffold)

Status (2026-08-05): shipped. /agora is live in production and every contract file below exists: pages/agora.html, src/agora/agora-world.js, src/agora/citizen-avatar.js, src/agora/passport-panel.js, src/agora/agora.css, plus the data/pages.json entry and the vite.config.js agora input. Later tasks built on this scaffold: the economy layer (Task 06, src/agora/economy-layer.js), the trust surface (Task 07, src/agora/trust-surface.js), the human HUD (Task 08, src/agora/me-hud.js), and the "Enter the Commons" play mode (src/agora/player-mode.js). Kept as the build record; use it as the pattern for future Agora surfaces.

How the populate step works today differs from the scope below in two ways. The /api/agora/citizens?limit=200 request starts at module load, in parallel with the OSM map, and the first loadCitizens pass consumes that prefetch (a slow Overpass boot used to hold the citizens request for 40s). And every citizen stands up on the shared default rig first (AVATAR_DEFAULT, one small GLB for the whole crowd, placed ten per frame), then only the most recently active MAX_PERSONAL_AVATARS (24 on desktop, 8 on a coarse pointer) upgrade to their own avatarUrl as it streams in: presence first, fidelity progressively, nobody missing and nobody invented. The population chip reads placed / total while the square fills. The HUD title chip is the page's one h1, and every nameplate, roster row and passport resolves a citizen's craft through citizenProfessionLabel (primary craft first, the capability bitmap only as a fallback, since every citizen carries the Fetcher bit).

Goal: Stand up /agora — the watchable world — on the existing City substrate. Render real citizens from /api/agora/citizens as avatars living in the scene, with idle animation and name labels, a click-to-inspect passport panel, and fully designed loading/empty/error states. This is the shell the economy visuals (Task 06) and interactions (Tasks 07/08) hang on.

Depends on: Task 01 (API live). Ideally Task 02 has seeded citizens so the scene isn't empty, but the empty state must be designed regardless.

Context to read first

  • docs/agora.md (§ The 3D layer) and 00-INDEX.md.
  • pages/city.html + src/city/city-world.js (scene/renderer/loop), city-map.js, city-player.js, city-camera.js, city.css — reuse this.
  • src/glb-canonicalize.js, src/animation-manager.js, src/agent-avatar.js, public/animations/ — avatar load + idle/walk clips.
  • api/agora/[action].js — citizens + passport shapes you consume.
  • data/pages.json, vite.config.js — how to register a page + route.

Background

The City already builds a Three.js world with a controllable player, a map, and a third-person camera. Agora reuses that scene and adds a population: each citizen is an avatar placed at its position, wearing its avatarUrl GLB (canonicalized + retargeted so the shared idle/walk clips drive any rig — see the avatar pipeline note in CLAUDE.md). Multiple avatars must coexist; pool/instance sensibly so 50+ citizens stay at 60fps.

Build (scope)

  1. Page + route. pages/agora.html (mirror pages/city.html's head/mount) + src/agora/agora-world.js entry. Register in data/pages.json (path:/agora, title/description, auth null) and wire the Vite input if needed.
  2. Mount the City scene. Reuse city-world.js's scene/renderer/camera/loop (extract a shared helper if cleaner, without breaking /city). Free-orbit or third-person camera over the square.
  3. Populate. Fetch /api/agora/citizens, place an avatar per citizen at its position (fall back to a deterministic layout if positions are 0). Load each avatarUrl GLB through the canonicalize→retarget→AnimationManager path; play idle. Cache/share GLBs and clips; lazy-load; cap concurrent loads. A floating name + profession label per avatar (billboarded, legible, accessible).
  4. Inspect. Click/tap an avatar (and keyboard focus + Enter) → a side panel that fetches /api/agora/passport?id=… and shows the basics (name, profession, status, reputation, stake, tasks completed, recent activity). The rich passport UI is Task 07 — keep this panel a clean, real first version.
  5. States. Loading = a skeleton/spinner-free progressive load (avatars fade in). Empty (citizens.empty) = a designed "the Commons is quiet — no citizens yet" with a link to docs/how it works, not a blank void. Error = an actionable retry. Resize/responsive (320/768/1440). Respect prefers-reduced-motion.

Out of scope

Job board building, claim-walk, completion artifacts, $THREE flows, ticker (Task 06). Verify button + cross-chain handshake (Task 07). Human avatar/auth (Task 08).

Contracts

  • New: pages/agora.html, src/agora/agora-world.js, src/agora/citizen-avatar.js, src/agora/passport-panel.js, src/agora/agora.css. Reuse src/city/* and the avatar pipeline; don't fork them.
  • Consumes /api/agora/citizens + /api/agora/passport.
  • data/pages.json gains the /agora entry.

Definition of Done

  • /agora loads in a real browser via npm run dev with no console errors.
  • Real citizens render as animated avatars with labels; the count matches /api/agora/citizens.
  • Clicking (and keyboard-focusing) a citizen opens a passport panel with real data from /api/agora/passport.
  • Empty, loading, and error states are all designed and reachable (test each: zero citizens, slow network, API down).
  • 50 citizens stay smooth (test with a seeded or synthetic-position fleet — performance only, not fake economic data); GLBs/clips are shared not reloaded.
  • Responsive at 320/768/1440; reduced-motion honored; focus rings present.

Verification

npm run dev → open /agora. Network tab shows real /api/agora/* calls. Toggle the API off to see the error state; point at an empty DB to see the empty state. Throttle network to see progressive load.

Guardrails

  • Don't break /city — if you share scene code, refactor carefully and re-test it.
  • No fabricated citizens to fill the scene; empty is honest.
  • Push to threews only; changelog: the new page's added date in data/pages.json feeds the changelog automatically — no manual entry needed for the page itself.