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
Default <agent-3d> to a bare avatar; chat is opt-in
nirholasfddec03518de
diff --git a/examples/_verify-modes.html b/examples/_verify-modes.htmlnew file mode 100644index 000000000..49130bfce--- /dev/null+++ b/examples/_verify-modes.html@@ -0,0 +1,21 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <title>verify modes</title>+ <style>+ body { margin: 0; display: flex; gap: 8px; background: #222; }+ .cell { width: 360px; height: 600px; }+ </style>+ </head>+ <body>+ <!-- 1: default → BARE -->+ <agent-3d id="a" class="cell" body="/avatars/cz.glb" eager></agent-3d>+ <!-- 2: chat attr → CHAT -->+ <agent-3d id="b" class="cell" chat body="/avatars/cz.glb" instructions="hi" eager></agent-3d>+ <!-- 3: kiosk → BARE (force) -->+ <agent-3d id="c" class="cell" kiosk body="/avatars/cz.glb" eager></agent-3d>++ <script type="module" src="../src/element.js"></script>+ </body>+</html>diff --git a/examples/bare-avatar.html b/examples/bare-avatar.htmlindex da8e9a761..80e9b087d 100644--- a/examples/bare-avatar.html+++ b/examples/bare-avatar.html@@ -23,8 +23,9 @@</style></head><body>- <!-- JUST the avatar. kiosk = no chat/input/debug GUI; name-plate=off = no label; transparent by default. -->- <agent-3d kiosk name-plate="off" body="/avatars/cz.glb" width="420px" height="560px"></agent-3d>+ <!-- JUST the avatar — the default. No chat, no input, no debug GUI, no name-plate,+ transparent background. Add the `chat` attribute to opt into the conversational UI. -->+ <agent-3d body="/avatars/cz.glb" width="420px" height="560px"></agent-3d><script type="module" src="../src/element.js"></script></body>diff --git a/examples/embed-test.html b/examples/embed-test.htmlindex e44a1f161..b44a6f6dc 100644--- a/examples/embed-test.html+++ b/examples/embed-test.html@@ -27,6 +27,7 @@<script type="module" src="https://three.ws/dist-lib/agent-3d.js"></script><agent-3d+ chatsrc="https://three.ws/api/avatars/bdef4d68-710e-4fa6-8a8d-d5c00857b85c"style="width: 600px; height: 600px"></agent-3d>diff --git a/examples/minimal.html b/examples/minimal.htmlindex b35a96f6a..3c773b4f6 100644--- a/examples/minimal.html+++ b/examples/minimal.html@@ -62,23 +62,27 @@<div class="two-col"><div class="card"><h2>Inline embed</h2>- <p>The agent below is embedded inline, flowing with the page content.</p>+ <p>+ A plain <code><agent-3d></code> is just the avatar. Add the+ <code>chat</code> attribute to give it the conversational UI.+ </p><agent-3d+ chatbody="/avatars/cz.glb"instructions="You are a friendly 3D guide."width="100%"height="320px"- brain="claude-opus-4-6"+ brain="claude-opus-4-8"></agent-3d></div><div class="card"><h2>The snippet</h2><pre>-<agent-3d- body="/avatars/cz.glb"- width="100%"- height="320px"-></agent-3d></pre+<!-- just the avatar -->+<agent-3d body="/avatars/cz.glb"></agent-3d>++<!-- avatar + chat -->+<agent-3d chat body="/avatars/cz.glb"></agent-3d></pre></div></div>@@ -86,8 +90,9 @@<p>Floating bubble in the corner ↘ — like a chatbot, but embodied.</p></main>- <!-- Floating bubble — bottom-right of the viewport -->+ <!-- Floating bubble — bottom-right of the viewport. `chat` makes it a talkative greeter. --><agent-3d+ chatbody="/avatars/cz.glb"instructions="You are a cheerful 3D greeter. Wave when users say hi."mode="floating"diff --git a/examples/one-line-demo.html b/examples/one-line-demo.htmlindex 789f07f0a..3bf34afce 100644--- a/examples/one-line-demo.html+++ b/examples/one-line-demo.html@@ -38,8 +38,8 @@<p>Everything below the heading is a single <code><agent-3d></code> tag.</p><div class="frame">- <!-- THE ONE LINE -->- <agent-3d body="/avatars/cz.glb" instructions="You are a friendly 3D guide for three.ws." width="100%" height="460px" brain="claude-opus-4-8"></agent-3d>+ <!-- THE ONE LINE — `chat` adds the conversational UI; drop it for just the avatar -->+ <agent-3d chat body="/avatars/cz.glb" instructions="You are a friendly 3D guide for three.ws." width="100%" height="460px" brain="claude-opus-4-8"></agent-3d></div></main>diff --git a/examples/two-agents.html b/examples/two-agents.htmlindex 7b65e6004..ac7f87fb9 100644--- a/examples/two-agents.html+++ b/examples/two-agents.html@@ -76,6 +76,7 @@<agent-stage id="stage" formation="row"><agent-3did="leo"+ chatname="Coach Leo"body="/avatars/cz.glb"instructions="You are Coach Leo. Friendly, short answers. When another agent says hi, wave and greet them back by name."@@ -83,6 +84,7 @@></agent-3d><agent-3did="mira"+ chatname="Mira"body="/avatars/cz.glb"brain="none"diff --git a/src/element.js b/src/element.jsindex c4dab5ded..9be29425e 100644--- a/src/element.js+++ b/src/element.js@@ -585,6 +585,12 @@ const BASE_STYLE = `background: rgba(255,255,255,0.3);}:host([mode="floating"]) .drag-handle { display: block; }+ /* Bare avatar (the default) — reflected as data-bare by _reflectChromeState().+ Hide the dat.GUI debug panel (incl. its color-picker hue strip) and the+ axes gizmo so a plain <agent-3d> is the avatar and nothing else. */+ :host([data-bare]) .gui-wrap { display: none !important; }+ :host([data-bare]) .gui-toggle { display: none !important; }+ :host([data-bare]) .axes { display: none !important; }/* Kiosk mode: hide dat.GUI debug controls entirely */:host([kiosk]) .gui-wrap { display: none !important; }:host([kiosk]) .gui-toggle { display: none !important; }@@ -654,6 +660,7 @@ class Agent3DElement extends HTMLElement {'tracked-mint','avatar-chat','avatar-walk',+ 'chat',];}@@ -722,6 +729,54 @@ class Agent3DElement extends HTMLElement {);}+ // Chrome policy — the single source of truth for "is this a full chat agent+ // or just a bare avatar?". Default is BARE: a plain <agent-3d> (or one given+ // only a `body`/`src`) ships the transparent 3D avatar and nothing else — no+ // chat, no input, no debug GUI, no name-plate.+ //+ // The conversational chrome is opt-in, switched on by either:+ // • the explicit `chat` attribute — the documented opt-in field, or+ // • binding to a published agent identity (`agent-id` / `manifest`), which+ // inherently carries a brain + persona, so it talks by default.+ //+ // `kiosk` / `viewer` remain explicit "force bare" escapes that win over the+ // agent-binding heuristic, for embeds that want a bound agent rendered as+ // pure decoration.+ _isChatMode() {+ if (this.hasAttribute('chat')) return true;+ if (this.hasAttribute('kiosk') || this.hasAttribute('viewer')) return false;+ return this.hasAttribute('agent-id') || this.hasAttribute('manifest');+ }++ // Reflect the resolved chrome mode onto the host as a read-only `data-bare`+ // marker. CSS keys the debug-GUI/axes hiding off it, so the default bare+ // avatar shows no controls even though it carries no `kiosk`/`viewer` attr.+ _reflectChromeState() {+ this.toggleAttribute('data-bare', !this._isChatMode());+ }++ // Tear down and rebuild the entire shadow shell, then reboot. Used when the+ // chat↔bare mode flips at runtime, since the two modes render different+ // chrome and _renderShell is otherwise idempotent.+ _rebuildShell() {+ this._teardown();+ this.shadowRoot.replaceChildren();+ // Null cached element refs so _renderShell recreates them from scratch.+ this._loadingEl = null;+ this._stageEl = null;+ this._posterEl = null;+ this._nameplateEl = null;+ this._chatEl = null;+ this._inputEl = null;+ this._micEl = null;+ this._avatarAnchorEl = null;+ this._thoughtBubbleEl = null;+ this._thoughtTextEl = null;+ this._renderShell();+ this._applyLayout();+ if (this._hasSource()) this._boot();+ }+disconnectedCallback() {this._teardown();}@@ -754,14 +809,31 @@ class Agent3DElement extends HTMLElement {if (name === 'avatar-walk' && newVal === 'off') {this._stopWalkAnimation();}+ // Toggling `chat` at runtime flips the whole chrome — rebuild the shell.+ if (name === 'chat') {+ this._rebuildShell();+ return;+ }if (['src', 'manifest', 'body', 'agent-id', 'avatar-id'].includes(name)) {- // Source change — reboot- this._teardown();- this._boot();+ // Source change — reboot. If the change also crosses the chat↔bare+ // boundary (e.g. an `agent-id`/`manifest` was added or removed), the+ // shell builds different chrome, so do a full rebuild instead.+ const wantsChat = this._isChatMode();+ const hasChrome = !!this._chatEl;+ if (wantsChat !== hasChrome) {+ this._rebuildShell();+ } else {+ this._teardown();+ this._boot();+ }}}_renderShell() {+ // Reflect the resolved chrome mode onto the host so CSS can hide the+ // debug GUI / axes for bare avatars (the default). Runs before the+ // idempotency guard so a runtime mode flip always re-reflects.+ this._reflectChromeState();if (this._loadingEl) return;const style = document.createElement('style');style.textContent = BASE_STYLE;@@ -824,8 +896,10 @@ class Agent3DElement extends HTMLElement {this.shadowRoot.appendChild(pillDrag);this._pillDrag = pillDrag;- // Chat + input chrome (omitted in kiosk mode)- if (!this.hasAttribute('kiosk')) {+ // Chat + input chrome — built only in chat mode. A bare avatar (the+ // default) never builds it, so there is no chat box, input row, mic, or+ // thought bubble: just the transparent 3D canvas.+ if (this._isChatMode()) {const chrome = document.createElement('div');chrome.className = 'chrome';chrome.part = 'chrome';@@ -1448,16 +1522,20 @@ class Agent3DElement extends HTMLElement {this.dispatchEvent(new CustomEvent('agent:load-progress', { detail: { phase: 'body', pct: 0.45 } }),);+ // Bare avatars run the viewer in kiosk mode: GUI closed, camera snapped+ // (no fly-in), and a lower DPR cap — the right profile for a lightweight+ // decoration avatar. Chat agents get the full interactive viewer.const viewer = new Viewer(this._stageEl, {- kiosk: this.hasAttribute('kiosk'),+ kiosk: !this._isChatMode(),});this._viewer = viewer;viewer._afterAnimateHooks = viewer._afterAnimateHooks || [];viewer._afterAnimateHooks.push(() => this._updateBubblePosition());// Apply the embed surface attributes (`background`, `name-plate`) now// that the viewer exists. They are also re-applied on attribute change.+ // A bare avatar carries no name-plate unless the embedder asks for one.this._applyBackground();- this._setNamePlateText(manifest.name || '');+ this._setNamePlateText(this._isChatMode() ? manifest.name || '' : '');this._applyNamePlate();// Fetch animation defs before viewer.load so _setupAnimationPanel// can preload idle+walk during the model load.@@ -1867,8 +1945,9 @@ class Agent3DElement extends HTMLElement {this._loadingEl.hidden = true;// Resolve errors should already have been caught and replaced with the// default-avatar manifest in _resolveManifest. Anything reaching here is- // a deeper boot failure — surface it (unless we're a tiny kiosk tile).- if (!this.hasAttribute('kiosk')) this._showError(err);+ // a deeper boot failure — surface it in chat mode; a bare decoration+ // avatar stays silent (no error card) and just emits the event.+ if (this._isChatMode()) this._showError(err);this.dispatchEvent(new CustomEvent('agent:error', {detail: { phase: 'boot', error: err },@@ -2410,7 +2489,9 @@ class Agent3DElement extends HTMLElement {}_showError(err) {- if (this.hasAttribute('kiosk')) return;+ // Bare avatars never paint an error card — they degrade silently to keep+ // the decoration clean. Only chat agents surface a visible error.+ if (!this._isChatMode()) return;const raw = (err && (err.message || String(err))) || '';const isWebgl = /webgl|context/i.test(raw);const title = isWebgl ? '3D preview unavailable' : "Couldn't load agent";@@ -2440,7 +2521,9 @@ class Agent3DElement extends HTMLElement {_fail(code, message) {this._loadingEl.hidden = true;- if (this.hasAttribute('kiosk')) {+ // Bare avatars report policy failures through the event only, with no+ // visible error banner. Chat agents also render a banner below.+ if (!this._isChatMode()) {this.dispatchEvent(new CustomEvent('agent:error', {detail: { phase: 'policy', error: { code, message } },