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(forge): every share is a real permalink with a preview card
nirholas54eed7dca160
diff --git a/src/forge.js b/src/forge.jsindex 4bf110911..87ed34795 100644--- a/src/forge.js+++ b/src/forge.js@@ -2982,10 +2982,14 @@ if (els.forgeShareBtn) {const origin = location.origin;const prompt = els.forgeShareBtn.dataset.sharePrompt || lastJob?.prompt || '';const id = currentCreationId;- const shareUrl = id ? `${origin}/forge/share/${id}` : `${origin}/forge`;const remixUrl = prompt? `${origin}/forge?prompt=${encodeURIComponent(prompt)}`: `${origin}/forge`;+ // A share is only a real, unfurlable permalink when the creation was+ // persisted server-side (has an id). Without one, share the remix link,+ // which actually rebuilds the model for whoever opens it, never a bare+ // /forge that unfurls to nothing.+ const shareUrl = id ? `${origin}/forge/share/${id}` : remixUrl;showSharePanel({kind: 'forge',@@ -2994,6 +2998,10 @@ if (els.forgeShareBtn) {description: 'A 3D model generated with text / image → 3D on three.ws',shareUrl,remixUrl,+ // Show the exact OG card the link unfurls as (forge-og 302s to the+ // real preview image, or renders an SVG card). Only meaningful with a+ // permalink; the remix-link fallback has no per-creation card.+ previewImage: id ? `${origin}/api/forge-og?id=${id}` : undefined,},els.forgeShareBtn,);diff --git a/src/home-forge.js b/src/home-forge.jsindex e300afc8b..92081d94e 100644--- a/src/home-forge.js+++ b/src/home-forge.js@@ -124,6 +124,7 @@ let lastPrompt = '';let modelViewerReady = null;let currentViewer = null; // the live <model-viewer> on stagelet currentGlbUrl = ''; // what the toolbar acts on+let currentCreationId = ''; // persisted creation id → real shareable permalinklet toastTimer = null;let embedCopyTimer = null;let embedTrigger = null; // element to restore focus to when the embed sheet closes@@ -416,9 +417,12 @@ function downloadName(prompt) {);}-function showResult(glbUrl, prompt, { fromHistory = false } = {}) {+function showResult(glbUrl, prompt, { fromHistory = false, creationId = '' } = {}) {stopElapsed();currentGlbUrl = glbUrl;+ // A fresh forge carries a persisted creation id (real OG permalink); a reload+ // from the on-device history rail does not, so it shares the remix link.+ currentCreationId = creationId || '';// Reloading from the history rail can happen before any forge this session,// so the viewer library may not be registered yet. The element upgrades// retroactively once the script lands — fire the load and let it catch up.@@ -549,7 +553,9 @@ async function run(prompt) {const viewerErr = await viewerLoad;if (viewerErr instanceof Error) throw viewerErr;- showResult(done.glb_url, prompt);+ // The initial POST always carries the persisted creation id; the async+ // poll result may not, so prefer the job's id and fall back to done's.+ showResult(done.glb_url, prompt, { creationId: job.creation_id || done.creation_id || '' });} catch (err) {if (!pollAbort && seq === runSeq) {showError(err.message || 'Something went wrong. Try a simpler prompt.');@@ -565,6 +571,7 @@ function reset() {setBusy(false);closeEmbed();currentGlbUrl = '';+ currentCreationId = '';currentViewer = null;markActiveThumb();showState('idle');@@ -650,13 +657,21 @@ function autoGrow() {async function copyShareLink() {if (!currentGlbUrl) return;- // Share the idea, not just the file: a remix link auto-builds this prompt- // for whoever opens it. (The "Open in Scene" action still links the exact- // finished model.)- const url = new URL(remixLinkFor(lastPrompt), location.origin).href;+ // A freshly forged model has a persisted creation id, so share its real+ // permalink: /forge/share/:id unfurls with an OG card (api/forge-share.js)+ // and opens the actual model, not just its prompt. Only a reload from the+ // on-device history rail lacks an id, so there we share the remix link, which+ // rebuilds the prompt for whoever opens it. Either way the copied link is a+ // real, working destination, never a dead file URL.+ const sharesModel = Boolean(currentCreationId);+ const path = sharesModel ? `/forge/share/${currentCreationId}` : remixLinkFor(lastPrompt);+ const url = new URL(path, location.origin).href;+ const okMsg = sharesModel+ ? 'Link copied. Opens your model with a preview card'+ : 'Remix link copied. Whoever opens it builds their own';try {await navigator.clipboard.writeText(url);- showToast('Remix link copied — whoever opens it builds their own');+ showToast(okMsg);} catch {// Clipboard blocked (permissions / insecure context) — fall back to a// transient selectable field the user can copy manually.