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 widget demo page with styling and usage instructions
nirholasc7d5aa1b2ce3
diff --git a/public/vanity-wallet.html b/public/vanity-wallet.htmlindex d4c9651ac..42cde8632 100644--- a/public/vanity-wallet.html+++ b/public/vanity-wallet.html@@ -311,7 +311,17 @@<svg viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" d="M2 8h11m0 0L9 4m4 4l-4 4"/></svg></button></form>- <p class="h-footer-newsletter-msg" data-newsletter-msg aria-live="polite"></p>+ <p class="h-footer-newsletter-msg" data-newsletter-msg aria-live="polite"></p>+ </div>+ <div class="h-footer-resources">+ <h3>Resources</h3>+ <p>Read the docs, join the community, and get help.</p>+ <a class="h-footer-community-btn" href="/docs" target="_blank" rel="noopener">+ <svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>+ Docs+ </a>+ </div>+ </div></div><div class="h-footer-community"><h3>Join the community</h3>diff --git a/public/widget-demo.html b/public/widget-demo.htmlnew file mode 100644index 000000000..8b9cf0098--- /dev/null+++ b/public/widget-demo.html@@ -0,0 +1,56 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>3D Agent Widget Demo</title>+ <style>+ body {+ font-family: sans-serif;+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 2rem;+ background-color: #f0f0f0;+ }+ .widget-container {+ width: 400px;+ height: 500px;+ border: 1px solid #ccc;+ border-radius: 8px;+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);+ overflow: hidden; /* Ensures the iframe stays within the rounded corners */+ }+ textarea {+ width: 500px;+ height: 150px;+ padding: 10px;+ border: 1px solid #ccc;+ border-radius: 4px;+ font-family: monospace;+ font-size: 14px;+ resize: vertical;+ }+ </style>+</head>+<body>++ <h1>3D Agent Widget Demo</h1>++ <p>Here is a demo of an embedded 3D agent:</p>++ <div class="widget-container">+ <div class="threews-widget" data-agent-id="041cb44a-3c58-4d56-b083-d5234563456a"></div>+ </div>++ <h2>How to use it</h2>+ <p>Copy and paste this code into your website:</p>+ <textarea readonly>+<div class="threews-widget" data-agent-id="YOUR_AGENT_ID" style="width: 400px; height: 500px;"></div>+<script src="https://3d-agent.vercel.app/dist/widget.js" defer></script>+ </textarea>++ <script src="/dist/widget.js" defer></script>++</body>+</html>diff --git a/pumpfun-widget.html b/pumpfun-widget.htmlindex 108285bfb..ab8506ced 100644--- a/pumpfun-widget.html+++ b/pumpfun-widget.html@@ -2,9 +2,9 @@<html lang="en"><head><meta charset="utf-8" />- <title>three.ws</title>+ <title>Pump.fun Live</title><meta name="viewport" content="width=device-width, initial-scale=1.0" />- <meta name="description" content="Embedded three.ws avatar — on-chain." />+ <meta name="description" content="Pump.fun live feed widget." /><meta name="robots" content="noindex" /><style>html,@@ -138,155 +138,10 @@</style></head><body>- <div id="stage"></div>- <div id="name-plate"></div>- <div id="chain-plate"></div>- <a id="open-link" target="_blank" rel="noopener" style="display: none">Open ↗</a>- <div id="loading">Loading agent</div>- <div id="error"></div>- <div id="blocked"></div>-+ <div id="root"></div><script type="module">- import { Viewer } from './src/viewer.js';- import {- parseAgentRef,- resolveOnchainAgent,- toManifest,- resolveUrlCandidates,- isEmbedAllowed,- toPublicUrl,- } from './src/erc8004/resolver.js';-- const params = new URL(location.href).searchParams;- const bg = params.get('bg') || 'transparent';- if (bg === 'dark') document.body.classList.add('bg-dark');- if (bg === 'light') document.body.classList.add('bg-light');-- const plateOn = params.get('name') !== '0';- const chainOn = params.get('chain-plate') !== '0';- const openLinkOn = params.get('open-link') !== '0';-- // URL: /a/:chainId/:agentId/embed- const ref = parseAgentRef(location.pathname);-- // Best-effort parent origin from referrer; never use '*'.- const parentOrigin = (() => {- try {- if (window.parent === window) return location.origin;- if (document.referrer) return new URL(document.referrer).origin;- } catch {}- return null;- })();-- function postToParent(msg) {- if (!parent || parent === window) return;- if (!parentOrigin) return;- try { parent.postMessage(msg, parentOrigin); } catch {}- }-- function showError(msg) {- document.getElementById('loading').style.display = 'none';- const el = document.getElementById('error');- el.textContent = msg || 'Could not load agent';- el.style.display = 'flex';- postToParent({ __agent: true, type: 'error', message: msg });- }-- function showBlocked(host) {- document.getElementById('loading').style.display = 'none';- const el = document.getElementById('blocked');- const link = ref ? toPublicUrl(ref) : '/';- el.innerHTML = `- <div>This agent does not allow embedding on <b>${host || 'this site'}</b>.</div>- <a href="${link}" target="_blank" rel="noopener">Open on three.ws ↗</a>- `;- el.style.display = 'flex';- postToParent({ __agent: true, type: 'blocked', host });- }-- // Best-effort parent hostname — referrer is the only cross-origin signal.- function getParentHost() {- try {- if (window.parent === window) return location.hostname;- if (document.referrer) return new URL(document.referrer).hostname;- } catch {}- return '';- }-- // Try a list of candidate URLs; resolve with the first that succeeds.- async function loadWithFallback(viewer, uris) {- let lastErr;- for (const u of uris) {- try {- await viewer.load(u, '', new Map());- return u;- } catch (err) {- lastErr = err;- console.warn('[a-embed] load failed, trying next:', u, err?.message);- }- }- throw lastErr || new Error('All candidate URLs failed');- }-- async function main() {- if (!ref) return showError('Invalid agent URL');-- const resolved = await resolveOnchainAgent(ref);- if (resolved.error && !resolved.glbUrl && !resolved.image) {- return showError(`On-chain resolve failed: ${resolved.error}`);- }-- // Embed-policy gate- const parentHost = getParentHost();- const policy = resolved.metadata?.embedPolicy;- if (policy && !isEmbedAllowed(policy, parentHost)) {- return showBlocked(parentHost);- }-- if (plateOn) {- document.getElementById('name-plate').textContent = resolved.name;- }- if (chainOn) {- const chainName = resolved.chain?.name || `chain ${ref.chainId}`;- document.getElementById('chain-plate').textContent =- `${chainName} · #${ref.agentId}`;- }- if (openLinkOn) {- const ol = document.getElementById('open-link');- ol.href = toPublicUrl(ref);- ol.style.display = 'inline-block';- }-- const bodyURI = resolved.glbUrl || resolved.image;- if (!bodyURI) return showError('Agent has no 3D body');-- const stage = document.getElementById('stage');- const viewer = new Viewer(stage, { kiosk: true });- if (bg === 'transparent') {- viewer.renderer?.setClearAlpha(0);- if (viewer.scene) viewer.scene.background = null;- }-- const candidates = resolveUrlCandidates(bodyURI);- await loadWithFallback(viewer, candidates);-- document.getElementById('loading').style.display = 'none';-- postToParent({- __agent: true,- type: 'ready',- caip: resolved.caip,- chainId: ref.chainId,- agentId: ref.agentId,- name: resolved.name,- owner: resolved.onchain.owner,- });- }-- main().catch((err) => {- console.error('[a-embed]', err);- showError(err.message || 'Could not load agent');- });+ // Coming soon+ document.getElementById('root').innerHTML = '<h1>Coming soon</h1>';</script></body></html>