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
fix: mark subproject commits as dirty for worktree consistency
nirholas10f7e71e515b
diff --git a/.gitignore b/.gitignoreindex fd3653ce4..404baa55d 100644--- a/.gitignore+++ b/.gitignore@@ -15,3 +15,6 @@ character-studio/node_modulescharacter-studio/buildcharacter-studio/public/loot-assets.mcp.json++# Animation build cache+public/animations/clips/.input-hashes.jsondiff --git a/app.html b/app.htmlindex fc25272d5..ca641129a 100644--- a/app.html+++ b/app.html@@ -61,6 +61,7 @@</h1><nav class="features-nav"><a href="/app" class="active">Viewer</a>+ <a href="/create">Create</a><a href="/features">Features</a><a href="/discover">Discover</a><a href="/widgets">Widgets</a>diff --git a/home.css b/home.cssindex 145381a1b..83faafc04 100644--- a/home.css+++ b/home.css@@ -27,8 +27,9 @@}}-/* ── Act 2 Three.js canvas (full-area, transparent) ─────────────────────── */+/* ── Three.js canvas viewers (hero + Act 2) ─────────────────────────────── */+#hero-avatar.h-avatar-viewer,#home-act2-canvas.h-avatar-viewer {display: block;width: 100%;@@ -223,8 +224,8 @@.h-bento-grid {display: grid;- grid-template-columns: repeat(3, 1fr);- grid-template-rows: auto auto;+ grid-template-columns: 2fr 1fr;+ grid-auto-rows: auto;gap: 1rem;}@@ -244,26 +245,139 @@}.h-bento-card--lg {- grid-column: span 2;- grid-row: span 2;+ grid-column: 1;+ grid-row: 1 / span 4;display: grid;- grid-template-rows: 1fr auto;+ grid-template-rows: 1fr auto auto;}.h-bento-visual {position: relative;- min-height: 280px;+ min-height: 360px;background: rgba(255, 255, 255, 0.02);}.h-bento-visual model-viewer {width: 100%;height: 100%;- min-height: 280px;+ min-height: 360px;background: transparent;--poster-color: transparent;}+.h-bento-cz-canvas {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ display: block;+ cursor: grab;+}++.h-bento-anim-panel {+ border-top: 1px solid rgba(255, 255, 255, 0.06);+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);+ background: rgba(0, 0, 0, 0.28);+ padding: 0.7rem 1rem 0.6rem;+ display: flex;+ flex-direction: column;+ gap: 0.45rem;+}++.h-bento-anim-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+}++.h-bento-anim-title {+ font-size: 0.62rem;+ font-weight: 600;+ letter-spacing: 0.14em;+ text-transform: uppercase;+ color: rgba(255, 255, 255, 0.4);+ font-family: 'Space Grotesk', 'Inter', sans-serif;+}++.h-bento-anim-stop {+ background: none;+ border: none;+ color: rgba(255, 255, 255, 0.35);+ font-size: 0.85rem;+ cursor: pointer;+ padding: 2px 6px;+ border-radius: 4px;+ transition: color 0.2s, background 0.2s;+ line-height: 1;+}++.h-bento-anim-stop:hover {+ color: #f87171;+ background: rgba(248, 113, 113, 0.1);+}++.h-bento-anim-grid {+ display: flex;+ gap: 0.4rem;+ overflow-x: auto;+ scrollbar-width: thin;+ scrollbar-color: rgba(255, 255, 255, 0.12) transparent;+ padding-bottom: 4px;+}++.h-bento-anim-grid::-webkit-scrollbar { height: 4px; }+.h-bento-anim-grid::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 2px; }++.h-bento-anim-btn {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 2px;+ padding: 0.45rem 0.55rem;+ min-width: 56px;+ background: rgba(255, 255, 255, 0.04);+ border: 1px solid rgba(255, 255, 255, 0.08);+ border-radius: 8px;+ color: rgba(255, 255, 255, 0.6);+ font-family: inherit;+ cursor: pointer;+ transition: all 0.18s ease;+ flex-shrink: 0;+}++.h-bento-anim-btn:hover:not(:disabled) {+ background: rgba(255, 255, 255, 0.08);+ border-color: rgba(255, 255, 255, 0.18);+ color: #fff;+}++.h-bento-anim-btn--active {+ background: rgba(167, 139, 250, 0.18);+ border-color: rgba(167, 139, 250, 0.5);+ color: #fff;+ box-shadow: 0 0 14px rgba(167, 139, 250, 0.18);+}++.h-bento-anim-btn--loading {+ opacity: 0.4;+ cursor: wait;+}++.h-bento-anim-btn__icon {+ font-size: 1.15rem;+ line-height: 1;+}++.h-bento-anim-btn__label {+ font-size: 9px;+ font-weight: 500;+ letter-spacing: 0.03em;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ max-width: 64px;+}+.h-bento-body {padding: 1.4rem 1.6rem;display: flex;@@ -508,6 +622,7 @@}.h-bento-card--lg {grid-column: span 2;+ grid-row: auto;}.h-dev-inner {grid-template-columns: 1fr;@@ -520,7 +635,7 @@}.h-bento-card--lg {grid-column: span 1;- grid-row: span 1;+ grid-row: auto;}.h-trust-inner {gap: 1rem;diff --git a/home.html b/home.htmlindex d1f8260aa..c72fd2b44 100644--- a/home.html+++ b/home.html@@ -49,6 +49,7 @@</h1><nav class="home-nav" aria-label="Primary"><a href="/app">Viewer</a>+ <a href="/create">Create</a><a href="/studio">Studio</a><a href="/widgets">Widgets</a><a href="/features">Docs</a>@@ -99,24 +100,11 @@<div class="h-avatar-wrap"><div class="h-avatar-ring"></div><div class="h-avatar-glow"></div>- <model-viewer+ <canvasid="hero-avatar"class="h-avatar-viewer"- src="/avatars/cz.glb"- alt="three.ws — interactive 3D agent. Click for surprises."- animation-name="IdleV4.2(maya_head)"- autoplay- disable-zoom- interaction-prompt="none"- shadow-intensity="0.9"- shadow-softness="1"- exposure="1.1"- tone-mapping="aces"- environment-image="neutral"- camera-orbit="-45deg 80deg 8.5m"- field-of-view="18deg"- loading="eager"- ></model-viewer>+ aria-label="three.ws — interactive 3D agent. Click for surprises."+ ></canvas><div class="h-avatar-badge"><span class="h-avatar-badge-label">live agent</span><span>0x3d…a9f</span>@@ -365,24 +353,17 @@<h2 class="h-section-title">Everything an agent needs<br />to exist in the world.</h2></div><div class="h-bento-grid">- <!-- Large card: 3D viewer -->+ <!-- Large card: 3D viewer + inline animation panel --><div class="h-bento-card h-bento-card--lg h-reveal"><div class="h-bento-visual">- <model-viewer- src="/avatars/cz.glb"- auto-rotate- auto-rotate-delay="0"- rotation-per-second="14deg"- interaction-prompt="none"- camera-controls- disable-zoom- shadow-intensity="0.7"- exposure="1.0"- environment-image="neutral"- camera-orbit="0deg 72deg 2.8m"- field-of-view="30deg"- loading="lazy"- ></model-viewer>+ <canvas id="bento-cz-canvas" class="h-bento-cz-canvas"></canvas>+ </div>+ <div class="h-bento-anim-panel" data-role="bento-anim-panel">+ <div class="h-bento-anim-header">+ <span class="h-bento-anim-title">Animations</span>+ <button type="button" class="h-bento-anim-stop" data-role="bento-anim-stop" title="Stop all">⏹</button>+ </div>+ <div class="h-bento-anim-grid" data-role="bento-anim-grid"></div></div><div class="h-bento-body"><span class="h-bento-tag">Viewer</span>@@ -498,11 +479,12 @@</div><nav class="h-footer-links" aria-label="Footer"><a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">GitHub</a>- <a href="/features">Docs</a><a href="/features">Features</a>- <a href="/studio">Widgets</a>+ <a href="/widgets">Widgets</a><a href="/discover">Discover</a><a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a>+ <a href="/legal/privacy">Privacy</a>+ <a href="/legal/tos">Terms</a></nav><p class="h-footer-copy">Open source · MIT license</p></div>@@ -549,17 +531,14 @@});})();- // Hero avatar — track cursor + orbit on scroll + clickable easter eggs+ // Hero avatar — Act2Viewer with cursor/scroll orbit + click → real animations(function () {const scrollEl = document.querySelector('.home-parallax');- const mv = document.getElementById('hero-avatar');- const wrap = mv ? mv.closest('.h-avatar-wrap') : null;+ const canvas = document.getElementById('hero-avatar');const heroAct = document.querySelector('.h-hero-act');- if (!scrollEl || !mv || !wrap || !heroAct) return;+ if (!scrollEl || !canvas || !heroAct) return;- let mouseX = 0, mouseY = 0;- let scrollProgress = 0;- let dollyOffset = 0; /* additive zoom from click reaction */+ let mouseX = 0, mouseY = 0, scrollProgress = 0;const BASE_THETA = -45, BASE_PHI = 80, BASE_R = 8.5;let curTheta = BASE_THETA, curPhi = BASE_PHI, curR = BASE_R;@@ -572,50 +551,44 @@scrollProgress = Math.min(scrollEl.scrollTop / heroAct.offsetHeight, 1);}, { passive: true });- function tick() {- /* sweep from left-front (-45°) to right-front (+45°) — never- rotates past the side, so we never show CZ's back. */- const scrollTheta = scrollProgress * 90;- const scrollPhi = -scrollProgress * 8;- const scrollR = scrollProgress * 0.8;- const cursorTheta = mouseX * 16;- const cursorPhi = mouseY * 6;- const targetTheta = BASE_THETA + scrollTheta + cursorTheta;- const targetPhi = BASE_PHI + scrollPhi + cursorPhi;- const targetR = BASE_R + scrollR + dollyOffset;- curTheta += (targetTheta - curTheta) * 0.07;- curPhi += (targetPhi - curPhi) * 0.07;- curR += (targetR - curR) * 0.12;- mv.setAttribute('camera-orbit',- curTheta.toFixed(1) + 'deg ' +- curPhi.toFixed(1) + 'deg ' +- curR.toFixed(2) + 'm');- requestAnimationFrame(tick);+ function whenReady(cb) {+ if (window.Act2Viewer) return cb();+ setTimeout(() => whenReady(cb), 60);}- tick();-- /* Click → random fun trick (CZ has no extra animations, so we do- it with CSS transforms on the wrap: fall over, spin, push-up,- jump). State is auto-cleared. */- /* CZ has only one baked animation in his GLB (Idle), so faking- skeletal motion with CSS transforms looks plastic. Instead,- clicking does a real camera dolly-zoom — actual rendering- on the real animated model = looks natural, like /app. */- let dollyActive = false;- mv.style.cursor = 'pointer';- mv.addEventListener('click', () => {- if (dollyActive) return;- dollyActive = true;- const t0 = performance.now();- const dur = 700;- function step(now) {- const t = Math.min((now - t0) / dur, 1);- const wave = Math.sin(t * Math.PI); /* 0 → 1 → 0 */- dollyOffset = -3.2 * wave; /* zoom in 3.2m closer at peak */- if (t < 1) requestAnimationFrame(step);- else { dollyOffset = 0; dollyActive = false; }- }- requestAnimationFrame(step);++ whenReady(() => {+ const viewer = new window.Act2Viewer(canvas, { fov: 18 });++ /* cursor + scroll orbit loop — matches original model-viewer camera-orbit params */+ (function tick() {+ const scrollTheta = scrollProgress * 90;+ const scrollPhi = -scrollProgress * 8;+ const scrollR = scrollProgress * 0.8;+ curTheta += (BASE_THETA + scrollTheta + mouseX * 16 - curTheta) * 0.07;+ curPhi += (BASE_PHI + scrollPhi + mouseY * 6 - curPhi) * 0.07;+ curR += (BASE_R + scrollR - curR) * 0.12;+ viewer.setOrbit(curTheta, curPhi, curR);+ requestAnimationFrame(tick);+ })();++ viewer.loadModel('/avatars/cz.glb').catch(console.error);++ /* click → random manifest animation; non-looping ones return to idle */+ const FUN = ['wave', 'dance', 'celebrate', 'jump', 'silly', 'rumba', 'capoeira', 'thriller'];+ let lastAnim = null;+ canvas.style.cursor = 'pointer';+ canvas.addEventListener('click', async () => {+ const pool = FUN.filter(a => a !== lastAnim);+ const name = pool[Math.floor(Math.random() * pool.length)];+ lastAnim = name;+ try {+ await viewer.playClip(name);+ const def = viewer._manifest.find(d => d.name === name);+ if (def && !def.loop) {+ setTimeout(() => viewer.playClip('idle').catch(() => {}), 2600);+ }+ } catch (_) {}+ });});})();@@ -691,6 +664,66 @@});})();+ // Bento Viewer card — same Act2Viewer + animation panel as Act 2+ (function () {+ const canvas = document.getElementById('bento-cz-canvas');+ const grid = document.querySelector('[data-role="bento-anim-grid"]');+ const stopBtn = document.querySelector('[data-role="bento-anim-stop"]');+ if (!canvas || !grid) return;++ function whenReady(cb) {+ if (window.Act2Viewer) return cb();+ setTimeout(() => whenReady(cb), 60);+ }++ whenReady(() => {+ const viewer = new window.Act2Viewer(canvas);++ function prettyLabel(def) {+ return (def.label || def.name).replace(/\s*\([^)]*\)/g, '').trim();+ }++ function buildButtons(defs) {+ grid.innerHTML = '';+ defs.forEach((def, i) => {+ const btn = document.createElement('button');+ btn.type = 'button';+ btn.className = 'h-bento-anim-btn';+ btn.dataset.anim = def.name;+ btn.title = def.label || def.name;+ const icon = document.createElement('span');+ icon.className = 'h-bento-anim-btn__icon';+ icon.textContent = def.icon || '✨';+ const label = document.createElement('span');+ label.className = 'h-bento-anim-btn__label';+ label.textContent = prettyLabel(def);+ btn.appendChild(icon);+ btn.appendChild(label);+ if (i === 0) btn.classList.add('h-bento-anim-btn--active');+ btn.addEventListener('click', async () => {+ grid.querySelectorAll('.h-bento-anim-btn').forEach((b) => b.classList.remove('h-bento-anim-btn--active'));+ btn.classList.add('h-bento-anim-btn--active');+ btn.classList.add('h-bento-anim-btn--loading');+ try { await viewer.playClip(def.name); } catch (_) {}+ btn.classList.remove('h-bento-anim-btn--loading');+ });+ grid.appendChild(btn);+ });+ }++ viewer.onClipsReady = buildButtons;+ viewer.loadModel('/avatars/cz.glb').catch(console.error);++ if (stopBtn) {+ stopBtn.addEventListener('click', () => {+ if (viewer.mixer) viewer.mixer.stopAllAction();+ viewer.currentAction = null;+ grid.querySelectorAll('.h-bento-anim-btn').forEach((b) => b.classList.remove('h-bento-anim-btn--active'));+ });+ }+ });+ })();+// Chain ribbon (Act 3)(function () {const ribbon = document.querySelector('[data-role="home-chain-ribbon"]');diff --git a/index.html b/index.htmlindex 3d527e07d..6556a4463 100644--- a/index.html+++ b/index.html@@ -759,10 +759,11 @@</h1><nav class="features-nav" aria-label="Primary"><a href="/app">Viewer</a>+ <a href="/create">Create</a><a href="/discover">Discover</a><a href="/features">Features</a><a href="/widgets">Widgets</a>- <a href="/docs">Docs</a>+ <a href="/docs/widgets">Docs</a><a href="/dashboard" class="nav-dashboard">Dashboard</a><a href="/my-agents" id="nav-my-agents" hidden>My Agents</a><a href="/login" class="nav-sign-in" id="nav-sign-in">Sign in</a>@@ -1169,10 +1170,11 @@<a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">GitHub</a>- · <a href="/features">Docs</a> · <a href="/deploy">Deploy on-chain</a> ·+ · <a href="/docs/widgets">Docs</a> · <a href="/deploy">Deploy on-chain</a> ·<a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a>+ · <a href="/legal/privacy">Privacy</a> · <a href="/legal/tos">Terms</a></p></footer></main>diff --git a/package.json b/package.jsonindex 991ca9167..1af321827 100644--- a/package.json+++ b/package.json@@ -35,7 +35,7 @@"scripts": {"dev": "vite --port 3000","dev:lib": "TARGET=lib vite",- "build": "npm run build:animations && vite build",+ "build": "vite build","build:animations": "node scripts/build-animations.mjs","build:lib": "TARGET=lib vite build","build:artifact": "vite build --config vite.config.artifact.js",diff --git a/public/features/features.css b/public/features/features.cssindex acfdd3faf..e871864ea 100644--- a/public/features/features.css+++ b/public/features/features.css@@ -366,18 +366,84 @@pointer-events: none;}+.act-agent-wrap {+ position: relative;+ width: clamp(340px, 42vw, 560px);+ aspect-ratio: 1;+ display: flex;+ align-items: center;+ justify-content: center;+ pointer-events: auto;+}++[data-role='act1-stage'] .act-agent-wrap {+ transform: translate(12vw, -6vh);+}++@media (max-width: 768px) {+ [data-role='act1-stage'] .act-agent-wrap {+ transform: translate(6vw, -3vh);+ }+}+.act-agent {+ position: relative;display: block;- width: clamp(280px, 32vw, 480px);- aspect-ratio: 4 / 5;+ width: 100%;+ height: 100%;+ background: transparent;+ --poster-color: transparent;pointer-events: auto;filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.5));- opacity: 0;- transition: opacity 0.6s ease 0.1s;+ z-index: 2;}-.act-agent[data-ready='true'] {- opacity: 1;+.act-agent-ring {+ position: absolute;+ inset: -6%;+ border-radius: 50%;+ border: 1px solid rgba(255, 215, 106, 0.18);+ box-shadow:+ 0 0 0 1px rgba(255, 215, 106, 0.06) inset,+ 0 0 80px rgba(255, 215, 106, 0.18);+ pointer-events: none;+ z-index: 1;+}++.act-agent-ring--violet {+ border-color: rgba(167, 139, 250, 0.22);+ box-shadow:+ 0 0 0 1px rgba(167, 139, 250, 0.08) inset,+ 0 0 80px rgba(167, 139, 250, 0.22);+}++.act-agent-ring--mint {+ border-color: rgba(110, 231, 183, 0.22);+ box-shadow:+ 0 0 0 1px rgba(110, 231, 183, 0.08) inset,+ 0 0 80px rgba(110, 231, 183, 0.22);+}++.act-agent-glow {+ position: absolute;+ inset: 10%;+ border-radius: 50%;+ filter: blur(60px);+ opacity: 0.55;+ pointer-events: none;+ z-index: 0;+}++.act-agent-glow--gold {+ background: radial-gradient(circle, var(--features-gold), transparent 70%);+}++.act-agent-glow--violet {+ background: radial-gradient(circle, var(--features-violet), transparent 70%);+}++.act-agent-glow--mint {+ background: radial-gradient(circle, var(--features-mint), transparent 70%);}/* Passport tag (Act 3) */@@ -892,11 +958,6 @@animation: none;}- .act-agent {- opacity: 1;- transition: none;- }-.layer-stars-canvas {display: none;}diff --git a/public/features/features.js b/public/features/features.jsindex 16ea6547f..701a36e49 100644--- a/public/features/features.js+++ b/public/features/features.js@@ -1,15 +1,12 @@/*** /features — page wiring.*- * - Lazy-boots Act 2 and Act 3 <agent-3d> elements when scrolled into view- * (Act 1 has [eager] in markup so it boots immediately).- * - Wires Act 2 emotion chips → element.expressEmotion(trigger).- * - Fetches a real on-chain agent for Act 3 and shows its passport tag.+ * - Wires Act 2 emotion chips → robotexpressive animation playback.+ * - Fetches a real on-chain agent and shows its passport tag on Act 3.* - Populates the chain ribbon (Act 3 background) from a fixed list — kept* in sync visually with src/erc8004/chains.js but not imported (this page* is a static asset, no module graph connection to /src).* - Wires the embed-snippet copy button.- * - Reveals the agent (fade in) once it dispatches `agent:ready`.** No build step. Plain ES module loaded via <script type="module">.*/@@ -70,52 +67,15 @@ function chainLabel(chainId) {return SHORT_NAME_BY_CHAIN.get(Number(chainId)) || `chain ${chainId}`;}-function onAgentReady(agentEl, fn) {- agentEl.addEventListener('agent:ready', fn, { once: true });-}--// ── Lazy-boot Acts 2 & 3 when their stage scrolls into view ──────────────--function setupLazyBoot() {- const lazyEls = ROOT.querySelectorAll('agent-3d:not([eager])[data-role^="act"]');- if (!lazyEls.length) return;+// ── Act 2: emotion chip → robotexpressive animation ──────────────────────- const io = new IntersectionObserver(- (entries) => {- for (const entry of entries) {- if (!entry.isIntersecting) continue;- const el = entry.target;- // Setting `eager` triggers an internal boot path on agent-3d,- // or we just rely on the existing IntersectionObserver inside- // the element. Setting `eager` is a belt-and-braces nudge.- el.setAttribute('eager', '');- io.unobserve(el);- }- },- { rootMargin: '200px 0px', threshold: 0.05 },- );-- for (const el of lazyEls) io.observe(el);-}--// ── Reveal each agent on `agent:ready` ───────────────────────────────────--function setupReveal() {- for (const el of ROOT.querySelectorAll('agent-3d.act-agent')) {- // If the agent dispatched agent:ready before this listener attached,- // the data-ready guard catches the case via mutation fallback.- onAgentReady(el, () => {- el.dataset.ready = 'true';- });- // Safety: reveal after 6s even if ready never fires (network failure- // shouldn't leave a perpetually invisible blob on the page).- setTimeout(() => {- if (!el.dataset.ready) el.dataset.ready = 'true';- }, 6000);- }-}--// ── Act 2: emotion chip → expressEmotion ─────────────────────────────────+const EMOTION_TO_ANIM = {+ celebration: 'Dance',+ curiosity: 'Wave',+ empathy: 'ThumbsUp',+ concern: 'No',+ patience: 'Yes',+};function setupEmotionChips() {const wrap = ROOT.querySelector('[data-role="emotion-chips"]');@@ -128,23 +88,13 @@ function setupEmotionChips() {const trigger = btn.getAttribute('data-emotion');if (!trigger) return;- // Visual feedback (works even if agent hasn't booted yet)btn.dataset.active = 'true';setTimeout(() => delete btn.dataset.active, 600);- // Trigger on the live avatar via the public API added in src/element.js.- // Falls back silently if the method isn't defined (e.g. very old CDN- // bundle); chips still feel responsive thanks to the visual feedback.- if (typeof agentEl.expressEmotion === 'function') {- agentEl.expressEmotion(trigger, 0.95);- } else {- // Fallback: dispatch a custom event the integrator can hook on.- agentEl.dispatchEvent(- new CustomEvent('emote', {- detail: { trigger, weight: 0.95 },- bubbles: true,- }),- );+ const animName = EMOTION_TO_ANIM[trigger];+ if (animName && (agentEl.availableAnimations || []).includes(animName)) {+ agentEl.animationName = animName;+ agentEl.play();}});}@@ -170,7 +120,6 @@ async function loadOnChainAgent() {const chainEl = ROOT.querySelector('[data-role="passport-chain"]');const codeIdEl = ROOT.querySelector('[data-role="code-agent-id"]');const statAgents = ROOT.querySelector('[data-role="stat-agents"]');- const act3Agent = ROOT.querySelector('[data-role="act3-agent"]');try {// Fetch a recently-registered on-chain agent. /api/agents/suggest needs@@ -186,9 +135,6 @@ async function loadOnChainAgent() {const onChain = agents.find((a) => a.onChain);if (!onChain) return;- // Load the chosen agent into the Act 3 avatar.- if (act3Agent) act3Agent.setAttribute('agent-id', onChain.id);-// Update the embed-code snippet to show a real id.if (codeIdEl) codeIdEl.textContent = shortAddr(onChain.id);@@ -294,8 +240,6 @@ function setupProgressDots() {function init() {initStarFields();paintChainRibbon();- setupReveal();- setupLazyBoot();setupEmotionChips();setupCopyEmbed();setupProgressDots();diff --git a/public/features/index.html b/public/features/index.htmlindex f00896cee..b1fc8ec4a 100644--- a/public/features/index.html+++ b/public/features/index.html@@ -32,7 +32,6 @@rel="stylesheet"/><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>- <script type="module" src="https://three.ws/agent-3d/latest/agent-3d.js"></script></head><body class="features-page features-parallax-page"><a href="#deploy" class="skip-link">Skip to deploy</a>@@ -115,13 +114,29 @@</div><div class="parallax-layer parallax-layer--front" style="--depth: 1"><div class="act-stage" data-role="act1-stage">- <agent-3d- class="act-agent"- data-role="act1-agent"- kiosk- eager- aria-label="Live 3D avatar — drag to rotate"- ></agent-3d>+ <div class="act-agent-wrap">+ <div class="act-agent-ring"></div>+ <div class="act-agent-glow act-agent-glow--gold"></div>+ <model-viewer+ class="act-agent"+ data-role="act1-agent"+ src="/avatars/cz.glb"+ alt="Live 3D avatar — drag to rotate"+ animation-name="IdleV4.2(maya_head)"+ autoplay+ camera-controls+ disable-zoom+ interaction-prompt="none"+ shadow-intensity="0.9"+ shadow-softness="1"+ exposure="1.1"+ tone-mapping="aces"+ environment-image="neutral"+ camera-orbit="-25deg 80deg 8.5m"+ field-of-view="18deg"+ loading="eager"+ ></model-viewer>+ </div></div></div><div class="parallax-layer" style="--depth: 0.5" aria-hidden="true">@@ -212,12 +227,27 @@</div><div class="parallax-layer parallax-layer--front" style="--depth: 1"><div class="act-stage" data-role="act2-stage">- <agent-3d- class="act-agent"- data-role="act2-agent"- kiosk- aria-label="3D avatar reacting to emotion triggers"- ></agent-3d>+ <div class="act-agent-wrap">+ <div class="act-agent-ring act-agent-ring--violet"></div>+ <div class="act-agent-glow act-agent-glow--violet"></div>+ <model-viewer+ class="act-agent"+ data-role="act2-agent"+ src="/animations/robotexpressive.glb"+ alt="3D avatar reacting to emotion triggers"+ animation-name="Idle"+ autoplay+ camera-controls+ disable-zoom+ interaction-prompt="none"+ shadow-intensity="0.7"+ exposure="1.0"+ environment-image="neutral"+ camera-orbit="0deg 78deg 22m"+ field-of-view="14deg"+ loading="lazy"+ ></model-viewer>+ </div></div></div><div class="parallax-layer" style="--depth: 0.5" aria-hidden="true">@@ -304,12 +334,27 @@</div><div class="parallax-layer parallax-layer--front" style="--depth: 1"><div class="act-stage" data-role="act3-stage">- <agent-3d- class="act-agent"- data-role="act3-agent"- kiosk- aria-label="A registered on-chain ERC-8004 agent"- ></agent-3d>+ <div class="act-agent-wrap">+ <div class="act-agent-ring act-agent-ring--mint"></div>+ <div class="act-agent-glow act-agent-glow--mint"></div>+ <model-viewer+ class="act-agent"+ data-role="act3-agent"+ src="/animations/soldier.glb"+ alt="A registered on-chain ERC-8004 agent"+ animation-name="Idle"+ autoplay+ camera-controls+ disable-zoom+ interaction-prompt="none"+ shadow-intensity="0.8"+ exposure="1.0"+ environment-image="neutral"+ camera-orbit="10deg 82deg 4m"+ field-of-view="28deg"+ loading="lazy"+ ></model-viewer>+ </div><div class="act-passport" data-role="passport" hidden><span class="passport-label">agentId</span><span class="passport-value" data-role="passport-id">—</span>diff --git a/scripts/build-animations.mjs b/scripts/build-animations.mjsindex 806445979..dcbac5287 100644--- a/scripts/build-animations.mjs+++ b/scripts/build-animations.mjs@@ -16,6 +16,7 @@* Run via: npm run build:animations*/import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from 'node:fs';+import { createHash } from 'node:crypto';import { fileURLToPath } from 'node:url';import { dirname, resolve, basename } from 'node:path';import { Blob } from 'node:buffer';@@ -55,6 +56,19 @@ const OUT_DIR = resolve(ANIM_DIR, 'clips');const REFERENCE_GLB = resolve(ROOT, 'public/avatars/cz.glb');const CONFIG = resolve(__dirname, 'animations.config.json');const MANIFEST_OUT = resolve(ANIM_DIR, 'manifest.json');+const HASH_CACHE = resolve(ANIM_DIR, 'clips/.input-hashes.json');++function hashFile(path) {+ return createHash('sha1').update(readFileSync(path)).digest('hex');+}++function loadHashCache() {+ try { return JSON.parse(readFileSync(HASH_CACHE, 'utf8')); } catch { return {}; }+}++function saveHashCache(cache) {+ writeFileSync(HASH_CACHE, JSON.stringify(cache, null, '\t') + '\n');+}const MIXAMO_PREFIX = /^mixamorig\d*[_:]?/i;// Mixamo FBX exports hip translation in centimeters relative to the rig's@@ -138,26 +152,60 @@ async function serializeClip(clip) {async function main() {const config = JSON.parse(readFileSync(CONFIG, 'utf8'));- if (existsSync(OUT_DIR)) rmSync(OUT_DIR, { recursive: true, force: true });mkdirSync(OUT_DIR, { recursive: true });- console.log('[animations] loading reference Avaturn rig:', basename(REFERENCE_GLB));- const reference = await loadGLB(REFERENCE_GLB);- const avaturnBones = collectBoneNames(reference.scene);- console.log(`[animations] reference rig has ${avaturnBones.size} bones`);+ const hashCache = loadHashCache();+ const rigHash = hashFile(REFERENCE_GLB);+ const configHash = hashFile(CONFIG);+ const inputKey = `rig:${rigHash}|config:${configHash}`;++ // Lazy-load the reference rig only if at least one clip needs retargeting.+ let avaturnBones = null;+ async function getRig() {+ if (avaturnBones) return avaturnBones;+ console.log('[animations] loading reference Avaturn rig:', basename(REFERENCE_GLB));+ const reference = await loadGLB(REFERENCE_GLB);+ avaturnBones = collectBoneNames(reference.scene);+ console.log(`[animations] reference rig has ${avaturnBones.size} bones`);+ return avaturnBones;+ }const manifest = [];let okCount = 0;+ let skipCount = 0;let failCount = 0;for (const def of config) {const fbxPath = resolve(ANIM_DIR, def.source);+ const outName = `${def.name}.json`;+ const outPath = resolve(OUT_DIR, outName);+if (!existsSync(fbxPath)) {console.warn(`[animations] SKIP ${def.name}: missing source ${def.source}`);failCount++;continue;}++ // Skip retargeting if the FBX + rig + config haven't changed and output exists.+ const fbxHash = hashFile(fbxPath);+ const cacheKey = `${inputKey}|fbx:${fbxHash}`;+ if (hashCache[def.name] === cacheKey && existsSync(outPath)) {+ const existing = JSON.parse(readFileSync(outPath, 'utf8'));+ manifest.push({+ name: def.name,+ url: `/animations/clips/${outName}`,+ label: def.label,+ icon: def.icon,+ loop: def.loop !== false,+ });+ console.log(`[animations] CACHED ${def.name}`);+ skipCount++;+ okCount++;+ continue;+ }+try {+ const bones = await getRig();const fbx = await loadFBX(fbxPath);const sourceClip = fbx.animations?.[0];if (!sourceClip) {@@ -165,7 +213,7 @@ async function main() {failCount++;continue;}- const { clip, matched, total, dropped } = retargetClip(sourceClip, avaturnBones);+ const { clip, matched, total, dropped } = retargetClip(sourceClip, bones);const matchPct = (matched / total) * 100;if (matchPct < 60) {console.warn(@@ -176,9 +224,9 @@ async function main() {}clip.name = def.name;const json = await serializeClip(clip);- const outName = `${def.name}.json`;const text = JSON.stringify(json);- writeFileSync(resolve(OUT_DIR, outName), text);+ writeFileSync(outPath, text);+ hashCache[def.name] = cacheKey;manifest.push({name: def.name,url: `/animations/clips/${outName}`,@@ -197,9 +245,10 @@ async function main() {}}+ saveHashCache(hashCache);writeFileSync(MANIFEST_OUT, JSON.stringify(manifest, null, '\t') + '\n');console.log(`\n[animations] wrote manifest with ${manifest.length} clips → ${MANIFEST_OUT}`);- console.log(`[animations] ${okCount} ok, ${failCount} failed`);+ console.log(`[animations] ${okCount} ok (${skipCount} cached), ${failCount} failed`);if (okCount === 0) process.exit(1);}diff --git a/src/home-act2-viewer.js b/src/home-act2-viewer.jsindex 002974a7a..12a29b64a 100644--- a/src/home-act2-viewer.js+++ b/src/home-act2-viewer.js@@ -31,7 +31,7 @@ import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';const CROSSFADE = 0.35;export class Act2Viewer {- constructor(canvas) {+ constructor(canvas, { fov = 14 } = {}) {this.canvas = canvas;this.renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true });this.renderer.toneMapping = ACESFilmicToneMapping;@@ -39,7 +39,7 @@ export class Act2Viewer {this.renderer.outputColorSpace = SRGBColorSpace;this.scene = new Scene();- this.camera = new PerspectiveCamera(14, 1, 0.1, 100);+ this.camera = new PerspectiveCamera(fov, 1, 0.1, 100);this.camera.position.set(0, 1.0, 22);/* neutral environment (matches model-viewer's environment-image="neutral") */@@ -65,6 +65,8 @@ export class Act2Viewer {this._loader = new GLTFLoader();this._clock = new Clock();this._modelYaw = 0;+ this._modelFocusY = 1.0;+ this._externalOrbit = false;/** Optional callback when the chip list changes (manifest + GLB-baked combined). */this.onClipsReady = null;@@ -91,8 +93,8 @@ export class Act2Viewer {_tick() {const dt = this._clock.getDelta();if (this.mixer) this.mixer.update(dt);- if (this.model) {- this._modelYaw += dt * 0.18; /* slow auto-rotate, like model-viewer's auto-rotate */+ if (this.model && !this._externalOrbit) {+ this._modelYaw += dt * 0.18;this.model.rotation.y = this._modelYaw;}this.renderer.render(this.scene, this.camera);@@ -175,8 +177,10 @@ export class Act2Viewer {/* fit camera to model height with a comfortable framing */const targetHeight = size.y;const dist = (targetHeight / 2) / Math.tan((this.camera.fov / 2) * (Math.PI / 180));- this.camera.position.set(0, targetHeight * 0.55, dist * 1.2);- this.camera.lookAt(0, targetHeight * 0.55, 0);+ this._modelFocusY = targetHeight * 0.55;+ this._externalOrbit = false;+ this.camera.position.set(0, this._modelFocusY, dist * 1.2);+ this.camera.lookAt(0, this._modelFocusY, 0);this.mixer = new AnimationMixer(this.model);@@ -235,6 +239,25 @@ export class Act2Viewer {this.currentAction = action;}+ /**+ * Orbit the camera around the model using polar coordinates matching model-viewer's+ * camera-orbit convention: theta = azimuth (deg), phi = elevation from top (deg),+ * radius = distance (m). Calling this disables internal auto-rotate.+ */+ setOrbit(thetaDeg, phiDeg, radius) {+ this._externalOrbit = true;+ const theta = thetaDeg * (Math.PI / 180);+ const phi = phiDeg * (Math.PI / 180);+ const sinPhi = Math.sin(phi);+ const cosPhi = Math.cos(phi);+ this.camera.position.set(+ radius * sinPhi * Math.sin(theta),+ this._modelFocusY + radius * cosPhi,+ radius * sinPhi * Math.cos(theta),+ );+ this.camera.lookAt(0, this._modelFocusY, 0);+ }+setExposure(v) {this.renderer.toneMappingExposure = v;}