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.

Screenshot share on IRL + XR; post-create next-steps page; preserveDrawingBuffer

nirholas1d40f41e1be5
diff --git a/pages/create-next.html b/pages/create-next.html
new file mode 100644
index 000000000..fcd437efb
--- /dev/null
+++ b/pages/create-next.html
@@ -0,0 +1,379 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <script>/* three.ws theme boot — no-flash */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
+ <title>Your avatar is ready · three.ws</title>
+ <meta name="robots" content="noindex" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>
+ <style>
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+
+ html, body {
+ height: 100%;
+ background: #050508;
+ color: #e5e7eb;
+ font-family: Inter, system-ui, sans-serif;
+ }
+
+ /* ── layout ── */
+ .cn-shell {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ min-height: 100vh;
+ }
+
+ /* ── left: avatar panel ── */
+ .cn-left {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 40px 32px;
+ position: relative;
+ background: radial-gradient(ellipse 80% 60% at 50% 60%, rgba(99,102,241,.1) 0%, transparent 70%);
+ border-right: 1px solid rgba(255,255,255,.06);
+ }
+
+ .cn-avatar-wrap {
+ position: relative;
+ width: clamp(200px, 40vw, 320px);
+ height: clamp(200px, 40vw, 320px);
+ opacity: 0; transform: scale(.92);
+ transition: opacity .8s ease-out, transform .8s ease-out;
+ }
+ .cn-avatar-wrap.show { opacity: 1; transform: none; }
+
+ .cn-avatar-glow {
+ position: absolute; inset: -24px;
+ border-radius: 50%;
+ background: radial-gradient(circle at center, rgba(99,102,241,.22) 0%, transparent 70%);
+ animation: glow-pulse 3s ease-in-out infinite;
+ opacity: 0; transition: opacity .6s ease-out;
+ }
+ .cn-avatar-glow.show { opacity: 1; }
+
+ model-viewer.cn-mv, .cn-initial {
+ width: 100%; height: 100%;
+ border-radius: 50%;
+ --progress-bar-color: transparent;
+ }
+ .cn-initial {
+ display: flex; align-items: center; justify-content: center;
+ background: linear-gradient(135deg, #312e81, #4f46e5);
+ font-size: 4rem; font-weight: 800;
+ color: rgba(255,255,255,.9);
+ }
+
+ .cn-avatar-label {
+ margin-top: 20px;
+ font-size: 1.1rem; font-weight: 700; color: #f9fafb;
+ letter-spacing: -.01em; text-align: center;
+ opacity: 0; transition: opacity .6s ease-out;
+ }
+ .cn-avatar-label.show { opacity: 1; }
+
+ .cn-avatar-tag {
+ margin-top: 8px;
+ font-size: 11px; font-weight: 600; letter-spacing: .1em;
+ text-transform: uppercase; color: #a5b4fc;
+ opacity: 0; transition: opacity .6s ease-out;
+ }
+ .cn-avatar-tag.show { opacity: 1; }
+
+ .cn-back {
+ position: absolute; bottom: 24px;
+ font-size: 12px; color: #6b7280;
+ text-decoration: none;
+ transition: color .15s;
+ }
+ .cn-back:hover { color: #9ca3af; }
+
+ /* ── right: next steps ── */
+ .cn-right {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ padding: 48px 40px;
+ gap: 0;
+ }
+
+ .cn-header {
+ opacity: 0; transform: translateY(10px);
+ transition: opacity .6s ease-out, transform .6s ease-out;
+ }
+ .cn-header.show { opacity: 1; transform: none; }
+
+ .cn-kicker {
+ font-size: 11px; font-weight: 700;
+ letter-spacing: .14em; text-transform: uppercase;
+ color: #6366f1; margin-bottom: 8px;
+ }
+
+ .cn-headline {
+ font-size: clamp(1.4rem, 2.5vw, 2rem);
+ font-weight: 800; line-height: 1.15;
+ color: #f9fafb;
+ }
+
+ .cn-steps {
+ margin-top: 32px;
+ display: flex; flex-direction: column; gap: 0;
+ }
+
+ .cn-step {
+ display: flex; gap: 18px;
+ padding: 20px 24px;
+ border-radius: 14px;
+ border: 1px solid rgba(255,255,255,.07);
+ background: rgba(255,255,255,.03);
+ cursor: pointer;
+ transition: border-color .2s, background .2s, transform .15s;
+ text-decoration: none; color: inherit;
+ opacity: 0; transform: translateX(14px);
+ position: relative;
+ margin-bottom: 10px;
+ }
+ .cn-step:last-child { margin-bottom: 0; }
+ .cn-step.show { opacity: 1; transform: none; }
+ .cn-step:hover {
+ border-color: rgba(99,102,241,.5);
+ background: rgba(99,102,241,.07);
+ transform: translateX(3px);
+ }
+ .cn-step.primary {
+ border-color: rgba(99,102,241,.4);
+ background: rgba(99,102,241,.1);
+ }
+ .cn-step.primary:hover {
+ border-color: rgba(99,102,241,.7);
+ background: rgba(99,102,241,.16);
+ }
+ .cn-step.optional {
+ border-style: dashed;
+ border-color: rgba(255,255,255,.1);
+ }
+
+ .cn-step-num {
+ width: 32px; height: 32px;
+ border-radius: 50%;
+ display: flex; align-items: center; justify-content: center;
+ flex-shrink: 0;
+ font-size: 13px; font-weight: 700;
+ background: rgba(99,102,241,.15); color: #a5b4fc;
+ }
+ .cn-step.primary .cn-step-num {
+ background: rgba(99,102,241,.4); color: #e0e7ff;
+ }
+ .cn-step.optional .cn-step-num {
+ background: rgba(255,255,255,.06); color: #6b7280;
+ }
+
+ .cn-step-body { flex: 1; }
+
+ .cn-step-title {
+ font-size: 14px; font-weight: 700;
+ color: #e5e7eb;
+ display: flex; align-items: center; gap: 8px;
+ }
+ .cn-step.optional .cn-step-title { color: #9ca3af; }
+
+ .cn-opt-pill {
+ font-size: 9px; font-weight: 700; letter-spacing: .1em;
+ text-transform: uppercase; color: #4b5563;
+ border: 1px solid rgba(255,255,255,.1);
+ padding: 1px 6px; border-radius: 4px;
+ }
+
+ .cn-step-desc {
+ margin-top: 3px;
+ font-size: 12.5px; color: #6b7280; line-height: 1.5;
+ }
+ .cn-step.primary .cn-step-desc { color: #9ca3af; }
+
+ .cn-step-arrow {
+ align-self: center;
+ font-size: 16px; color: #4b5563;
+ transition: transform .15s;
+ flex-shrink: 0;
+ }
+ .cn-step:hover .cn-step-arrow { transform: translateX(3px); color: #a5b4fc; }
+ .cn-step.optional:hover .cn-step-arrow { transform: translateX(3px); color: #6b7280; }
+
+ /* ── animations ── */
+ @keyframes glow-pulse {
+ 0%,100% { opacity: .5; transform: scale(1); }
+ 50% { opacity: 1; transform: scale(1.06); }
+ }
+
+ /* ── mobile ── */
+ @media (max-width: 700px) {
+ .cn-shell {
+ grid-template-columns: 1fr;
+ grid-template-rows: auto 1fr;
+ }
+ .cn-left {
+ border-right: none;
+ border-bottom: 1px solid rgba(255,255,255,.06);
+ padding: 32px 24px 24px;
+ background: radial-gradient(ellipse 120% 100% at 50% 80%, rgba(99,102,241,.09) 0%, transparent 70%);
+ }
+ .cn-avatar-wrap {
+ width: clamp(140px, 50vw, 200px);
+ height: clamp(140px, 50vw, 200px);
+ }
+ .cn-right { padding: 28px 20px 40px; }
+ .cn-step { padding: 16px 18px; }
+ }
+ </style>
+</head>
+<body>
+ <div class="cn-shell">
+ <div class="cn-left">
+ <div class="cn-avatar-wrap" id="cnAvatarWrap">
+ <div class="cn-avatar-glow" id="cnAvatarGlow"></div>
+ <div class="cn-initial" id="cnInitial">?</div>
+ </div>
+ <div class="cn-avatar-label" id="cnAvatarLabel">Loading…</div>
+ <div class="cn-avatar-tag" id="cnAvatarTag">3D AI Agent</div>
+ <a class="cn-back" href="/dashboard/avatars">← Back to avatars</a>
+ </div>
+
+ <div class="cn-right">
+ <div class="cn-header" id="cnHeader">
+ <div class="cn-kicker">What's next?</div>
+ <h1 class="cn-headline" id="cnHeadline">Your avatar is ready.<br>Here's where it gets powerful.</h1>
+ </div>
+
+ <div class="cn-steps" id="cnSteps">
+ <a class="cn-step primary show" id="cnStep1" href="#" style="transition-delay:.05s">
+ <div class="cn-step-num">1</div>
+ <div class="cn-step-body">
+ <div class="cn-step-title" id="cnStep1Title">Give it a brain</div>
+ <div class="cn-step-desc" id="cnStep1Desc">Set its personality, system prompt, and voice. Your avatar becomes a real AI agent in minutes.</div>
+ </div>
+ <div class="cn-step-arrow">→</div>
+ </a>
+ <a class="cn-step show" id="cnStep2" href="#" style="transition-delay:.12s">
+ <div class="cn-step-num">2</div>
+ <div class="cn-step-body">
+ <div class="cn-step-title">Embed it anywhere</div>
+ <div class="cn-step-desc">Drop a live talking 3D widget on any website in 2 minutes. Copy one snippet.</div>
+ </div>
+ <div class="cn-step-arrow">→</div>
+ </a>
+ <a class="cn-step optional show" id="cnStep3" href="#" style="transition-delay:.2s">
+ <div class="cn-step-num">3</div>
+ <div class="cn-step-body">
+ <div class="cn-step-title">Deploy on-chain <span class="cn-opt-pill">Optional</span></div>
+ <div class="cn-step-desc">Mint your agent as a collectible. Make it discoverable and tradeable.</div>
+ </div>
+ <div class="cn-step-arrow">→</div>
+ </a>
+ </div>
+ </div>
+ </div>
+
+ <script type="module">
+ import { agentAvatarGlb } from '/src/shared/agent-3d.js';
+
+ const p = new URLSearchParams(location.search);
+ const avatarId = p.get('avatarId') || '';
+ const agentId = p.get('agentId') || '';
+ const fromFlow = p.get('from') || 'object';
+
+ // If this is an agent save (has agentId), step 1 goes to /app (AI chat).
+ // If avatar-only, step 1 goes to /create-agent (build an agent from the avatar).
+ const step1Href = agentId ? `/app?agent=${encodeURIComponent(agentId)}` : (avatarId ? `/create-agent?avatar=${encodeURIComponent(avatarId)}` : '/create-agent');
+ const step1Label = agentId ? 'Chat with your agent' : 'Give it a brain';
+ const step1Desc = agentId
+ ? 'Talk to your agent, customize its personality, and set a system prompt.'
+ : 'Set its personality, system prompt, and voice. Your avatar becomes a real AI agent in minutes.';
+ const step2Href = avatarId ? `/embed.html?avatar=${encodeURIComponent(avatarId)}` : '/embed.html';
+ const step3Href = agentId ? `/deploy?agent=${encodeURIComponent(agentId)}` : (avatarId ? `/create-agent?avatar=${encodeURIComponent(avatarId)}&then=deploy` : '/launchpad');
+ const headline = agentId ? 'Your agent is ready.<br>Here\'s where it gets powerful.' : 'Your avatar is ready.<br>Here\'s where it gets powerful.';
+ const backHref = agentId ? `/app?agent=${encodeURIComponent(agentId)}` : '/dashboard/avatars';
+ const avatarTag = agentId ? '3D AI Agent' : '3D Avatar';
+
+ // Wire static links that don't need data
+ document.getElementById('cnStep1').href = step1Href;
+ document.getElementById('cnStep1Title').textContent = step1Label;
+ document.getElementById('cnStep1Desc').textContent = step1Desc;
+ document.getElementById('cnStep2').href = step2Href;
+ document.getElementById('cnStep3').href = step3Href;
+ document.getElementById('cnHeadline').innerHTML = headline;
+ document.querySelector('.cn-back').href = backHref;
+ document.getElementById('cnAvatarTag').textContent = avatarTag;
+
+ // Stagger reveals
+ function after(ms, fn) { setTimeout(fn, ms); }
+ after(0, () => document.getElementById('cnHeader').classList.add('show'));
+ after(80, () => document.getElementById('cnAvatarWrap').classList.add('show'));
+ after(500, () => document.getElementById('cnAvatarGlow').classList.add('show'));
+ after(600, () => document.getElementById('cnAvatarLabel').classList.add('show'));
+ after(700, () => document.getElementById('cnAvatarTag').classList.add('show'));
+ // Step cards already have show class, transition-delay handles stagger
+
+ async function loadData() {
+ let name = '';
+ let glbUrl = null;
+
+ if (agentId) {
+ try {
+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}`, { credentials: 'include' });
+ if (r.ok) {
+ const agent = await r.json();
+ name = agent.name || '';
+ glbUrl = agentAvatarGlb(agent);
+ }
+ } catch { /* non-fatal */ }
+ } else if (avatarId) {
+ try {
+ const r = await fetch(`/api/avatars/${encodeURIComponent(avatarId)}`, { credentials: 'include' });
+ if (r.ok) {
+ const avatar = await r.json();
+ name = avatar.name || '';
+ glbUrl = avatar.model_url || avatar.glb_url;
+ }
+ } catch { /* non-fatal */ }
+ }
+
+ // Try URL-param name as fallback
+ if (!name) name = p.get('name') || (agentId ? 'Your agent' : 'Your avatar');
+
+ document.getElementById('cnAvatarLabel').textContent = name;
+ document.getElementById('cnInitial').textContent = (name[0] || 'A').toUpperCase();
+ document.title = `${name} · three.ws`;
+
+ if (glbUrl) {
+ const wrap = document.getElementById('cnAvatarWrap');
+ const ph = document.getElementById('cnInitial');
+
+ const mv = document.createElement('model-viewer');
+ mv.className = 'cn-mv';
+ mv.setAttribute('src', glbUrl);
+ mv.setAttribute('auto-rotate', '');
+ mv.setAttribute('auto-rotate-delay', '0');
+ mv.setAttribute('rotation-per-second', '20deg');
+ mv.setAttribute('camera-controls', '');
+ mv.setAttribute('interaction-prompt', 'none');
+ mv.setAttribute('environment-image', 'neutral');
+ mv.setAttribute('exposure', '0.9');
+ mv.setAttribute('shadow-intensity', '0.3');
+ mv.setAttribute('loading', 'eager');
+ mv.setAttribute('reveal', 'auto');
+ mv.setAttribute('style', 'width:100%;height:100%;background:transparent;border-radius:50%');
+ mv.setAttribute('alt', `${name} 3D avatar`);
+
+ mv.addEventListener('load', () => { ph.style.display = 'none'; });
+ wrap.appendChild(mv);
+ }
+ }
+
+ loadData();
+ </script>
+</body>
+</html>
diff --git a/pages/irl.html b/pages/irl.html
index 6c42618a0..64ff627f5 100644
--- a/pages/irl.html
+++ b/pages/irl.html
@@ -884,17 +884,64 @@
<script>
document.getElementById('irl-share-btn').addEventListener('click', async () => {
+ const btn = document.getElementById('irl-share-btn');
+ const origText = btn.textContent;
+
+ // Capture the current frame from the Three.js canvas (+ camera feed if in AR)
+ async function captureFrame() {
+ const irl = document.getElementById('irl-canvas');
+ if (!irl) return null;
+ const w = irl.width; const h = irl.height;
+ if (!w || !h) return null;
+ const out = document.createElement('canvas');
+ out.width = w; out.height = h;
+ const ctx2 = out.getContext('2d');
+ const vid = document.getElementById('irl-camera');
+ if (document.body.classList.contains('is-ar') && vid && !vid.paused) {
+ try { ctx2.drawImage(vid, 0, 0, w, h); } catch {}
+ }
+ try { ctx2.drawImage(irl, 0, 0); } catch {}
+ return new Promise(res => out.toBlob(res, 'image/png'));
+ }
+
+ btn.disabled = true;
+ btn.textContent = '…';
+
+ try {
+ const blob = await captureFrame();
+ if (blob) {
+ const file = new File([blob], 'three-ws-irl.png', { type: 'image/png' });
+ if (navigator.share && navigator.canShare?.({ files: [file] })) {
+ await navigator.share({ title: 'IRL · three.ws', files: [file] });
+ btn.textContent = 'Shared!';
+ setTimeout(() => { btn.textContent = origText; btn.disabled = false; }, 2000);
+ return;
+ }
+ // Download on desktop
+ const objUrl = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = objUrl; a.download = 'three-ws-irl.png';
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(objUrl), 4000);
+ btn.textContent = 'Saved!';
+ setTimeout(() => { btn.textContent = origText; btn.disabled = false; }, 2000);
+ return;
+ }
+ } catch {}
+
+ // Fallback: share / copy URL
const url = location.href;
if (navigator.share) {
- try { await navigator.share({ title: 'IRL · three.ws', url }); return; } catch {}
+ try { await navigator.share({ title: 'IRL · three.ws', url }); btn.textContent = 'Shared!'; setTimeout(() => { btn.textContent = origText; btn.disabled = false; }, 2000); return; } catch {}
}
try {
await navigator.clipboard.writeText(url);
- const btn = document.getElementById('irl-share-btn');
- const orig = btn.textContent;
btn.textContent = 'Copied!';
- setTimeout(() => { btn.textContent = orig; }, 1800);
- } catch {}
+ } catch {
+ btn.textContent = origText;
+ }
+ btn.disabled = false;
+ setTimeout(() => { if (btn.textContent !== origText) { btn.textContent = origText; } }, 1800);
});
</script>
</body>
diff --git a/pages/xr.html b/pages/xr.html
index 9a7e1f4de..7f58daad6 100644
--- a/pages/xr.html
+++ b/pages/xr.html
@@ -132,6 +132,20 @@
.xr-chip--camera { background: rgba(251,191,36,0.1); color: #fbbf24; border-color: rgba(251,191,36,0.3); }
.xr-chip--none { background: rgba(255,255,255,0.04); color: var(--text-2); border-color: var(--border); }
+ /* Share button */
+ #xr-share-btn {
+ margin-left: auto;
+ display: flex; align-items: center; gap: 5px;
+ padding: 6px 12px; border-radius: 999px;
+ border: 1px solid var(--border);
+ background: rgba(255,255,255,0.05);
+ color: var(--text-2); font: inherit; font-size: 12px; font-weight: 600;
+ cursor: pointer; backdrop-filter: blur(12px);
+ transition: background 0.15s, color 0.15s, border-color 0.15s;
+ flex-shrink: 0;
+ }
+ #xr-share-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.18); background: rgba(255,255,255,0.1); }
+
/* ── Loading overlay ── */
#xr-loading {
position: fixed; inset: 0; z-index: 30;
@@ -367,6 +381,10 @@
</a>
<div class="xr-wordmark">three<span>.ws</span> XR</div>
<div id="xr-device-chip" class="xr-chip xr-chip--none">Detecting…</div>
+ <button id="xr-share-btn" type="button" aria-label="Share screenshot">
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>
+ Share
+ </button>
</div>
<!-- Floating mode badge -->
@@ -446,5 +464,60 @@
})();
</script>
<script src="/brand.js" defer></script>
+ <script>
+ document.getElementById('xr-share-btn').addEventListener('click', async () => {
+ const btn = document.getElementById('xr-share-btn');
+ const origHTML = btn.innerHTML;
+ btn.disabled = true;
+ btn.querySelector('svg') && (btn.querySelector('svg').style.display = 'none');
+ btn.lastChild.textContent = '…';
+
+ async function captureFrame() {
+ const cvs = document.getElementById('xr-canvas');
+ if (!cvs) return null;
+ const w = cvs.width; const h = cvs.height;
+ if (!w || !h) return null;
+ const out = document.createElement('canvas');
+ out.width = w; out.height = h;
+ const ctx2 = out.getContext('2d');
+ const vid = document.getElementById('xr-camera-feed');
+ if (vid && !vid.paused && vid.videoWidth) {
+ try { ctx2.drawImage(vid, 0, 0, w, h); } catch {}
+ }
+ try { ctx2.drawImage(cvs, 0, 0); } catch {}
+ return new Promise(res => out.toBlob(res, 'image/png'));
+ }
+
+ try {
+ const blob = await captureFrame();
+ if (blob) {
+ const file = new File([blob], 'three-ws-xr.png', { type: 'image/png' });
+ if (navigator.share && navigator.canShare?.({ files: [file] })) {
+ await navigator.share({ title: 'XR · three.ws', files: [file] });
+ btn.innerHTML = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg> Shared!';
+ setTimeout(() => { btn.innerHTML = origHTML; btn.disabled = false; }, 2000);
+ return;
+ }
+ const objUrl = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = objUrl; a.download = 'three-ws-xr.png'; a.click();
+ setTimeout(() => URL.revokeObjectURL(objUrl), 4000);
+ btn.innerHTML = '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg> Saved!';
+ setTimeout(() => { btn.innerHTML = origHTML; btn.disabled = false; }, 2000);
+ return;
+ }
+ } catch {}
+
+ // Fallback: share URL
+ const url = location.href;
+ if (navigator.share) {
+ try { await navigator.share({ title: 'XR · three.ws', url }); } catch {}
+ } else {
+ try { await navigator.clipboard.writeText(url); } catch {}
+ }
+ btn.innerHTML = origHTML;
+ btn.disabled = false;
+ });
+ </script>
</body>
</html>
diff --git a/src/create-review.js b/src/create-review.js
index c861e0f57..76a87c044 100644
--- a/src/create-review.js
+++ b/src/create-review.js
@@ -421,7 +421,7 @@ async function onSave({ auto = false } = {}) {
await captureAndUploadThumbnail(avatar.id).catch(() => {});
releaseObjectUrl();
try { window.__twsGuide?.complete('create'); } catch (_) {}
- window.location.href = '/dashboard/avatars?saved=1';
+ window.location.href = `/create/next?avatarId=${encodeURIComponent(avatar.id)}&name=${encodeURIComponent(name)}&from=object`;
return;
}
@@ -446,7 +446,7 @@ async function onSave({ auto = false } = {}) {
// Mark the "create your first avatar" step of the getting-started guide
// done at the true completion point, before we navigate away.
try { window.__twsGuide?.complete('create'); } catch (_) {}
- window.location.href = '/app?agent=' + agent.id;
+ window.location.href = `/create/next?agentId=${encodeURIComponent(agent.id)}&avatarId=${encodeURIComponent(avatar.id)}&name=${encodeURIComponent(name)}&from=agent`;
} catch (err) {
log.error('[create-review] save failed', err);
setSaveCancellable(false);
diff --git a/src/irl.js b/src/irl.js
index c0962a7aa..39e672d6b 100644
--- a/src/irl.js
+++ b/src/irl.js
@@ -100,7 +100,7 @@ function setStatus(msg, { error = false, loading = false, sticky = false } = {})
}
// ── Renderer / scene ──────────────────────────────────────────────────────
-const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true });
+const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true, preserveDrawingBuffer: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.setClearColor(0x000000, 0);
@@ -283,7 +283,43 @@ if (!navigator.mediaDevices?.getUserMedia) {
// ── Placed objects ────────────────────────────────────────────────────────
let placeModeActive = false;
let selectedType = 'orb';
-const placedObjects = []; // { mesh, spawnT }
+const placedObjects = []; // { mesh, spawnT, type }
+
+// ── Session persistence (localStorage) ───────────────────────────────────
+const SESSION_KEY = 'irl_session_v1';
+
+function _saveSession() {
+ try {
+ localStorage.setItem(SESSION_KEY, JSON.stringify({
+ avatarId: _currentAvatarId,
+ locked: avatarLocked,
+ placedObjects: placedObjects.map(o => ({
+ type: o.type,
+ x: o.mesh.position.x,
+ z: o.mesh.position.z,
+ })),
+ }));
+ } catch {}
+}
+
+function _restoreSession() {
+ try {
+ const raw = localStorage.getItem(SESSION_KEY);
+ if (!raw) return;
+ const s = JSON.parse(raw);
+ for (const o of (s.placedObjects ?? [])) {
+ const def = OBJ_DEFS[o.type];
+ if (!def) continue;
+ const mesh = def.create();
+ mesh.position.x = Number(o.x) || 0;
+ mesh.position.z = Number(o.z) || 0;
+ mesh.scale.setScalar(1);
+ scene.add(mesh);
+ placedObjects.push({ mesh, spawnT: SPAWN_DURATION, type: o.type });
+ }
+ if (placedObjects.length) clearBtn.hidden = false;
+ } catch {}
+}
const OBJ_DEFS = {
orb: {
@@ -389,6 +425,7 @@ clearBtn.addEventListener('click', () => {
placedObjects.length = 0;
clearBtn.hidden = true;
setStatus('Objects cleared');
+ _saveSession();
});
// ── Tap-to-place raycasting ───────────────────────────────────────────────
@@ -416,8 +453,9 @@ canvas.addEventListener('pointerup', e => {
mesh.position.z = hits[0].point.z;
mesh.scale.setScalar(0.001);
scene.add(mesh);
- placedObjects.push({ mesh, spawnT: 0 });
+ placedObjects.push({ mesh, spawnT: 0, type: selectedType });
clearBtn.hidden = false;
+ _saveSession();
});
// ── Joystick ──────────────────────────────────────────────────────────────
@@ -500,6 +538,8 @@ function _clearAvatar() {
async function loadAvatar(idOrUrl, nameOverride) {
// Resolve id/url — accepts: null (default), a UUID (look up), a direct URL
const id = idOrUrl !== undefined ? idOrUrl : avatarIdParam;
+ // Track the active avatar for session persistence
+ if (id && !/^https?:\/\//.test(id) && !id.startsWith('/')) _currentAvatarId = id;
let avatarName = nameOverride || 'Your Avatar';
let glbUrl = resolveAvatarUrl(typeof idOrUrl === 'string' && /^https?:\/\/|^\//.test(idOrUrl) ? idOrUrl : id);
@@ -558,6 +598,7 @@ async function loadAvatar(idOrUrl, nameOverride) {
cameraBtn.disabled = false;
cameraBtn.removeAttribute('aria-busy');
setStatus(null);
+ _saveSession();
}
// ── Avatar picker ─────────────────────────────────────────────────────────
@@ -688,6 +729,7 @@ async function setLocked(next) {
setStatus(next
? (arActive ? `Pinned in real space${gpsNote} — move phone to look around` : 'Agent pinned — drag to orbit')
: 'Agent unpinned');
+ _saveSession();
}
if (lockBtn) {
@@ -1274,7 +1316,10 @@ fetch('/api/irl/pins?mine=1', { credentials: 'include' })
.catch(() => {});
loadAvatar()
- .then(() => requestAnimationFrame(tick))
+ .then(() => {
+ _restoreSession();
+ requestAnimationFrame(tick);
+ })
.catch(err => {
log.error('[irl] avatar load failed:', err);
nameEl.textContent = 'Avatar';
diff --git a/src/xr.js b/src/xr.js
index 5ce9e1083..fd8192905 100644
--- a/src/xr.js
+++ b/src/xr.js
@@ -54,7 +54,7 @@ function setStatus(msg, type = 'idle') {
// ── Three.js setup ───────────────────────────────────────────────────────────
-const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true });
+const renderer = new WebGLRenderer({ canvas, antialias: true, alpha: true, preserveDrawingBuffer: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.shadowMap.enabled = true;
diff --git a/vercel.json b/vercel.json
index db3f500b3..e30fe11c8 100644
--- a/vercel.json
+++ b/vercel.json
@@ -593,6 +593,10 @@
"src": "/mint-success/?",
"dest": "/mint-success.html"
},
+ {
+ "src": "/create/next/?",
+ "dest": "/create-next.html"
+ },
{
"src": "/trades/?",
"dest": "/trades.html"