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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>@three-ws/page-agent — custom avatar demo</title>
<!--
ADVANCED EXAMPLE — drive YOUR OWN rigged GLB through the building blocks,
and inspect what lipsync tier it qualifies for. See
docs/guide-custom-avatars.md. Run from the package root: `npx serve .`
then open /examples/custom-avatar.html (optionally ?url=<your-glb>).
-->
<style>
:root { color-scheme: dark; }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; background: #0b0c10; color: #e9eaf0; }
.wrap { max-width: 760px; margin: 0 auto; padding: 48px 24px; }
h1 { font-size: 26px; margin: 0 0 6px; }
#stage { width: 280px; height: 360px; margin: 16px 0;
background: radial-gradient(120% 100% at 50% 0%, #1a1d27, #0c0e14); border-radius: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
input[type=url] { flex: 1; min-width: 260px; padding: 9px 12px; border-radius: 10px;
border: 1px solid #2a2c38; background: #0d0e14; color: #e9eaf0; font: inherit; }
button, select { cursor: pointer; border: 1px solid #2a2c38; background: #15161e; color: #e9eaf0;
padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; }
code, pre { background: #15161e; border-radius: 8px; }
code { padding: 2px 6px; font-size: 14px; }
pre { padding: 12px; overflow: auto; border: 1px solid #23252f; }
.tier { font-weight: 700; }
.tier[data-mode="arkit"] { color: #34d399; }
.tier[data-mode="jaw"] { color: #fbbf24; }
.tier[data-mode="none"] { color: #f87171; }
</style>
</head>
<body>
<div class="wrap">
<h1>Bring your own rigged avatar</h1>
<p>Paste a URL to a skeleton-rigged <code>.glb</code> (CORS-enabled) and load
it. We'll render it and report which lipsync tier it qualifies for.</p>
<div class="row">
<input id="url" type="url" value="https://three.ws/avatars/realistic-halfbody.glb" placeholder="https://three.ws/avatars/realistic-halfbody.glb" />
<select id="framing">
<option value="bust">bust</option>
<option value="upper" selected>upper</option>
<option value="full">full</option>
</select>
<button id="load">Load</button>
</div>
<div id="stage" aria-label="Custom avatar"></div>
<div class="row">
<button id="speak">▶ Speak a test line</button>
<button id="stop">⏹ Stop</button>
<span>Lipsync tier: <span class="tier" id="tier" data-mode="none">—</span></span>
</div>
<pre id="report">Load a model to inspect its rig…</pre>
</div>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { AvatarStage, SpeechNarrator, buildMorphMap } from '../src/index.js';
const stage = new AvatarStage(document.getElementById('stage'), { background: 'transparent' });
const narrator = new SpeechNarrator(stage, { onError: (e) => console.warn(e) });
// A minimal voice profile is all the narrator needs for a custom avatar.
narrator.setAgent({ voice: { lang: 'en-US', rate: 1, pitch: 1, match: ['samantha', 'aria', 'guy'] } });
const tierEl = document.getElementById('tier');
const reportEl = document.getElementById('report');
async function load(url) {
if (!url) return;
const framing = document.getElementById('framing').value;
reportEl.textContent = 'Loading ' + url + ' …';
try {
// Inspect the rig independently so we can report the tier even before framing.
const gltf = await new GLTFLoader().loadAsync(url);
const morph = buildMorphMap(gltf.scene);
const mode = morph?.mode || 'none';
tierEl.textContent = mode === 'arkit' ? 'viseme (best)' : mode === 'jaw' ? 'jaw' : 'animation only';
tierEl.dataset.mode = mode;
reportEl.textContent = [
'URL: ' + url,
'Lipsync: ' + (mode === 'none' ? 'no face morphs — needs a talk clip' : mode),
'Morphs: ' + (morph ? [...morph.map.keys()].join(', ') : '(none found)'),
'Clips: ' + (gltf.animations.map((c) => c.name).join(', ') || '(none — procedural idle will run)'),
].join('\n');
await stage.load(url, { framing }); // render it
} catch (err) {
tierEl.textContent = 'load failed';
tierEl.dataset.mode = 'none';
reportEl.textContent = 'Failed to load: ' + (err?.message || err) +
'\n\nCommon causes: 404, or the host is missing CORS headers (Access-Control-Allow-Origin).';
}
}
document.getElementById('load').onclick = () => load(document.getElementById('url').value.trim());
document.getElementById('speak').onclick = () =>
narrator.speak('Hello — I am a custom rigged avatar driven by the page-agent engine.', { interrupt: true });
document.getElementById('stop').onclick = () => narrator.cancel();
// Honor ?url= for quick sharing; otherwise start with a known-good catalog rig.
const fromQuery = new URLSearchParams(location.search).get('url');
const start = fromQuery || 'https://three.ws/avatars/realistic-halfbody.glb';
document.getElementById('url').value = start;
load(start);
</script>
</body>
</html>