Skip to content

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.

feat(avatar-walk): add toggle functionality for avatar walking animation

nirholas02d8de28f9c8
diff --git a/.vercelignore b/.vercelignore
index eb2d602a8..d4ef1ddee 100644
--- a/.vercelignore
+++ b/.vercelignore
@@ -6,7 +6,10 @@
tests
specs
-examples
+examples/*
+!examples/skills
+examples/skills/*
+!examples/skills/pump-fun-strategy
prompts
contracts
sdk
diff --git a/public/test-avatar-chat.html b/public/test-avatar-chat.html
deleted file mode 100644
index b39183867..000000000
--- a/public/test-avatar-chat.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Avatar-Chat Test</title>
- <style>
- body { margin: 0; background: #0b0d10; color: white; font-family: system-ui; }
- .container { display: flex; height: 100vh; gap: 16px; padding: 16px; box-sizing: border-box; }
- agent-3d { flex: 0 0 360px; height: 100%; }
- .controls { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
- button { padding: 8px 16px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); color: white; border-radius: 8px; cursor: pointer; }
- button:hover { background: rgba(255,255,255,0.1); }
- .status { font-size: 12px; opacity: 0.6; padding: 8px; background: rgba(255,255,255,0.04); border-radius: 8px; }
- pre { margin: 0; font-size: 11px; white-space: pre-wrap; }
- </style>
-</head>
-<body>
- <div class="container">
- <agent-3d
- id="agent"
- src="/animations/robotexpressive.glb"
- brain="claude-opus-4-6"
- background="dark"
- mode="inline"
- responsive="false"
- width="360px"
- height="100%"
- ></agent-3d>
-
- <div class="controls">
- <h2>Avatar-Chat Test Panel</h2>
-
- <div>
- <strong>Layout Toggle</strong><br>
- <button onclick="toggle()">Toggle avatar-chat="off"</button>
- <span id="toggle-state">ON</span>
- </div>
-
- <div>
- <strong>Manual Triggers</strong><br>
- <button onclick="send('Hello, say something short.')">Short response</button>
- <button onclick="send('Write a detailed 3-paragraph explanation of how blockchain works.')">Long response</button>
- <button onclick="send('What are the trending tokens on pump.fun?')">Tool call (if skill installed)</button>
- </div>
-
- <div>
- <strong>Event Log</strong>
- <div class="status"><pre id="log"></pre></div>
- </div>
- </div>
- </div>
-
- <script type="module">
- import '/src/element.js';
-
- const agent = document.getElementById('agent');
- const log = document.getElementById('log');
- const toggleState = document.getElementById('toggle-state');
- let lines = [];
-
- function addLog(msg) {
- lines.unshift(`${new Date().toISOString().slice(11,23)} ${msg}`);
- lines = lines.slice(0, 20);
- log.textContent = lines.join('\n');
- }
-
- for (const ev of ['brain:thinking', 'brain:stream', 'brain:message', 'skill:tool-start', 'skill:tool-called', 'voice:speech-start', 'voice:speech-end']) {
- agent.addEventListener(ev, (e) => {
- const detail = ev === 'brain:stream'
- ? `chunk="${e.detail?.chunk?.slice(0,20)}…"`
- : JSON.stringify(e.detail || {}).slice(0, 60);
- addLog(`${ev} ${detail}`);
- });
- }
-
- window.toggle = () => {
- if (agent.getAttribute('avatar-chat') === 'off') {
- agent.removeAttribute('avatar-chat');
- toggleState.textContent = 'ON';
- } else {
- agent.setAttribute('avatar-chat', 'off');
- toggleState.textContent = 'OFF';
- }
- };
-
- window.send = (text) => agent.say(text);
- </script>
-</body>
-</html>
diff --git a/specs/EMBED_SPEC.md b/specs/EMBED_SPEC.md
index cfdf438b8..9efb11bd3 100644
--- a/specs/EMBED_SPEC.md
+++ b/specs/EMBED_SPEC.md
@@ -89,6 +89,7 @@ All on-chain forms resolve through [`src/erc8004/resolver.js`](../src/erc8004/re
| `scale` | number | `1.0` | camera zoom multiplier, independent of pixel size |
| `responsive` | boolean | on | applies `clamp()`-based mobile shrinking |
| `avatar-chat` | `"off"` | on (default) | Set to `"off"` to disable the integrated avatar-in-chat layout. In default mode, the avatar is part of the chat flow, walking during streaming and scrolling, and displaying a thought bubble for status and text. |
+| `avatar-walk` | `"off"` | on (default) | Set to `"off"` to disable the walking animation during streaming and scrolling. The avatar will remain idle or perform empathy animations instead. |
### Integrated Avatar Chat
diff --git a/src/element.js b/src/element.js
index 5ed1c2b81..135470565 100644
--- a/src/element.js
+++ b/src/element.js
@@ -523,6 +523,7 @@ class Agent3DElement extends HTMLElement {
'name-plate',
'tracked-mint',
'avatar-chat',
+ 'avatar-walk',
];
}
@@ -613,6 +614,9 @@ class Agent3DElement extends HTMLElement {
? attachTradeReactions(this, { mint: newVal })
: null;
}
+ if (name === 'avatar-walk' && newVal === 'off') {
+ this._stopWalkAnimation();
+ }
if (['src', 'manifest', 'body', 'agent-id'].includes(name)) {
// Source change — reboot
this._teardown();
@@ -748,7 +752,10 @@ class Agent3DElement extends HTMLElement {
// Walk when the chat is scrolling — user-initiated or auto
chat.addEventListener('scroll', () => {
- if (this.getAttribute('avatar-chat') !== 'off') {
+ if (
+ this.getAttribute('avatar-chat') !== 'off' &&
+ this.getAttribute('avatar-walk') !== 'off'
+ ) {
this._onStreamChunk();
}
}, { passive: true });
@@ -1288,6 +1295,7 @@ class Agent3DElement extends HTMLElement {
requestAnimationFrame(_nudge);
}
this._scene = new SceneController(viewer);
+ if (bodyURI) this._scene.playClipByName('idle', { loop: true });
// Memory
this.dispatchEvent(
@@ -1820,7 +1828,7 @@ class Agent3DElement extends HTMLElement {
// Walk animation: debounced — keeps walking as long as chunks arrive within 600ms of each other.
_onStreamChunk() {
- if (!this._scene || this.getAttribute('avatar-chat') === 'off') return;
+ if (!this._scene || this.getAttribute('avatar-walk') === 'off') return;
if (this.hasAttribute('kiosk')) return;
const prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (!this._isWalking && !prefersReduced) {
@@ -2348,6 +2356,27 @@ class Agent3DElement extends HTMLElement {
this._clearThoughtBubble();
}
+ /**
+ * Enable the walk animation during streaming and scrolling.
+ * This is the default state. Call to re-enable after {@link disableAvatarWalk}.
+ * @returns {void}
+ */
+ enableAvatarWalk() {
+ this.removeAttribute('avatar-walk');
+ }
+
+ /**
+ * Disable the walk animation globally.
+ * The avatar will stay in its idle or empathy-layer animations even while
+ * streaming text or scrolling the chat.
+ * Equivalent to setting the `avatar-walk="off"` attribute.
+ * @returns {void}
+ */
+ disableAvatarWalk() {
+ this.setAttribute('avatar-walk', 'off');
+ this._stopWalkAnimation();
+ }
+
async installSkill(uri) {
if (!this._skills) throw new Error('Agent not mounted');
return this._skills.install({ uri });