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
docs(api): document the Play Population API, extend locale strings
nirholas88e36871cf59
diff --git a/api/sniper/status.js b/api/sniper/status.jsindex 3e7e79181..54ccc8e19 100644--- a/api/sniper/status.js+++ b/api/sniper/status.js@@ -37,6 +37,7 @@import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';import { limits, clientIp } from '../_lib/rate-limit.js';import { sql } from '../_lib/db.js';+import { deriveSniperState } from '../_lib/sniper-solvency.js';const WORKER = 'agent-sniper';// Allow 2× the default heartbeat cadence (30s) plus slack before declaring the@@ -136,14 +137,9 @@ export default wrap(async (req, res) => {// yet run) degrades to 'unknown', which never overrides the feed verdict — an// unmeasured fleet must not read as a broke one.const solvency = meta.solvency && typeof meta.solvency === 'object' ? meta.solvency : null;- const solvencyState = solvency?.state || 'unknown';- const state = !alive- ? 'down'- : solvencyState === 'starved'- ? 'starved'- : feedSilent || !feedLive || solvencyState === 'degraded'- ? 'degraded'- : 'live';+ const state = deriveSniperState({+ alive, feedLive, feedSilent: !!feedSilent, solvencyState: solvency?.state || 'unknown',+ });return json(res,diff --git a/docs/api-reference.md b/docs/api-reference.mdindex d8a553fec..d83b698ae 100644--- a/docs/api-reference.md+++ b/docs/api-reference.md@@ -4301,6 +4301,44 @@ curl 'https://three.ws/api/animations/signatures?similar=wave&limit=5'---+## Play Population API++```+GET /api/play/population+GET /api/play/population?coin=<mint-or-contract>+```++How many people are standing in the `/play` worlds right now. No auth, CORS open, cached 5 seconds at the edge.++`/play` presence lives in Colyseus rooms on the standalone multiplayer server, not in Postgres, so this handler proxies that server's own `/population` aggregate. That aggregate reads the matchmaker's driver-backed room listing, so the count spans every instance when the fleet is scaled horizontally. Only a count crosses the boundary: no session ids, no display names, no wallets, no positions.++`coin` narrows the count to one community's worlds (a Solana mint or an EVM contract address). Anything that is not a well-formed address is ignored rather than forwarded, and the response reports the filter that was actually applied.++**Response**++```json+{+ "ok": true,+ "coin": "FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump",+ "players": 4,+ "rooms": 1+}+```++When the multiplayer server is unreachable the endpoint still answers `200`, with the count omitted:++```json+{ "ok": false, "reason": "unavailable", "coin": null }+```++Callers must render a live state without a number in that case rather than substituting one. The `/event` landing page does exactly this: it shows "The doors are open" instead of inventing a crowd.++```bash+curl -s 'https://three.ws/api/play/population?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump'+```++---+## Config API```diff --git a/public/locales/en.json b/public/locales/en.jsonindex 59f3d2779..5e4bc4af1 100644--- a/public/locales/en.json+++ b/public/locales/en.json@@ -1,30 +1,4 @@{- "404": {- "back_to_lab": "<span>Back to lab</span>",- "browse_all_pages": "<span>Browse all pages</span>",- "forge_something_instead": "<span>Forge something instead</span>",- "lost_in_3d": "Lost in 3D",- "meta_description": "That page doesn't exist. Head back home, or explore the agent lab.",- "meta_og_description": "That page doesn't exist. Head back home, or explore the agent lab.",- "meta_og_title": "Page not found · three.ws",- "meta_title": "three.ws — 404",- "meta_twitter_description": "That page doesn't exist. Head back home, or explore the agent lab.",- "meta_twitter_title": "Page not found · three.ws",- "take_her_home": "<span>Take her home</span> <span>→</span>",- "this_page_does_not_exist_on_three": "This page does not exist on three.ws — but she landed here, looked around, and seems pretty confused. Send her home.",- "your_agent_took_a_wrong_turn": "Your agent took a wrong turn."- },- "500": {- "contact_support": "<span>Contact support</span>",- "copy_support_reference_to_cl_arialabel": "Copy support reference to clipboard",- "meta_title": "three.ws — something broke on our end",- "reference": "Reference",- "server_hiccup": "Server hiccup",- "something_broke_on_our_end": "Something broke on our end.",- "take_me_home": "<span>Take me home</span>",- "this_one_s_on_us_not_you": "This one's on us, not you — and it isn't silent: the team was <strong>alerted automatically</strong> the moment it happened. Give it a moment and try again.",- "try_again": "<span id=\"retry-label\">Try again</span> <span>→</span>"- },"3d": {"1_discover_the_whole_api": "1 · Discover the whole API","2_inspect_a_model_validate_optimization_repo": "2 · Inspect a model (validate + optimization report)",@@ -94,6 +68,32 @@"x402_bazaar": "x402 Bazaar","yes_no_account_no_api_key_no": "Yes. No account, no API key, no wallet. Free endpoints have a generous per-IP rate limit that only blunts abuse. The free draft generation tier runs on a shared GPU lane — it's honest about being a prototyping tier (draft geometry, GLB only, no rigging)."},+ "404": {+ "back_to_lab": "<span>Back to lab</span>",+ "browse_all_pages": "<span>Browse all pages</span>",+ "forge_something_instead": "<span>Forge something instead</span>",+ "lost_in_3d": "Lost in 3D",+ "meta_description": "That page doesn't exist. Head back home, or explore the agent lab.",+ "meta_og_description": "That page doesn't exist. Head back home, or explore the agent lab.",+ "meta_og_title": "Page not found · three.ws",+ "meta_title": "three.ws — 404",+ "meta_twitter_description": "That page doesn't exist. Head back home, or explore the agent lab.",+ "meta_twitter_title": "Page not found · three.ws",+ "take_her_home": "<span>Take her home</span> <span>→</span>",+ "this_page_does_not_exist_on_three": "This page does not exist on three.ws — but she landed here, looked around, and seems pretty confused. Send her home.",+ "your_agent_took_a_wrong_turn": "Your agent took a wrong turn."+ },+ "500": {+ "contact_support": "<span>Contact support</span>",+ "copy_support_reference_to_cl_arialabel": "Copy support reference to clipboard",+ "meta_title": "three.ws — something broke on our end",+ "reference": "Reference",+ "server_hiccup": "Server hiccup",+ "something_broke_on_our_end": "Something broke on our end.",+ "take_me_home": "<span>Take me home</span>",+ "this_one_s_on_us_not_you": "This one's on us, not you — and it isn't silent: the team was <strong>alerted automatically</strong> the moment it happened. Give it a moment and try again.",+ "try_again": "<span id=\"retry-label\">Try again</span> <span>→</span>"+ },"a_edit": {"back": "← Back","meta_title": "Edit Agent — three.ws"@@ -14752,6 +14752,7 @@"art_directed_mesh_generation_from_text_or": "Art-directed mesh generation from text or an image.","assistants_are_excellent_at_text_and_images": "Assistants are excellent at text and images and have had nothing to say in three dimensions. A model you can orbit, rig, animate, and stand in your living room is a different kind of answer than a picture of one. three.ws exists to make that response type ordinary: an open protocol shape, a free connector, and an open-source stack under all of it. Being named an OpenAI Select Partner is the endorsement to go build more of it.","auth": "Auth",+ "collect_a_generation_that_outran_its_tool": "Collect a generation that outran its tool call. Read-only, and it never spends generation quota.","connect_the_server": "Connect the server.","custom_gpt_actions": "Custom GPT Actions","every_generated_model_carries_a_one_tap": "Every generated model carries a one-tap AR link. iOS gets a Quick Look USDZ converted on the fly, Android gets a Scene Viewer intent, desktop gets the WebGL viewer.",@@ -14759,7 +14760,6 @@"generate_a_3d_avatar_from_a_prompt": "Generate a 3D avatar from a prompt or a reference image.","generate_a_textured_3d_model_from_a": "Generate a textured 3D model from a text prompt. Returns a GLB.","iterate_by_describing_a_change_make_it": "Iterate by describing a change (\"make it metallic\"), with a revertable version lineage.",- "collect_a_generation_that_outran_its_tool": "Collect a generation that outran its tool call. Read-only, and it never spends generation quota.","make_the_body_speak_a_line_lip": "Make the body speak a line: lip-sync, expression, and gesture blended together.","manifest": "Manifest","mcp": "MCP <code>2025-06-18</code>",@@ -15792,12 +15792,68 @@"while_the_category_is_still_being_named": "While the category is still being named, we've shipped the whole path — in production, in the browser, today."},"play": {+ "avatar": "Avatar",+ "avatar_aria": "Change your avatar",+ "avatar_title": "Change your avatar (V)",+ "buy": "Buy",+ "buy_title": "Buy this coin",+ "canvas_label": "The 3D coin community world. Walk with W A S D or the arrow keys, hold Shift to run, Space to jump, drag or use the mouse to look around. Press Enter to open chat, Q for emotes, E to talk to whoever is nearby, and Z to hide the panels.",+ "chat": "Chat",+ "chat_input_aria": "Chat message",+ "chat_log_aria": "Chat messages",+ "chat_placeholder": "Say something…",+ "chat_toggle_aria": "Toggle chat",+ "dance": "Dance",+ "dance_aria": "Dance on the floor",+ "dance_title": "Sync-dance with everyone on the floor",+ "eco": "Eco",+ "eco_aria": "Power saver",+ "eco_title": "Power saver: 30fps and lighter rendering, for a cooler, quieter machine",+ "emotes": "Emotes",+ "friends": "Friends",+ "friends_aria": "Open friends panel",+ "friends_title": "Friends: presence and messages (J)",+ "gate": "Gate",+ "gate_aria": "Configure the holders gate",+ "gate_title": "Set who can enter the Holders world",+ "hint": "<kbd>W A S D</kbd> / drag-joystick to move · <kbd>drag</kbd> to look · scroll zoom · <kbd>Enter</kbd> chat · <kbd>Q</kbd> emotes · <kbd>I</kbd> inspect · <kbd>P</kbd> photo · <kbd>Z</kbd> zen",+ "jobs": "Jobs",+ "jobs_aria": "Open the jobs board",+ "jobs_title": "Jobs Board: dailies, courier runs, and the vault heist",+ "leave": "Communities","meta_description": "Coin Communities — a browser isometric MMO on three.ws. Join coin communities, gather, fight, trade, and explore a shared world. Sign in with your wallet and play.","meta_og_description": "A browser isometric MMO on three.ws — join coin communities, gather, fight, trade, explore.","meta_og_title": "Play · Coin Communities","meta_title": "Play · Coin Communities — three.ws","meta_twitter_description": "Play in your coin's 3D community world. Walk, chat, and hang out with fellow holders.",- "meta_twitter_title": "Play · Coin Communities — three.ws"+ "meta_twitter_title": "Play · Coin Communities — three.ws",+ "online": "{{n}} online",+ "reactions": "Reactions",+ "send": "Send",+ "shop": "Shop",+ "shop_aria": "Open cosmetics shop",+ "shop_title": "Cosmetics: try looks on your avatar",+ "show_ui": "Show UI",+ "show_ui_aria": "Show controls",+ "show_ui_title": "Show controls (Z)",+ "status_connecting": "connecting…",+ "status_denied": "sign-in required",+ "status_failed": "offline, tap to retry",+ "status_idle": "idle",+ "status_offline": "reconnecting…",+ "status_online": "connected",+ "status_retry_aria": "Connection {{state}}. Activate to reconnect.",+ "status_retry_title": "Reconnect",+ "status_unavailable": "multiplayer unavailable",+ "voice": "Voice",+ "voice_aria": "Voice chat",+ "voice_title": "Join voice: talk to people near you",+ "wardrobe": "My Fits",+ "wardrobe_aria": "Open my cosmetics wardrobe",+ "wardrobe_title": "My Cosmetics: equip your owned looks",+ "zen": "Zen",+ "zen_aria": "Zen mode",+ "zen_title": "Zen mode: hide every panel, just the world (Z)"},"play_agent_wallet": {"0_00usd": "<span class=\"skel\">$0.00</span><small>USD</small>",diff --git a/scripts/play-economy-audit.mjs b/scripts/play-economy-audit.mjsindex 5af687f34..2a396006e 100644--- a/scripts/play-economy-audit.mjs+++ b/scripts/play-economy-audit.mjs@@ -16,7 +16,7 @@// first failed expectation so it can gate a release.import { Client } from 'colyseus.js';-import { TREES } from '../multiplayer/src/world-features.js';+import { TREES, VENDOR_STALLS, ATMS } from '../multiplayer/src/world-features.js';const URL = process.env.WS || 'ws://127.0.0.1:2567';// A stable key so the persistence check at the end has something to reclaim.@@ -121,7 +121,21 @@ check('a swing always pays woodcutting XP, hit or miss', box.xp.filter((g) => g.check('XP events carry exact level boundaries so the bar needs no round trip',box.xp.every((g) => Number.isFinite(g.levelXp) && (g.nextXp === null || Number.isFinite(g.nextXp))), '');+// --- the counter has to be walked to ------------------------------------------+// Trading from the tree line must be refused: "walk to the shop" is a rule the+// server keeps, not a courtesy the client extends.+const noticesBeforeRemote = box.notices.length;+const purseAtTree = purseOf(box);+room.send('storeSell', { slot: { zone: 'inv', i: slotOf(box.inv || box.profile, 'wood') } });+room.send('bank', { amount: 1 });+await sleep(800);+check('trading and banking from out in the world are refused',+ purseOf(box) === purseAtTree,+ box.notices.slice(noticesBeforeRemote).map((n) => n.text).join(' | ') || 'no refusal notice');+// --- sell ---------------------------------------------------------------------+const stall = VENDOR_STALLS[0];+await walkTo(stall.x, stall.z);room.send('storeReq');await sleep(500);const woodPrice = box.store?.sell?.find((s) => s.item === 'wood')?.price;@@ -162,6 +176,8 @@ if (purseBeforeBuy >= potion.price) {}// --- bank ---------------------------------------------------------------------+const atm = ATMS[0];+await walkTo(atm.x, atm.z);const purse = purseOf(box);room.send('bank', { amount: purse });await sleep(700);diff --git a/src/game/meetup-event.js b/src/game/meetup-event.jsindex 020cf90df..e94c05c04 100644--- a/src/game/meetup-event.js+++ b/src/game/meetup-event.js@@ -74,10 +74,19 @@ function fmtCompactUsd(v) {return `$${n.toFixed(0)}`;}-class MeetupEvent {- constructor(event, cc) {+export class MeetupEvent {+ /**+ * @param {object} opts+ * @param {object} opts.event parsed event (meetup-schedule.js parseEvent)+ * @param {object} opts.cc the live CoinCommunities app (window.__CC__)+ * @param {Function} opts.Fireworks the Fireworks class, injected so the heavy+ * three.js module stays a lazy import at the boot edge and tests can run the+ * whole DOM layer without a WebGL scene.+ */+ constructor({ event, cc, Fireworks }) {this.ev = event;this.cc = cc;+ this._Fireworks = Fireworks;this.chip = null;this.panel = null;this.banner = null;@@ -355,7 +364,7 @@ class MeetupEvent {// --------------------------------------------------------------- fireworks_ensureFireworks() {- if (!this.fireworks && this.cc.scene) this.fireworks = new (this._FireworksCtor)({ scene: this.cc.scene });+ if (!this.fireworks && this._Fireworks && this.cc.scene) this.fireworks = new this._Fireworks({ scene: this.cc.scene });return this.fireworks;}@@ -427,10 +436,10 @@ class MeetupEvent {}}-// Fireworks is heavier (three.js geometry churn), loaded only when a mount is-// actually possible; the class is stashed on the instance so _ensureFireworks-// can construct synchronously inside the frame loop.-async function boot() {+// Fireworks drags in three.js geometry churn, so it is imported only once an+// event that can actually mount is confirmed: a plain /play visit with no live+// event never pays for it.+export async function boot() {let cfg = null;try {const res = await fetch(CONFIG_URL, { cache: 'no-cache' });@@ -442,22 +451,21 @@ async function boot() {// every other surface that reads the event).cfg = applyPreviewOverride(cfg, location.search);- if (!cfg) return;- if (eventState(cfg, Date.now()).phase === PHASE.ENDED) return;+ if (!cfg) return null;+ if (eventState(cfg, Date.now()).phase === PHASE.ENDED) return null;const { Fireworks } = await import('./fireworks.js');// Wait for the app the same way ambient-crowd.js does.- let tries = 0;- (function wait() {- const cc = window.__CC__;- if (cc) {- const m = new MeetupEvent(cfg, cc);- m._FireworksCtor = Fireworks;- } else if (++tries < 300) {- setTimeout(wait, 300);- }- })();+ return new Promise((resolve) => {+ let tries = 0;+ (function wait() {+ const cc = window.__CC__;+ if (cc) resolve(new MeetupEvent({ event: cfg, cc, Fireworks }));+ else if (++tries < 300) setTimeout(wait, 300);+ else resolve(null);+ })();+ });}boot();diff --git a/src/physics/physics-world.js b/src/physics/physics-world.jsindex 5474f0ffe..a01342185 100644--- a/src/physics/physics-world.js+++ b/src/physics/physics-world.js@@ -16,14 +16,30 @@// body's translation is its FEET (the collider is offset upward by its own// half-height), so callers can copy it straight onto an avatar rig whose// origin sits on the floor.--import RAPIER from '@dimforge/rapier3d-compat';+//+// That inline WASM is why the import below is dynamic and NOT a static top-level+// one. The `-compat` build base64s a ~1.6 MB WASM binary into its JavaScript,+// which Rollup then folds into whatever chunk statically imports it: a static+// import here put 2.27 MB of parsed JS (774 KB over the wire) on the critical+// path of every page that draws a physics scene — /play and /walk both+// modulepreloaded it before the first frame, and the browser paid a multi-second+// parse for a module nothing needs until the world is already standing. Loading+// it from inside initRapier() gives it its own async chunk that downloads+// alongside world entry instead of ahead of it. Callers already tolerate the+// delay: PhysicsWorld.create() is awaited, and the scenes run their documented+// direct-mutation movement fallback until it resolves.let _rapierReady = null;/** Initialize the Rapier WASM runtime once and reuse it across worlds. */export function initRapier() {- if (!_rapierReady) _rapierReady = RAPIER.init().then(() => RAPIER);+ if (!_rapierReady) {+ _rapierReady = import('@dimforge/rapier3d-compat').then(async (mod) => {+ const RAPIER = mod.default ?? mod;+ await RAPIER.init();+ return RAPIER;+ });+ }return _rapierReady;}@@ -31,7 +47,7 @@ const _v = { x: 0, y: 0, z: 0 };export class PhysicsWorld {/**- * @param {typeof RAPIER} rapier initialized Rapier module+ * @param {object} rapier initialized Rapier module (from initRapier)* @param {{ gravity?: {x:number,y:number,z:number} }} [opts]*/constructor(rapier, { gravity = { x: 0, y: -14, z: 0 } } = {}) {