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.

feat(studio): include AR launch URL in shapeSubmit and shapePoll responses

nirholase417a55e2e1b
diff --git a/api/3d/studio.js b/api/3d/studio.js
index 8edf09b0d..521f31cc6 100644
--- a/api/3d/studio.js
+++ b/api/3d/studio.js
@@ -47,10 +47,16 @@ const JOB_HANDLE_RE = /^[A-Za-z0-9._-]{8,1024}$/;
// Shape a forge submit response into the Actions contract: model URLs and job
// state only. Pure + exported so tests pin the boundary against real captured
// forge shapes without any network.
-export function shapeSubmit(job, base) {
+export function shapeSubmit(job, base, prompt) {
const glbUrl = typeof job?.glb_url === 'string' ? job.glb_url : '';
if (job?.status === 'done' && glbUrl) {
- return { status: 'done', glbUrl, viewerUrl: viewerUrl(base, glbUrl), format: 'glb' };
+ return {
+ status: 'done',
+ glbUrl,
+ viewerUrl: viewerUrl(base, glbUrl),
+ arUrl: arLaunchUrl(base, glbUrl, prompt),
+ format: 'glb',
+ };
}
const handle = job?.job_id ?? null;
return {
@@ -65,7 +71,14 @@ export function shapeSubmit(job, base) {
export function shapePoll(data, base, jobId) {
const glbUrl = typeof data?.glb_url === 'string' ? data.glb_url : '';
if (data?.status === 'done' && glbUrl) {
- return { status: 'done', job: jobId, glbUrl, viewerUrl: viewerUrl(base, glbUrl), format: 'glb' };
+ return {
+ status: 'done',
+ job: jobId,
+ glbUrl,
+ viewerUrl: viewerUrl(base, glbUrl),
+ arUrl: arLaunchUrl(base, glbUrl),
+ format: 'glb',
+ };
}
if (data?.status === 'failed') {
return {
diff --git a/api/_mcp/render.js b/api/_mcp/render.js
index dbc6109fa..f72a39518 100644
--- a/api/_mcp/render.js
+++ b/api/_mcp/render.js
@@ -41,7 +41,7 @@ export function safeHttpsUrl(s) {
}
}
-export function renderModelViewerHtml({ src, name, poster, background, height, width, autoRotate, ar, cameraOrbit }) {
+export function renderModelViewerHtml({ src, name, poster, background, height, width, autoRotate, ar, arHref, cameraOrbit }) {
const attrs = [
`src="${attr(src)}"`,
'camera-controls',
@@ -56,14 +56,27 @@ export function renderModelViewerHtml({ src, name, poster, background, height, w
]
.filter(Boolean)
.join(' ');
+ // arHref: the device-aware /api/ar launch link. model-viewer's own AR button
+ // only appears on AR-capable browsers and never inside an embedding host's
+ // sandboxed iframe, so a plain visible link is what makes "place it in your
+ // home" one tap from anywhere (ChatGPT opens it in the system browser).
+ const arLink = arHref
+ ? '<a class="ar" href="' + attr(arHref) + '" target="_blank" rel="noopener">View in your space</a>'
+ : '';
return [
'<!doctype html>',
'<html><head><meta charset="utf-8"><title>' + esc(name || 'Avatar') + '</title>',
'<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script>',
'<style>html,body{margin:0;height:100%;background:' + attr(background) + '}',
- 'model-viewer{width:' + attr(width) + ';height:' + attr(height) + ';--progress-bar-color:#6a5cff}</style>',
+ 'model-viewer{width:' + attr(width) + ';height:' + attr(height) + ';--progress-bar-color:#6a5cff}',
+ 'a.ar{position:absolute;left:50%;transform:translateX(-50%);bottom:14px;font-family:ui-sans-serif,system-ui,sans-serif;' +
+ 'font-size:13px;font-weight:700;color:#0b0c10;background:#6ea8fe;border-radius:999px;padding:9px 16px;' +
+ 'text-decoration:none;box-shadow:0 2px 10px rgba(0,0,0,.35)}',
+ 'a.ar:hover{filter:brightness(1.08)}a.ar:active{transform:translateX(-50%) translateY(1px)}',
+ 'a.ar:focus-visible{outline:2px solid #fff;outline-offset:2px}</style>',
'</head><body>',
'<model-viewer ' + attrs + '></model-viewer>',
+ arLink,
'</body></html>',
].join('\n');
}