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: add width and height inputs for embed snippet customization; enhance iframe handling in preview mode
nirholas70d523723784
diff --git a/home.css b/home.cssindex 04f7e3acd..a36ba0d5f 100644--- a/home.css+++ b/home.css@@ -88,26 +88,6 @@box-shadow: 0 0 12px rgba(255, 143, 77, 0.6);}-/* ── Mini bot in header ──────────────────────────────────────────────────── */--.h-header-bot {- position: absolute;- left: 50%;- transform: translateX(-50%);- bottom: -18px;- width: 72px;- height: 88px;- pointer-events: none;- z-index: 201;- filter: grayscale(0.6) drop-shadow(0 0 10px rgba(255, 215, 106, 0.2));-}--.h-header-bot model-viewer {- width: 100%;- height: 100%;- background: transparent;- --poster-color: transparent;-}/* ── Loading flash on page reveal ────────────────────────────────────────── */diff --git a/home.html b/home.htmlindex 2be4c6c3a..9b26b9707 100644--- a/home.html+++ b/home.html@@ -57,24 +57,7 @@><span class="wordmark-dot" aria-hidden="true"></span>three.ws</a></h1>- <div class="h-header-bot" aria-hidden="true">- <model-viewer- src="/animations/robotexpressive.glb"- auto-rotate- auto-rotate-delay="0"- rotation-per-second="15deg"- interaction-prompt="none"- camera-controls="false"- disable-zoom- shadow-intensity="0"- exposure="0.8"- environment-image="neutral"- camera-orbit="0deg 78deg 4.5m"- field-of-view="42deg"- loading="lazy"- ></model-viewer>- </div>- <nav class="home-nav" aria-label="Primary">+<nav class="home-nav" aria-label="Primary"><a href="/app">Viewer</a><a href="/discover">Discover</a><a href="/features">Features</a>diff --git a/public/features/features.css b/public/features/features.cssindex 0a1fa5505..c4bfb373c 100644--- a/public/features/features.css+++ b/public/features/features.css@@ -47,6 +47,12 @@-webkit-backdrop-filter: blur(8px);}+.features-parallax-page .wordmark-logo {+ height: 1.75rem;+ width: auto;+ display: block;+}+/* ── The scroll container — establishes perspective ─────────────────────── */.parallax {diff --git a/public/features/index.html b/public/features/index.htmlindex 55ba38f00..9d0b5168d 100644--- a/public/features/index.html+++ b/public/features/index.html@@ -38,7 +38,7 @@<header><h1>- <a href="/"><span class="wordmark-dot" aria-hidden="true"></span>three.ws</a>+ <a href="/"><img src="/three.svg" alt="three.ws" class="wordmark-logo" /></a></h1><nav class="features-nav" aria-label="Primary"><a href="/app">Viewer</a>diff --git a/public/studio/index.html b/public/studio/index.htmlindex 43083c4a2..a61e4818c 100644--- a/public/studio/index.html+++ b/public/studio/index.html@@ -218,6 +218,17 @@</div></label>+ <div style="display:flex;gap:12px">+ <label class="field">+ <span>Width (px)</span>+ <input type="number" id="embed-width" value="600" min="100" max="3000" step="10" />+ </label>+ <label class="field">+ <span>Height (px)</span>+ <input type="number" id="embed-height" value="600" min="100" max="3000" step="10" />+ </label>+ </div>+<label class="field"><span>iframe snippet</span><div class="copy-row">diff --git a/public/studio/studio.js b/public/studio/studio.jsindex b2829c4da..c30f07acc 100644--- a/public/studio/studio.js+++ b/public/studio/studio.js@@ -143,6 +143,9 @@ if (preModel) state.preselectedModel = preModel;else if (state.preselectedModel) selectByModelUrl(state.preselectedModel);else if (!state.avatarId) selectAvatar(DEMO_AVATAR.id);+ // Re-send config after every iframe navigation so brand settings apply on load.+ previewIfr.addEventListener('load', postConfigToPreview);+updatePreview(true);})();@@ -433,6 +436,9 @@ function wireButtons() {for (const btn of document.querySelectorAll('[data-copy]')) {btn.addEventListener('click', () => copyFromSelector(btn.dataset.copy, btn));}++ $('#embed-width').addEventListener('input', _refreshEmbedSnippet);+ $('#embed-height').addEventListener('input', _refreshEmbedSnippet);}// ── preview ──────────────────────────────────────────────────────────────────@@ -467,7 +473,7 @@ function updatePreview(forceReload) {state.config.envPreset && state.config.envPreset !== 'none'? `&preset=${encodeURIComponent(state.config.envPreset)}`: '';- const src = `/app#model=${encodeURIComponent(modelUrl)}&kiosk=true${camStr}${presetStr}`;+ const src = `/app#model=${encodeURIComponent(modelUrl)}&kiosk=true&type=${encodeURIComponent(state.type)}${camStr}${presetStr}`;const key = src;if (forceReload || key !== previewSrcKey) {previewSrcKey = key;@@ -557,16 +563,24 @@ async function save({ generate }) {}}+let _currentEmbedUrl = '';++function _refreshEmbedSnippet() {+ if (!_currentEmbedUrl) return;+ const w = parseInt($('#embed-width').value) || 600;+ const h = parseInt($('#embed-height').value) || 600;+ $('#embed-iframe-snippet').value = `<iframe src="${_currentEmbedUrl}" width="${w}" height="${h}" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" loading="lazy"></iframe>`;+}+function openEmbedModal(widget) {const origin = location.origin;const shareUrl = `${origin}/w/${widget.id}`;- const embedUrl = `${origin}/app#widget=${widget.id}&kiosk=true`;+ _currentEmbedUrl = `${origin}/app#widget=${widget.id}&kiosk=true`;$('#embed-share-url').value = shareUrl;- $('#embed-iframe-snippet').value =- `<iframe src="${embedUrl}" width="600" height="600" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking" loading="lazy"></iframe>`;+ _refreshEmbedSnippet();$('#embed-script-snippet').value =`<script async src="${origin}/embed.js" data-widget="${widget.id}"></` + 'script>';- $('#embed-preview-iframe').src = embedUrl;+ $('#embed-preview-iframe').src = _currentEmbedUrl;$('#embed-modal').hidden = false;}diff --git a/src/app.js b/src/app.jsindex 63a159b1a..b0a9e969d 100644--- a/src/app.js+++ b/src/app.js@@ -130,6 +130,7 @@ class App {this.options = {kiosk: Boolean(hash.kiosk) || !!(onchain && onchain.embed),model: hash.model || '',+ type: hash.type || '',preset: hash.preset || '',cameraPosition: hash.cameraPosition ? hash.cameraPosition.split(',').map(Number) : null,brain: hash.brain || 'none',@@ -149,6 +150,7 @@ class App {this.el = el;this.viewer = null;this.editor = null;+ this._previewMounted = false;this.viewerEl = null;this.spinnerEl = el.querySelector('.spinner');this.dropEl = el.querySelector('.wrap');@@ -929,6 +931,16 @@ class App {if (!this.viewer) return;try {if (cfg.background) this.viewer.setBackgroundColor(cfg.background);+ if (cfg.accent) {+ document.documentElement.style.setProperty('--accent', cfg.accent);+ const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(cfg.accent);+ if (m) {+ document.documentElement.style.setProperty(+ '--accent-soft',+ `rgba(${parseInt(m[1], 16)},${parseInt(m[2], 16)},${parseInt(m[3], 16)},0.18)`,+ );+ }+ }if (typeof cfg.autoRotate === 'boolean' && this.viewer.controls) {this.viewer.controls.autoRotate = cfg.autoRotate;if (typeof cfg.rotationSpeed === 'number') {@@ -976,6 +988,11 @@ class App {if (typeof data.config.caption === 'string') {this._renderWidgetCaption(data.config.caption);}+ // Preview mode (#model= + type=): mount widget runtime on first config message.+ if (this.options.type && !this._previewMounted) {+ this._previewMounted = true;+ this._mountWidgetByType(this.options.type, data.config, null).catch(() => {});+ }return;}diff --git a/src/widgets/talking-agent.js b/src/widgets/talking-agent.jsindex a1cb8cbaf..42c807ef5 100644--- a/src/widgets/talking-agent.js+++ b/src/widgets/talking-agent.js@@ -30,7 +30,7 @@ import { ACTION_TYPES } from '../agent-protocol.js';*/export async function mountTalkingAgent(viewer, config, container, ctx) {const { widgetId, getSceneCtrl, protocol = null, identity = null } = ctx || {};- if (!widgetId) throw new Error('mountTalkingAgent: widgetId required');+ const isPreview = !widgetId;const history = [];let destroyed = false;@@ -46,6 +46,9 @@ export async function mountTalkingAgent(viewer, config, container, ctx) {voiceOutput: config.voiceOutput !== false,skipDefaultListeners: true,onSend: async (text) => {+ if (isPreview) {+ return { reply: 'Preview mode — save your widget to enable live chat.' };+ }try {const result = await dispatchChat(widgetId, text, history.slice(-20));if (result.reply) {