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
feat(tutorials): update tutorial to drive agent's body animations with real APIs and AI
fudjiad57bbb4da060
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 34829b63c..ec3c7cb8f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -40,7 +40,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Hire and pay another agent, transparently — the live agent-to-agent commerce loop** — Your agent can now discover a specialist agent, check its on-chain reputation, pay it in USDC, hand off the task, and get the result back with a full receipt — who it hired, the reputation behind the choice, exactly what it cost, and the on-chain settlement reference. The agent_hire_discover tool ranks candidates by task fit, ERC-8004 reputation and real engagement; agent_hire runs the whole thing end to end and renders an inline provenance receipt card. Hard spend guardrails protect you throughout: a per-call cap, a per-session budget, and a confirmation prompt for anything above a threshold — and a blocked or failed hire is never charged. Discovery no longer comes up empty on a plain-language request, and paid hires now complete against a live agent. `[feature, improvement]`- **Markets grows a full toolkit — Heatmap, Fear & Greed, Gas Tracker, and Compare** — The Markets surface is now four tools bigger. Heatmap shows the whole market in one view — every coin a tile sized by market cap and colored by its price move. Fear & Greed puts market sentiment on a live gauge with full history. The Gas Tracker reads Ethereum fees straight from the chain, in gwei and in dollars, for transfers, swaps, and NFT mints. Compare lines up to four coins head to head — overlaying performance and every key stat, with a shareable URL. All live data, all free, all cross-linked from the markets table. (`/heatmap`) `[feature]`- **Mint a generated 3D avatar as an on-chain Solana NFT — with a live 3D viewer as its media** — You can now turn a generated or owned avatar into real, ownable on-chain property. The new mint_3d_asset tool mints your rigged GLB as a Solana NFT whose media is a live, interactive 3D viewer — not a flat picture — with the model, a rendered thumbnail, and its full provenance (who made it, the prompt, the model, its lineage) travelling with it. Creator royalties are enforced on every resale, capped at 10%. A companion get_3d_asset_onchain tool resolves any mint back to its current holder, live viewer, provenance, and royalty terms. Minting defaults to devnet for safe testing; mainnet is an explicit opt-in. It's idempotent, so a retried mint never creates a duplicate. `[feature, sdk]`-- **New tutorial: drive your agent's face from real APIs and AI** — A new developer tutorial shows how to wire the avatar's facial-emotion engine to real data — a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) reading arbitrary documents into structured emotion. Both lanes call the same public setMood()/expressEmotion() API the platform's own /agi page uses in production to embody a live trading agent's actual P&L and reputation. (`/tutorials/emotion-from-data`) `[docs, feature]`+- **New tutorial: drive your agent's animations from real APIs and AI** — A new developer tutorial shows how to trigger real body animations — celebrate, dance, flinch — from live data: a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) classifying arbitrary documents into a richer set of gestures. Both lanes use the public agent.play()/playEmote() animation API, with the cooldown pattern the platform's own production pump.fun trade-reaction engine uses to keep a fast feed from spamming the queue. (`/tutorials/emotion-from-data`) `[docs, feature]`- **New: three.ws Crypto Data API docs** — One page now documents the whole free, keyless Crypto Data API for AI agents — live at /crypto. It lays out all nine reads an agent needs mid-trade (token snapshot, security/rug signals, holders & concentration, live pump.fun launches, bonding-curve status, whale activity, symbol availability, wallet portfolio, trending) with a copy-paste quickstart in curl, JavaScript and Python, a real request/response example for each, and a live 'Try it' console right in the browser. Every endpoint is free with no key and no account. The page probes production in real time and marks each endpoint Live or Coming soon, so it stays honest as the API rolls out — and points you to the paid uniques (Pump Launcher, Vanity, Forge) when your agent is ready to act on the data. (`/crypto`) `[feature, docs]`- **On-chain identity verification now works cross-platform for any claim** — The Identity Verifier is no longer three.ws-only. Give it any claim that an identity controls an address — an ENS name (vitalik.eth), an SNS name (bonfida.sol), an EVM or Solana wallet, an ERC-8004 agent id, or a three.ws agent_id — and it returns real on-chain evidence the link is genuine: ENS/SNS resolution, a contract's deploy transaction and deployer, a token's mint and metadata authorities, an ERC-8004 registry entry, or the three.ws deploy record. Every verdict is true, false, or unverifiable — and it never reports true without concrete on-chain proof, so an insufficient read is honestly labeled instead of guessed. An agent can now verify whoever it's about to pay, trade, or delegate to, whatever platform they came from. Pair it with cross-chain Agent Reputation: verify who they are, then score whether to trust them. Full evidence model at /docs/trust-primitives. (`/docs/trust-primitives`) `[feature, improvement]`- **One x402 call runs the whole 3D asset pipeline** — New endpoint POST /api/x402/pipeline runs a full chain of 3D stages — generate → rig → remesh → gameready → stylize — as a single paid job with one price. Describe what you want (a text prompt or an existing GLB) and get back a rigged, game-ready GLB: text or GLB in, finished asset out. You pick the stages as an ordered chain, the 402 challenge quotes the exact sum of just those stages, and you poll the job for free at /api/forge?job=<id> while it advances, watching each stage's progress. Only stages whose lane is live on the deployment are offered, and if a stage fails mid-chain the job is marked failed at that stage with every completed stage's output still delivered — honest partial value, never a silent dead-end. It's the only end-to-end asset pipeline in the x402 ecosystem. (`/docs/3d-pipeline`) `[feature]`diff --git a/data/changelog.json b/data/changelog.jsonindex 7e8889de5..c7c6b5d53 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -3,8 +3,8 @@"entries": [{"date": "2026-07-07",- "title": "New tutorial: drive your agent's face from real APIs and AI",- "summary": "A new developer tutorial shows how to wire the avatar's facial-emotion engine to real data — a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) reading arbitrary documents into structured emotion. Both lanes call the same public setMood()/expressEmotion() API the platform's own /agi page uses in production to embody a live trading agent's actual P&L and reputation.",+ "title": "New tutorial: drive your agent's animations from real APIs and AI",+ "summary": "A new developer tutorial shows how to trigger real body animations — celebrate, dance, flinch — from live data: a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) classifying arbitrary documents into a richer set of gestures. Both lanes use the public agent.play()/playEmote() animation API, with the cooldown pattern the platform's own production pump.fun trade-reaction engine uses to keep a fast feed from spamming the queue.","tags": ["docs","feature"diff --git a/docs/tutorials/emotion-from-data.md b/docs/tutorials/emotion-from-data.mdindex f402bee87..893d2ada1 100644--- a/docs/tutorials/emotion-from-data.md+++ b/docs/tutorials/emotion-from-data.md@@ -1,46 +1,44 @@-# Emotion from data: wire your agent's face to real APIs and AI+# Animations from data: wire your agent's gestures to real APIs and AI-An agent whose face never changes is a puppet. An agent whose expression tracks something real — how a crowd is reacting, how a support queue is trending, how a trade is going — reads as alive. three.ws avatars already carry a full facial-emotion engine under the hood (the same "Empathy Layer" that drives the [AGI](/agi) page's body from its live trading state). This tutorial shows you how to point that engine at data you actually have: a REST API, a live feed, or a real AI model scoring arbitrary text.+An agent that just idles is furniture. An agent that visibly *reacts* — dances when something spikes, flinches when something drops, celebrates a milestone — reads as alive. three.ws ships a full animation library (idle, wave, dance, celebrate, jump, dozens more — browse them at [/animations](/animations)) and a public JS API to trigger any of it on command. This tutorial shows you how to point that at data you actually have: a live feed, a webhook, or a real AI model classifying arbitrary text.-You'll build two working pipelines — one with zero AI (a lexicon sentiment score, free, no key), one with a real model in the loop (IBM Granite scoring arbitrary documents into structured emotion) — and the production pattern for running either continuously without jank.+You'll build two working pipelines — one with zero AI (a lexicon sentiment score, free, no key, triggering a real body animation), one with a real model in the loop (IBM Granite classifying arbitrary documents, feeding a wider set of gestures) — plus the cooldown pattern that keeps an automated agent from spamming animations every tick.**What you'll build:**-- An agent whose face tracks live sentiment from a real data feed, using only `<agent-3d>`'s public JS API-- A second pipeline where an actual AI model (not a keyword list) reads arbitrary text — reviews, tickets, chat logs, anything — and returns a structured emotion score you feed straight into the avatar-- A continuous polling loop that updates mood over time without snapping or jittering, respecting `prefers-reduced-motion`-- An understanding of the two emotion layers every avatar exposes: transient spikes vs. sustained resting mood+- An agent that plays a real body animation (celebrate, dance, flinch) driven by a live sentiment feed, using only `<agent-3d>`'s public JS API+- A second pipeline where an actual AI model reads arbitrary text — reviews, tickets, chat logs, anything — and picks the matching gesture from a wider library, not just a three-way keyword split+- A cooldown/dedupe pattern so a fast-moving data source doesn't retrigger the same animation every poll+- The two real, documented entry points for animation: `agent.play(clipName)` (exact clip) and `agent.playEmote(name)` (semantic, with a fallback chain)-**Prerequisites:** You've completed [first agent](/tutorials/first-agent) or have an `<agent-3d>` element on a page. For the AI lane, a small amount of USDC and familiarity with the [x402 payment flow](/tutorials/pay-for-x402-service) — the call costs $0.04.+**Prerequisites:** You've completed [first agent](/tutorials/first-agent) or have an `<agent-3d>` element on a page, and ideally [the JS API tutorial](/tutorials/js-api-events) (Step 5 covers the animation basics this one builds on). For the AI lane, a small amount of USDC and familiarity with the [x402 payment flow](/tutorials/pay-for-x402-service) — the call costs $0.04.----## Step 1 — The two emotion layers+## Step 1 — The two animation entry points-Every `<agent-3d>` element exposes two methods for driving facial expression, and they answer different questions.+Every `<agent-3d>` element exposes two public methods for triggering body animation, and — per the [JS API tutorial](/tutorials/js-api-events#step-5--animations-exact-name-vs-hint) — they answer different questions.-**`expressEmotion(trigger, weight)`** — "something just happened." A transient spike that decays back to neutral on its own. Use it for events: a purchase completed, an error occurred, a message arrived.+**`agent.play(clipName)`** — plays the clip with that *exact* name from the loaded library or GLB. Case-sensitive; if the name isn't found, nothing plays. Use this once you know what's actually in the rig — e.g. `agent.play('rumba')`, `agent.play('thriller')`, `agent.play('celebrate')`. The full catalog (idle, locomotion, dance, gesture, action, sport, reaction, fitness — every clip a real, retargetable library entry, never hardcoded per-rig) is browsable at [/animations](/animations).-```js-agent.expressEmotion('celebration', 0.8); // decays over ~6s-```--Valid triggers: `celebration`, `concern`, `curiosity`, `empathy`, `patience`. `weight` is 0–1 and defaults to 0.7.--**`setMood(valence, arousal, opts)`** — "this is how it's feeling right now, as a baseline." A sustained resting state the avatar drifts toward continuously — a gentle smile and open posture when positive, a worried brow when negative — composited underneath any transient `expressEmotion` spikes rather than fighting them.+**`agent.playEmote(name)`** — a higher-level wrapper for the small set of product-moment reactions with a built-in fallback chain, so it's guaranteed to do *something* regardless of which clips the loaded rig actually has:```js-agent.setMood(0.4, 0.5); // valence -1..1 (despair→elation), arousal 0..1 (calm→activated)+agent.playEmote('celebrate'); // celebrate → wave+agent.playEmote('cheer'); // cheer → celebrate → wave+agent.playEmote('flinch'); // flinch → defeated → concern → shake```-`opts.reducedMotion` (boolean) tells the empathy layer to skip the drift animation and snap directly, for visitors with `prefers-reduced-motion: reduce` set.+If none of a chain's names exist on the rig, `playEmote` falls back to a small head-bob rather than doing nothing — so it's the safe default for "react to this event" code, and `play()` is for "I know exactly which clip I want."++Convenience shortcut: `agent.wave()`.-The pattern for "emotion from data" is: **your data source feeds `setMood()` continuously** for the resting state, and you fire `expressEmotion()` on top for discrete moments worth calling out. Everything below builds on top of just these two calls — no other API surface is needed.+The pattern for "animation from data" is: **your data source picks a discrete outcome** (celebrate / flinch / a specific dance), and you call `playEmote()` or `play()` with that name. Unlike the sustained facial-mood layer (`setMood()` — covered separately, see the note at the end), these are one-shot performances that play out and settle back to idle on their own.----## Step 2 — The free lane: sentiment → mood, no AI required+## Step 2 — The free lane: sentiment → animation, no AI required-The platform already runs a public, unauthenticated sentiment scorer over live pump.fun token chat: [`POST /api/social/sentiment-pulse`](../../api/social/sentiment-pulse.js). It pulls recent comments for a token and scores them with an in-repo lexicon (no LLM call, no key, no rate-limit surprises) — good enough to prove the wiring before you reach for a model.+The platform runs a public, unauthenticated sentiment scorer over live pump.fun token chat: [`POST /api/social/sentiment-pulse`](../../api/social/sentiment-pulse.js). It pulls recent comments for a token and scores them with an in-repo lexicon (no LLM call, no key) — good enough to prove the wiring before you reach for a model.```html<!DOCTYPE html>@@ -56,6 +54,8 @@ The platform already runs a public, unauthenticated sentiment scorer over live p<script type="module">const agent = document.getElementById('agent');const TOKEN = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump'; // $THREE, or any mint+ let lastFired = 0;+ const COOLDOWN_MS = 20_000; // never retrigger faster than thisasync function pulse() {const res = await fetch('https://three.ws/api/social/sentiment-pulse', {@@ -67,27 +67,27 @@ The platform already runs a public, unauthenticated sentiment scorer over live preturn res.json();}- function applyMood(overall) {- // scoreSentiment() already returns score in [-1, 1] — that's valence- // directly. Arousal comes from how much chatter there is and how- // one-sided it is (a wall of comments that agree reads as "activated").- const valence = Math.max(-1, Math.min(1, overall.score));- const lopsidedness = Math.abs(overall.posPct - overall.negPct) / 100;- const volume = Math.min(1, overall.count / 60);- const arousal = Math.max(0.15, lopsidedness * 0.6 + volume * 0.4);- agent.setMood(valence, arousal, {- reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,- });-- // Fire a one-off spike on strong, fresh sentiment so it reads as a reaction,- // not just a slow drift.- if (overall.score > 0.5) agent.expressEmotion('celebration', Math.min(1, overall.score));- else if (overall.score < -0.5) agent.expressEmotion('concern', Math.min(1, Math.abs(overall.score)));+ function reactTo(overall) {+ // scoreSentiment() returns score in [-1, 1] and posPct/negPct/count.+ // Require both a strong score AND enough chatter to trust it — a+ // single glowing comment shouldn't trigger a full celebration.+ const confident = overall.count >= 5;+ const now = performance.now();+ if (now - lastFired < COOLDOWN_MS) return; // still cooling down++ if (confident && overall.score > 0.45) {+ agent.playEmote('celebrate');+ lastFired = now;+ } else if (confident && overall.score < -0.45) {+ agent.playEmote('flinch');+ lastFired = now;+ }+ // Middling/uncertain sentiment: leave whatever's currently playing alone.}async function tick() {const data = await pulse();- if (data?.ok) applyMood(data.overall);+ if (data?.ok) reactTo(data.overall);}agent.addEventListener('agent:ready', () => {@@ -99,30 +99,36 @@ The platform already runs a public, unauthenticated sentiment scorer over live p</html>```-Save that as `index.html` and open it — no build step, no server, no wallet. Swap `TOKEN` for any Solana mint and the face tracks that token's live chat mood.+Save that as `index.html` and open it — no build step, no server, no wallet. Swap `TOKEN` for any Solana mint and the agent physically celebrates or flinches as that token's live chat swings.----## Step 3 — The AI lane: real emotion inference over arbitrary data+## Step 3 — The AI lane: real classification over arbitrary data, richer gestures-A lexicon scorer only works on short, informal text and only tells you positive/negative. For real documents — support tickets, product reviews, meeting transcripts, incident reports — you want a model that returns *structured* emotion: a sentiment score plus a breakdown across joy, anger, fear, sadness, surprise, and disgust. `ibm_granite_analyze` (part of the [IBM Granite x402 MCP suite](../ibm-x402-mcp.md)) does exactly this for $0.04/call, no IBM account needed — you pay in USDC, it pays IBM.+A lexicon scorer only works on short, informal text and only gives you positive/negative. For real documents — support tickets, product reviews, meeting transcripts, incident reports — you want a model that returns *structured* emotion: a sentiment score plus a breakdown across joy, anger, fear, sadness, surprise, and disgust, so you can pick a more specific reaction than a binary celebrate/flinch. `ibm_granite_analyze` (part of the [IBM Granite x402 MCP suite](../ibm-x402-mcp.md)) does exactly this for $0.04/call, no IBM account needed — you pay in USDC, it pays IBM.-This is a server-side call (it needs a wallet to sign the payment), so it lives behind a small endpoint you host yourself and the browser polls. The `@three-ws/x402-fetch` package does the 402 → sign → retry dance for you, the same way `window.X402.pay` does in the browser — see [pay-for-x402-service](/tutorials/pay-for-x402-service) for the full protocol if you want the mechanics.+This is a server-side call (it needs a wallet to sign the payment), so it lives behind a small endpoint you host yourself and the browser polls. The `@three-ws/x402-fetch` package does the 402 → sign → retry dance for you — see [pay-for-x402-service](/tutorials/pay-for-x402-service) for the full protocol if you want the mechanics.```js-// mood-from-ai.js — run with `node mood-from-ai.js`, or drop the body of-// scoreEmotion() into any serverless handler (Vercel/Cloud Run/etc).+// gesture-from-ai.js — run with `node gesture-from-ai.js`, or drop the body of+// gestureFor() into any serverless handler (Vercel/Cloud Run/etc).import { withX402, privateKeyToWallet } from '@three-ws/x402-fetch';const wallet = privateKeyToWallet(process.env.SOLANA_PRIVATE_KEY); // funds the $0.04 callsconst fetchWithPay = withX402(fetch, wallet);-// High-arousal emotions push the needle further from calm than low-arousal ones.-const AROUSAL_WEIGHT = { anger: 0.9, fear: 0.85, surprise: 0.8, joy: 0.55, sadness: 0.3, disgust: 0.45 };-// Which discrete trigger best represents the dominant emotion, for expressEmotion().-const DOMINANT_TRIGGER = { joy: 'celebration', anger: 'concern', fear: 'concern', sadness: 'empathy', surprise: 'curiosity', disgust: 'concern' };--async function scoreEmotion(document) {+// Dominant emotion → the richest matching clip. exact-name clips (agent.play)+// give a bigger, more specific performance than the 3-way emote chain.+const GESTURE_FOR = {+ joy: 'celebrate',+ surprise: 'silly',+ anger: 'shake',+ fear: 'defeated',+ sadness: 'defeated',+ disgust: 'angry',+};++async function gestureFor(document) {const res = await fetchWithPay('https://three.ws/api/ibm-mcp', {method: 'POST',headers: { 'Content-Type': 'application/json' },@@ -139,77 +145,77 @@ async function scoreEmotion(document) {const { result } = await res.json();const analysis = JSON.parse(result.content[0].text);- const valence = Math.max(-1, Math.min(1, analysis.sentiment.score));const breakdown = analysis.emotion_breakdown || {};- const dominant = Object.entries(breakdown).sort((a, b) => b[1] - a[1])[0]?.[0] || 'joy';- const arousal = Math.max(- 0.15,- Object.entries(breakdown).reduce((sum, [k, v]) => sum + v * (AROUSAL_WEIGHT[k] || 0.5), 0),- );+ const [dominant, strength] = Object.entries(breakdown).sort((a, b) => b[1] - a[1])[0] || ['joy', 0];++ // Below this, the signal is too weak to justify interrupting idle.+ if (strength < 0.3) return null;- return { valence, arousal, trigger: DOMINANT_TRIGGER[dominant], summary: analysis.summary };+ return { clip: GESTURE_FOR[dominant] || null, strength, summary: analysis.summary };}```-Wire that into a one-route endpoint (`GET /mood?text=...` returning the JSON above), and the browser side is the same shape as Step 2 — swap the `fetch` call and keep `applyMood()`:+Wire that into a one-route endpoint (`GET /gesture?text=...` returning the JSON above), and the browser side reuses the same cooldown-gated `reactTo()` shape from Step 2 — swap the fetch call and the trigger:```jsasync function tick() {- const res = await fetch(`/mood?text=${encodeURIComponent(latestDocument)}`);- const { valence, arousal, trigger } = await res.json();- agent.setMood(valence, arousal, { reducedMotion: prefersReduced });- if (trigger) agent.expressEmotion(trigger, Math.min(1, Math.abs(valence)) || 0.5);+ const res = await fetch(`/gesture?text=${encodeURIComponent(latestDocument)}`);+ const { clip } = await res.json();+ const now = performance.now();+ if (clip && now - lastFired > COOLDOWN_MS) {+ agent.play(clip); // exact library name, e.g. 'shake', 'silly', 'celebrate'+ lastFired = now;+ }}```-Now anything you can turn into a string — a webhook payload, a scraped page, a batch of reviews — can drive the avatar's face through a real model instead of a keyword list.+Now anything you can turn into a string — a webhook payload, a scraped page, a batch of reviews — can drive a specific, visible body performance instead of a static idle loop.----## Step 4 — Running it continuously without jank+## Step 4 — Don't let fast data spam the animation queue-Three rules the platform's own production instance of this pattern (see Step 5) follows, worth copying:+Two rules worth copying from the platform's own production reaction engine ([`src/widgets/pumpfun-reactions.js`](../../src/widgets/pumpfun-reactions.js) — the pump.fun live-trade avatar reactor, 23 distinct clips across dozens of event shapes):-1. **Don't poll faster than your data actually changes.** `setMood()` already lerps toward the target over ~1s so a mood *change* reads as a drift, not a cut — but polling every 2s when your source updates every 30s just spends API budget for no visual gain.-2. **Fail to neutral, not to silence.** If the fetch throws or the model call fails, don't skip the tick — call `agent.setMood(0.12, 0.32)` (the avatar's own default resting state) so a broken data source reads as "calm," not as a frozen or crashed face.-3. **Always pass `reducedMotion` from `matchMedia('(prefers-reduced-motion: reduce)')`.** The empathy layer respects it by snapping instead of drifting — free accessibility, one line.+1. **Cooldown, not "react to every event."** A fast feed (trades, comments, ticks) will fire far more often than a physical performance can play out. Gate triggers behind a minimum interval (`COOLDOWN_MS` above) — the production reactor goes further and queues lower-priority events behind an in-flight gesture instead of dropping or interrupting it.+2. **Require confidence before you interrupt idle.** A single data point (one comment, one weak signal) shouldn't yank the avatar out of idle. Both examples above gate on a minimum sample size / signal strength (`overall.count >= 5`, `strength >= 0.3`) — tune the threshold to your own data's noise floor.```js-async function tick() {- const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;- try {- const { valence, arousal, trigger } = await fetchMood();- agent.setMood(valence, arousal, { reducedMotion });- if (trigger) agent.expressEmotion(trigger, 0.7);- } catch {- agent.setMood(0.12, 0.32, { reducedMotion }); // neutral, not broken- }+let lastFired = 0;+const COOLDOWN_MS = 20_000;++function reactIfConfident(clipOrEmoteName, { confident, useExactClip = false } = {}) {+ const now = performance.now();+ if (!confident || now - lastFired < COOLDOWN_MS) return false;+ useExactClip ? agent.play(clipOrEmoteName) : agent.playEmote(clipOrEmoteName);+ lastFired = now;+ return true;}```----## Step 5 — See it live+## A note on the facial layer-The platform runs exactly this pattern in production on [/agi](/agi): [`api/agi/state.js`](../../api/agi/state.js) computes a real cognition vector server-side — valence from live unrealized P&L and on-chain reputation, arousal from how recently the agent last acted — from a real autonomous trading agent's actual track record (never sampled or faked). [`src/agi.js`](../../src/agi.js) polls it every 20s and applies it with the exact `setMood` / `expressEmotion` calls shown above (`applyMood()`, around line 90). Open `/agi` and watch the aura and the avatar's resting expression shift as the underlying trader's P&L moves — that's this tutorial's Step 3/4 pattern, shipped.+`agent.play()` / `agent.playEmote()` drive the *body* — the skeleton, via the shared animation-clip library. There's a separate, independent layer for the *face*: `agent.setMood(valence, arousal)` / `agent.expressEmotion(trigger, weight)` drive ARKit-52 blendshapes (smile, brow, gaze) on avatars that carry them, without touching the skeleton at all. The two compose — a `celebrate` clip moves the arms while the face layer, if you're also driving it, can separately smile — but they're distinct systems with distinct APIs. This tutorial covers the body; if you want the face to track data too, the same fetch/cooldown pattern above applies, just swapping in `setMood()`/`expressEmotion()`.---## Troubleshooting-- **Face never moves.** Confirm `agent:ready` fired before your first `setMood()` call — calling it before boot is silently no-op'd. Wrap your first tick in the `agent:ready` listener as shown in Step 2.-- **Mood snaps instead of drifting.** You're calling `setMood()` far more often than your data changes, so each call interrupts the lerp from the previous one. Widen your poll interval.-- **`expressEmotion` throws no error but nothing happens.** The trigger name is misspelled — it must be exactly one of `celebration`, `concern`, `curiosity`, `empathy`, `patience` (case-sensitive).-- **AI lane 402 loop / never resolves.** Your `SOLANA_PRIVATE_KEY` wallet has no USDC. Fund it with a few cents — see [fund](/tutorials) or the [x402 payment flow](/tutorials/pay-for-x402-service).+- **Nothing plays.** Confirm `agent:ready` fired before your first `play()`/`playEmote()` call — calling either before boot is silently a no-op. Wrap your first tick in the `agent:ready` listener as shown in Step 2.+- **`agent.play('someClip')` does nothing.** The name is case-sensitive and must match a clip actually present on the rig — check the exact name at [/animations](/animations) or fall back to `playEmote()`, which degrades gracefully instead of silently failing.+- **The agent keeps re-celebrating every poll.** You skipped the cooldown gate in Step 4, or your confidence threshold is too low for a noisy feed. Widen `COOLDOWN_MS` or raise the sample-size/strength floor.+- **AI lane 402 loop / never resolves.** Your `SOLANA_PRIVATE_KEY` wallet has no USDC. Fund it with a few cents — see the [x402 payment flow](/tutorials/pay-for-x402-service).- **`analysis.emotion_breakdown` is undefined.** You passed `analysis_type` other than `sentiment` — only that type returns the per-emotion breakdown; the other five types return type-specific fields instead (see [ibm-x402-mcp](../ibm-x402-mcp.md)).---## Recap-- `expressEmotion(trigger, weight)` for transient reactions, `setMood(valence, arousal, opts)` for sustained resting state — both are public methods on every `<agent-3d>` element, no library beyond the CDN script.+- `agent.play(clipName)` for an exact clip, `agent.playEmote(name)` for a safer semantic trigger with a fallback chain — both are public methods on every `<agent-3d>` element, no library beyond the CDN script.- The free lane (`/api/social/sentiment-pulse`) proves the wiring with zero AI and zero cost.-- The AI lane (`ibm_granite_analyze` over x402) turns arbitrary documents — not just short informal text — into structured, multi-dimensional emotion for $0.04/call.-- `/agi` is the live, real-money production example of this exact pattern — read its source when you want to see the pattern under real load.+- The AI lane (`ibm_granite_analyze` over x402) turns arbitrary documents into a richer emotion breakdown, unlocking more of the animation library than a simple positive/negative split.+- Gate every automated trigger behind a cooldown and a confidence floor — [`pumpfun-reactions.js`](../../src/widgets/pumpfun-reactions.js) is the production-grade version of this exact pattern, queueing and prioritizing real trade-feed events across 23 distinct clips.-**Related tutorials:** [Trigger the agent from page events](/tutorials/trigger-from-page-events) · [Connect Anthropic or OpenAI as the brain](/tutorials/connect-ai-brain) · [Discover and pay for an x402 service](/tutorials/pay-for-x402-service) · [MCP server for your agent](/tutorials/mcp-server-for-your-agent)+**Related tutorials:** [The JS API — animations, exact name vs. hint](/tutorials/js-api-events) · [Trigger the agent from page events](/tutorials/trigger-from-page-events) · [Animate your avatar](/tutorials/animate-your-avatar) · [Discover and pay for an x402 service](/tutorials/pay-for-x402-service)diff --git a/public/changelog.json b/public/changelog.jsonindex 7f4c5c497..a4ea531d9 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-07T23:53:44.043Z",+ "generated_at": "2026-07-08T00:08:53.648Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -361,8 +361,8 @@{"date": "2026-07-07","type": "update",- "title": "New tutorial: drive your agent's face from real APIs and AI",- "summary": "A new developer tutorial shows how to wire the avatar's facial-emotion engine to real data — a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) reading arbitrary documents into structured emotion. Both lanes call the same public setMood()/expressEmotion() API the platform's own /agi page uses in production to embody a live trading agent's actual P&L and reputation.",+ "title": "New tutorial: drive your agent's animations from real APIs and AI",+ "summary": "A new developer tutorial shows how to trigger real body animations — celebrate, dance, flinch — from live data: a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) classifying arbitrary documents into a richer set of gestures. Both lanes use the public agent.play()/playEmote() animation API, with the cooldown pattern the platform's own production pump.fun trade-reaction engine uses to keep a fast feed from spamming the queue.","link": "/tutorials/emotion-from-data","tags": ["docs",diff --git a/public/changelog.xml b/public/changelog.xmlindex 939f629a5..a885e5ebe 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -279,12 +279,12 @@<description>You can now turn a generated or owned avatar into real, ownable on-chain property. The new mint_3d_asset tool mints your rigged GLB as a Solana NFT whose media is a live, interactive 3D viewer — not a flat picture — with the model, a rendered thumbnail, and its full provenance (who made it, the prompt, the model, its lineage) travelling with it. Creator royalties are enforced on every resale, capped at 10%. A companion get_3d_asset_onchain tool resolves any mint back to its current holder, live viewer, provenance, and royalty terms. Minting defaults to devnet for safe testing; mainnet is an explicit opt-in. It's idempotent, so a retried mint never creates a duplicate.</description></item><item>- <title>New tutorial: drive your agent's face from real APIs and AI</title>+ <title>New tutorial: drive your agent's animations from real APIs and AI</title><link>https://three.ws/tutorials/emotion-from-data</link>- <guid isPermaLink="false">2026-07-07:New tutorial: drive your agent's face from real APIs and AI</guid>+ <guid isPermaLink="false">2026-07-07:New tutorial: drive your agent's animations from real APIs and AI</guid><pubDate>Tue, 07 Jul 2026 12:00:00 GMT</pubDate><category>docs</category>- <description>A new developer tutorial shows how to wire the avatar's facial-emotion engine to real data — a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) reading arbitrary documents into structured emotion. Both lanes call the same public setMood()/expressEmotion() API the platform's own /agi page uses in production to embody a live trading agent's actual P&L and reputation.</description>+ <description>A new developer tutorial shows how to trigger real body animations — celebrate, dance, flinch — from live data: a free lexicon-sentiment lane to prove the wiring in a single HTML file, then a real AI model (IBM Granite over x402) classifying arbitrary documents into a richer set of gestures. Both lanes use the public agent.play()/playEmote() animation API, with the cooldown pattern the platform's own production pump.fun trade-reaction engine uses to keep a fast feed from spamming the queue.</description></item><item><title>New: three.ws Crypto Data API docs</title>diff --git a/public/features.json b/public/features.jsonindex a04331757..c1f8b3bc3 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-07T23:53:44.030Z",+ "generated_at": "2026-07-08T00:08:53.636Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/public/sitemap/index.html b/public/sitemap/index.htmlindex de4b67b22..369a92b2b 100644--- a/public/sitemap/index.html+++ b/public/sitemap/index.html@@ -56,25 +56,6 @@.sm-brand img { width: 24px; height: 24px; border-radius: 5px; }.sm-brand:hover { text-decoration: none; }</style>-- <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">- <meta property="og:type" content="website">- <meta property="og:site_name" content="three.ws">- <meta property="og:locale" content="en_US">- <meta property="og:title" content="Sitemap · three.ws">- <meta property="og:description" content="Human-readable index of every page on three.ws.">- <meta property="og:url" content="https://three.ws/sitemap">- <meta property="og:image" content="https://three.ws/api/page-og?s=main&t=Sitemap&d=Human-readable+index+of+every+page+on+three.ws.&p=%2Fsitemap">- <meta property="og:image:width" content="1200">- <meta property="og:image:height" content="630">- <meta property="og:image:type" content="image/png">- <meta property="og:image:alt" content="Sitemap — three.ws">- <meta name="twitter:card" content="summary_large_image">- <meta name="twitter:site" content="@trythreews">- <meta name="twitter:title" content="Sitemap · three.ws">- <meta name="twitter:description" content="Human-readable index of every page on three.ws.">- <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&t=Sitemap&d=Human-readable+index+of+every+page+on+three.ws.&p=%2Fsitemap">- <script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebPage","name":"Sitemap","description":"Human-readable index of every page on three.ws.","url":"https://three.ws/sitemap","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"},"primaryImageOfPage":"https://three.ws/api/page-og?s=main&t=Sitemap&d=Human-readable+index+of+every+page+on+three.ws.&p=%2Fsitemap"}]}</script></head><body><header class="sm-topbar">diff --git a/public/tutorials-manifest.js b/public/tutorials-manifest.jsindex 3f7d9b5a0..41fc69fed 100644--- a/public/tutorials-manifest.js+++ b/public/tutorials-manifest.js@@ -337,12 +337,12 @@{slug: 'emotion-from-data',tier: 'advanced',- title: 'Emotion from data: wire your agent to real APIs and AI',- blurb: 'Drive the avatar\'s facial expression from a live data feed — a free lexicon lane to prove the wiring, then a real AI model scoring arbitrary text into structured emotion. The exact pattern that powers /agi in production.',- builds: 'An agent whose face tracks a live data feed through real AI',+ title: 'Animations from data: wire your agent\'s gestures to real APIs and AI',+ blurb: 'Trigger real body animations — celebrate, dance, flinch — from a live data feed. A free lexicon lane to prove the wiring, then a real AI model classifying arbitrary text into a richer set of gestures, with cooldown/dedupe so a fast feed never spams the queue.',+ builds: 'An agent that physically reacts to a live data feed through real AI',time: '25 min',previewModel: '/animations/robotexpressive.glb',- ctaPrimary: { label: 'See it live on /agi', href: '/agi' },+ ctaPrimary: { label: 'Browse the animation library', href: '/animations' },},{slug: 'custom-skill',