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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
perf(play): distance-based animation LOD for remote players, fix redundant timezone suffix on /event
nirholas2b695c9cc5ba
diff --git a/STRUCTURE.md b/STRUCTURE.mdindex 6eae7d9bb..c7e1e2b15 100644--- a/STRUCTURE.md+++ b/STRUCTURE.md@@ -89,6 +89,7 @@ bottom.| Cinematic rendering (shared 3D quality bar) | [src/shared/cinematic-render.js](src/shared/cinematic-render.js) — `applyCinematicDefaults()`, `loadEnvironment()`, `detectQualityTier()`, `updateGroundContactShadow()`; curated HDRIs in [public/hdri/](public/hdri) (CC0, Poly Haven) | Live, wired into every three.js viewer on the platform (`/irl`, talk mode, `/play`, `/club`, `/ar`, `/xr`, `/walk`, `/coin3d`, marketplace lobby, demo pages, the `<agent-3d>`/`<page-agent>` embeds, and more) | One module every WebGLRenderer-based viewer calls into instead of re-deriving ACES tone mapping, sRGB output color space, HDRI image-based lighting, and soft VSM shadows per file. `detectQualityTier()` picks high/medium/mobile from real device signals and caps pixel ratio + disables shadows/HDRI accordingly; `loadEnvironment()` fetches a real photographic HDRI (`studio`/`outdoor`/`sunset`) and falls back to a procedural room environment on mobile tier or fetch failure (including cross-origin embed contexts where the absolute `/hdri/*.hdr` URL can't resolve). `/walk` keeps its own richer per-biome HDR system ([src/walk-environments.js](src/walk-environments.js)); surfaces already running a postprocessing tone-mapping pass (`/oracle-graph`, `/club-entrance`) only take the sRGB/HDRI half to avoid double-applying the curve. || `/play` Wheel of Fortune (Fortune's Folly; free/paid $THREE spins) | Client: [src/game/wheel-station.js](src/game/wheel-station.js) (the plaza landmark, proximity prompt, `E` to spin; lazy-imports the actual UI on first interact), spin UI [src/game/spin-wheel-ui.js](src/game/spin-wheel-ui.js) (20-segment wheel, free/paid flow, wallet signing). Server: [multiplayer/src/spin-wheel.js](multiplayer/src/spin-wheel.js) (paytable, RNG, level/cooldown/pack gates, handlers), split-payment settlement [multiplayer/src/game-token.js](multiplayer/src/game-token.js) (`buildSpinPayment`/`verifySpinPayment`; the same primitives the $THREE boutique uses), wheel location [multiplayer/src/world-features.js](multiplayer/src/world-features.js) `WHEEL`, persisted cooldown field in [multiplayer/src/economy.js](multiplayer/src/economy.js), handlers wired in [multiplayer/src/rooms/WalkRoom.js](multiplayer/src/rooms/WalkRoom.js) | In-repo | W09 of the World Online program (program brief retired to git history). Walk up to the wheel in the plaza and press `E`: one free spin every 12h (a real persisted cooldown; survives a disconnect, unlike the ephemeral per-action cooldowns everything else on this row's neighbors use), or pay $3 in `$THREE`; split 50% to the holder-rewards pool / 50% to the treasury, verified on-chain before any prize is granted, mirroring the boutique's proven settlement pattern exactly. Gated behind an average skill level of 3 (a light anti-farm floor, not a grind) and never lets a won prize get lost to a full pack; room for at least one possible item prize is checked before a spin is even offered, paid or free. All 20 wedges are equal-odds by design, matching the client's fixed-angle wheel rendering exactly (see the header note in `spin-wheel.js` on why that must never drift). Tests: [tests/spin-wheel.test.js](tests/spin-wheel.test.js). || `/play` live events (countdown chip, agenda drawer, synchronized fireworks) | Config [public/event.json](public/event.json) (one file, shared with the lobby countdown and the server-side souvenir grant). Client: in-world layer [src/game/meetup-event.js](src/game/meetup-event.js) + [src/game/meetup-event.css](src/game/meetup-event.css), pure schedule math [src/game/meetup-schedule.js](src/game/meetup-schedule.js), particle show [src/game/fireworks.js](src/game/fireworks.js), lobby banner + wayfinding pill [src/game/event-countdown.js](src/game/event-countdown.js). Mounted from [pages/play.html](pages/play.html) | In-repo | Turns the `$THREE` home town into a place something is *happening* in for the length of a scheduled event, driven entirely by `public/event.json`: delete the file and the world is normal again, with no code change. A countdown chip docks under the King of the Totem card (and stands the generic pill down, so there is only ever one countdown on screen) and opens a right-docked agenda drawer that marks the running segment, dims finished ones, counts the rest down in local time, and carries a live `$THREE` pulse row (`/api/three-signal`) plus one-tap Buy and commemorative-photo actions. Six phases derive from the wall clock (`far → upcoming → preshow → live → afterglow → ended`), so every player agrees on what is on and what is next without a round-trip. **Fireworks are deterministic, not networked:** four-second buckets hashed with the event id give every client the identical sky (`fireworkPlan()`), the same trick [src/shared/world-clock.js](src/shared/world-clock.js) uses for the shared sun; density ramps into a closing barrage, power-saver halves it, at most 14 shells live at once, and a backgrounded tab rejoins the show live instead of replaying the backlog `requestAnimationFrame` paused through. Preview any schedule with `?meetup=now` or `?meetup=<ISO>`. Doc: [docs/play-live-events.md](docs/play-live-events.md). Browser audit: `npm run audit:meetup` ([scripts/meetup-audit.mjs](scripts/meetup-audit.mjs)). Tests: [tests/meetup-schedule.test.js](tests/meetup-schedule.test.js), [tests/meetup-event-ui.test.js](tests/meetup-event-ui.test.js) |+| `/play` event souvenirs (a free wearable you keep for having been there) | Config [public/event.json](public/event.json) (`souvenir.cosmeticId`, the same file the countdown reads). Server: window/world/item resolution [multiplayer/src/event-drop.js](multiplayer/src/event-drop.js), join-time grant `_grantEventSouvenir` in [multiplayer/src/rooms/WalkRoom.js](multiplayer/src/rooms/WalkRoom.js), `event` tier + catalog entry [multiplayer/src/cosmetics-catalog.js](multiplayer/src/cosmetics-catalog.js), unlock + persistence [multiplayer/src/economy.js](multiplayer/src/economy.js). Client: drop card [src/game/event-souvenir.js](src/game/event-souvenir.js), wardrobe treatment [src/game/cosmetics-wardrobe.js](src/game/cosmetics-wardrobe.js). Asset: [public/accessories/laurel-meetup.glb](public/accessories/laurel-meetup.glb) generated by [scripts/generate-accessory-glbs.mjs](scripts/generate-accessory-glbs.mjs), poster by [scripts/render-accessory-thumbs.mjs](scripts/render-accessory-thumbs.mjs) | In-repo | Everyone who joins the event world between an event's `startsAt` and `endsAt` is granted a free commemorative wearable (the Meetup Laurel), once, forever, wearable in every coin world. After `endsAt` it is never granted again and there is no purchase path at any point: a third catalog tier, `event`, carries `price: 0`, so the boutique's `tier === 'premium' && price > 0` filter excludes it by construction and the x402 purchase ledger is filtered to premium ids so it cannot mint one. Server-authoritative and idempotent: the window and the world both come from the shared event config (never a client option), the grant is a no-op on an account that already owns it, and the one-shot `souvenir` message only fires on the not-owned to owned transition, so a reconnect produces neither a duplicate nor a second announcement. Fails open on every axis (no config, unreachable config, closed window, wrong world all mean grant nothing and never delay a join). Doc: [docs/event-souvenirs.md](docs/event-souvenirs.md). Tests: [tests/event-souvenir.test.js](tests/event-souvenir.test.js); live conformance `node scripts/play-souvenir-conformance.mjs` (real server, no browser) and `node scripts/play-souvenir-e2e.mjs` (real browser) || `/play` Coin Wars portal (in-world war door, league board, spectator screen) | Client: [src/game/war-portal.js](src/game/war-portal.js) + [src/game/war-portal.css](src/game/war-portal.css) (plaza landmark, canvas league board, queue panel, results echo), wired in [src/game/coincommunities.js](src/game/coincommunities.js); arena page [pages/play/war.html](pages/play/war.html) `→ /play/war` → [src/play/war.js](src/play/war.js) + [src/play/war-world.js](src/play/war-world.js) + [src/play/war.css](src/play/war.css). API: [api/wars.js](api/wars.js) `→ /api/wars` over [api/_lib/wars-store.js](api/_lib/wars-store.js) (ledger + queue + live registry) and [api/_lib/war-ticket.js](api/_lib/war-ticket.js) (signs a pairing). Server: [multiplayer/src/rooms/ClashRoom.js](multiplayer/src/rooms/ClashRoom.js) `clash_arena`, pairing math [multiplayer/src/war-matchmaking.js](multiplayer/src/war-matchmaking.js), ticket verify [multiplayer/src/war-ticket.js](multiplayer/src/war-ticket.js), spectator snapshots [multiplayer/src/war-live.js](multiplayer/src/war-live.js), league math [multiplayer/src/war-standings.js](multiplayer/src/war-standings.js), portal location [multiplayer/src/world-features.js](multiplayer/src/world-features.js) `WAR_PORTAL` | In-repo | F18. Coin Wars ran full community-vs-community battles with an Elo league behind it and no door into it from any world. The portal is that door: a plaza landmark whose board shows this coin's real league standing, its last battles, and any war running right now (read from `/api/wars`, folded through the arena's own standings module, never a second implementation). Press `E` to run the coin's holder gate and queue the community; the matchmaker pairs it with another waiting community, seals both sides into an HMAC war ticket, and hands the player to `/play/war` with a return link carrying the full coin identity, so walking back lands in the same world with the result already echoing on the board. While a war is live the board becomes a spectator screen (score, round clock, kill feed) off a cheap poll, and a win takes the board over for a few seconds. Costs nothing when nobody is near it: no poll fires outside `WAR_PORTAL_BOARD_REACH`. Docs: [docs/coin-wars.md](docs/coin-wars.md). Tests: [tests/war-matchmaking.test.js](tests/war-matchmaking.test.js), [tests/clash-match.test.js](tests/clash-match.test.js) || `/play` event countdown (lobby banner + in-world pill) | Self-attaching module [src/game/event-countdown.js](src/game/event-countdown.js) loaded by [pages/play.html](pages/play.html); config [public/event.json](public/event.json) (single source of the event window; the file is the edit surface for scheduling an event), read through the shared parser + state machine in [src/shared/event-config.js](src/shared/event-config.js). Verified end to end in a real browser by `npm run verify:event` ([scripts/verify-event-countdown.mjs](scripts/verify-event-countdown.mjs)). Campaign pack: [prompts/event/](prompts/event/) | In-repo | While `public/event.json` describes an upcoming or live event, the lobby shows a banner (name, tagline, local-time start, ticking countdown, CTA into the event world) and the in-world view gets a dismissible top-center pill (dismissal persisted per event in localStorage). Three explicit states: upcoming, live (pulsing marker, CTA suppressed when already standing in the event world), and over (everything unmounts, the interval stops). Zero edits to `coincommunities*.js` by design (the ambient-crowd pattern): it waits for the lobby DOM and mounts nothing when the config is missing, malformed, or expired. || The event landing page (`/event`) | [pages/event.html](pages/event.html) `→ /event`, page module [src/event-page.js](src/event-page.js); config [public/event.json](public/event.json) (the SAME file the `/play` countdown reads, never a second copy of the times); live population [api/play/population.js](api/play/population.js) `→ /api/play/population`, backed by the multiplayer server's public `/population` aggregate in [multiplayer/src/index.js](multiplayer/src/index.js) | Live | The one link the community shares before and during an event, written for someone with zero context. Hero countdown ticking off `public/event.json`, a single large CTA into the event world, a plain-language "what to expect" built only from what `/play` actually does, and the run of show rendered in the visitor's own timezone with an "Add to calendar" button that builds a real RFC 5545 `.ics` in the browser (no third-party calendar service, so the guest list never leaves the device). Four designed states: upcoming (days/hours/minutes/seconds), live (LIVE marker plus the real number of people standing in the world), ended (says it happened, relabels the agenda to "What happened", and still routes people into `/play`), and no-config (an honest "no event scheduled" with the same door). The live number is real or absent: when the multiplayer server is unreachable the panel keeps the live state and drops the count instead of inventing one. Doc: [docs/api-reference.md](docs/api-reference.md#play-population-api). |diff --git a/scripts/audit-play-failure-modes.mjs b/scripts/audit-play-failure-modes.mjsindex e7b9d033e..f50774140 100644--- a/scripts/audit-play-failure-modes.mjs+++ b/scripts/audit-play-failure-modes.mjs@@ -64,6 +64,13 @@ const CANONICAL = `/play?coin=${THREE_MINT}&name=three.ws&symbol=three&image=${e// resolution point while staying well inside the watchdog.const SETTLE_MS = 20_000;+// Navigation budget. 60s is generous against a healthy host, but this repo's dev+// box is shared by many concurrent agents and a starved chromium can take minutes+// to reach DOMContentLoaded on a page it would otherwise open in two seconds.+// Raise it there (NAV_TIMEOUT_MS=180000) so host contention shows up as a slow+// pass instead of a fabricated "the world hung" finding.+const NAV_TIMEOUT_MS = Number(process.env.NAV_TIMEOUT_MS) || 60_000;+// ── Hostile inputs ───────────────────────────────────────────────────────────// Every payload calls the same sentinel, so one flag proves script execution// regardless of which vector fired.@@ -345,7 +352,7 @@ async function runScenario(base, sc) {const findings = [];try {- await page.goto(base + sc.url, { waitUntil: 'domcontentloaded', timeout: 60_000 });+ await page.goto(base + sc.url, { waitUntil: 'domcontentloaded', timeout: NAV_TIMEOUT_MS });} catch (err) {const m = String(err?.message || err);await teardown();