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(ar): add AR Studio section and links for multi-model placement
nirholasa66e026e7604
diff --git a/data/pages.json b/data/pages.jsonindex 0680dbf5d..e7b78b7c8 100644--- a/data/pages.json+++ b/data/pages.json@@ -756,6 +756,15 @@"added": "2026-07-14","showcase": true},+ {+ "path": "/ar/studio",+ "title": "AR Studio",+ "description": "A live multi-model AR scene through your camera: place any number of 3D models and avatars in your real space, pull in your forge creations, community models, or any GLB link, and generate new models by prompt without leaving the view.",+ "priority": 0.7,+ "changefreq": "monthly",+ "added": "2026-07-17",+ "showcase": true+ },{"path": "/spatial-mcp","title": "Spatial MCP — reference renderer",diff --git a/public/ar-forge.html b/public/ar-forge.htmlindex 26affab0a..7ff98a188 100644--- a/public/ar-forge.html+++ b/public/ar-forge.html@@ -204,6 +204,7 @@<button class="btn primary" id="ar-btn" type="button" aria-label="View this model in augmented reality">📱 View in your space</button><a class="btn" id="download" download aria-label="Download the GLB file">Download GLB</a><button class="btn" id="share" type="button" aria-label="Share a link to this model">Share</button>+ <a class="btn" id="open-studio" aria-label="Open this model in the AR Studio and place several models together">Add to AR Studio</a><span class="spacer"></span><a class="btn" id="open-viewer" target="_blank" rel="noopener" aria-label="Open this model in the full 3D viewer">Open in viewer</a></div>@@ -225,7 +226,7 @@<footer class="foot">Free lane, fair-use rate limited · Models are meshopt-compressed glTF binaries ·- <a href="/forge">Forge studio</a> · <a href="/viewer">GLB viewer</a> · <a href="/features/ar">How AR works</a> ·+ <a href="/ar/studio">AR Studio (multi-model)</a> · <a href="/forge">Forge studio</a> · <a href="/viewer">GLB viewer</a> · <a href="/features/ar">How AR works</a> ·<a href="/irl">Living agents in AR</a></footer>@@ -363,6 +364,8 @@downloadEl.href = current.glb;downloadEl.setAttribute('download', fileName(current.prompt) + '.glb');openViewer.href = '/viewer?src=' + encodeURIComponent(current.glb) + '&title=' + encodeURIComponent((current.prompt || '').slice(0, 80));+ var studioEl = $('open-studio');+ if (studioEl) studioEl.href = '/ar/studio?src=' + encodeURIComponent(current.glb) + '&title=' + encodeURIComponent((current.prompt || '').slice(0, 80));if (mv.canActivateAR) {arBtn.textContent = '📱 View in your space';handoff.classList.remove('show');diff --git a/src/forge-ar.js b/src/forge-ar.jsindex 3a22c139e..b820591de 100644--- a/src/forge-ar.js+++ b/src/forge-ar.js@@ -74,10 +74,16 @@ function qrMarkup(glbUrl) {const cubeIcon = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2 3 7v10l9 5 9-5V7l-9-5Z"/><path d="m3 7 9 5 9-5"/><path d="M12 12v10"/></svg>`;+function studioLink(glbUrl, title) {+ const u = `/ar/studio?src=${encodeURIComponent(glbUrl)}`;+ return title ? `${u}&title=${encodeURIComponent(title.slice(0, 80))}` : u;+}+function bodyHtml({ glbUrl, title, touch }) {const link = esc(arLink(glbUrl, title));const nameHtml = title ? `<p class="tws-ar-name">${esc(title)}</p>` : '';const qr = qrMarkup(glbUrl);+ const studio = `<a class="tws-ar-link" href="${esc(studioLink(glbUrl, title))}">Arrange several models together in the AR Studio ↗</a>`;const linkBtn = `<a class="tws-ar-cta" href="${link}" target="_blank" rel="noopener">${cubeIcon}<span>Open AR viewer</span></a>`;@@ -95,6 +101,7 @@ function bodyHtml({ glbUrl, title, touch }) {<p class="tws-ar-hint">Place this model in your room — point your camera at a flat surface and drop it in.</p><button class="tws-ar-cta" type="button" data-ar-launch>${cubeIcon}<span>View in your space</span></button><a class="tws-ar-link" href="${link}" target="_blank" rel="noopener">Open in a new tab instead ↗</a>+ ${studio}${qrSecondary}</div>`;@@ -107,6 +114,7 @@ function bodyHtml({ glbUrl, title, touch }) {${qr}<p class="tws-ar-hint">Scan with your phone camera to view this model in AR and place it in your room.</p>${linkBtn}+ ${studio}</div>`;}diff --git a/tests/api/forge-multiview-photo.test.js b/tests/api/forge-multiview-photo.test.jsnew file mode 100644index 000000000..66056917b--- /dev/null+++ b/tests/api/forge-multiview-photo.test.js@@ -0,0 +1,172 @@+/**+ * Multi-view conditioning for single-photo image→3D on the self-host TRELLIS+ * fusing lane: api/forge.js.+ *+ * A single uploaded photo used to go to the fusing worker alone, so TRELLIS+ * hallucinated the subject's unseen sides (smeared textures, hollowed-out+ * backs). The handler now rotates the photo into side + back turnaround views+ * (Vertex Gemini edit lane) before submitting, exactly like the text→3D path+ * always did. These tests pin the gate: standard-tier single photos gain the+ * synthesized views; draft keeps single-view speed; caller-supplied multi-view+ * inputs are forwarded untouched; and a failed synthesis degrades to the+ * single view instead of failing the generation.+ */++import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest';++beforeAll(() => {+ Object.assign(process.env, {+ APP_ORIGIN: 'https://three.ws',+ // Self-hosted TRELLIS worker wired → photos route to the fusing lane.+ MODEL_TRELLIS_URL: 'https://trellis.example.run.app',+ GCP_RECONSTRUCTION_KEY: 'test-gcp-key',+ // Satisfies the handler's global text-to-3D configured guard; photo+ // uploads still prefer the self-host TRELLIS lane over NVIDIA (text-only).+ NVIDIA_API_KEY: 'nvapi-test',+ // The lane wraps its job id in a signed forge token (encodeJobToken).+ JWT_SECRET: 'test-jwt-secret-at-least-32-characters-long',+ });+});++// Self-hosted GCP worker accepts the job and returns a poll handle, echoing+// back how many views it was given: the wire contract under test.+const gcpSubmit = vi.fn(async ({ params }) => ({+ extJobId: 'gcpjob-multiview-01',+ viewsUsed: params.images.length,+ multiview: params.images.length > 1,+}));+vi.mock('../../api/_providers/gcp.js', () => ({+ createRegenProvider: () => ({ submit: gcpSubmit }),+}));++// Turnaround synthesis (Vertex Gemini edit lane) yields a side + back view of+// the uploaded photo. Individual tests override it to simulate an outage.+const synthesizeTurnaroundViews = vi.fn(async () => [+ 'https://cdn.example/photo-side.png',+ 'https://cdn.example/photo-back.png',+]);+vi.mock('../../api/_mcp3d/text-to-image.js', () => ({+ textToImage: vi.fn(async () => ({ imageUrl: 'https://cdn.example/ref.png', model: 'flux' })),+ synthesizeTurnaroundViews,+}));++// Store: no real DB. createCreation returns an id; failures are recorded.+vi.mock('../../api/_lib/forge-store.js', () => ({+ hashClient: (v) => `client:${v || 'anon'}`,+ hashIp: (v) => `ip:${v}`,+ createCreation: vi.fn(async () => 'creation-1'),+ materializeCreation: vi.fn(async ({ glbUrl }) => ({ id: 'creation-1', glbUrl })),+ markFailed: vi.fn(async () => {}),+ findByJob: vi.fn(async () => null),+}));++// Vision pre-check is a no-op pass: the routing, not the input, is under test.+vi.mock('../../api/_lib/forge-image-validate.js', () => ({+ validateForgeImage: vi.fn(async () => ({ ok: true })),+}));++// Rate limiter: deterministic success so the lane logic is what runs.+vi.mock('../../api/_lib/rate-limit.js', async (importActual) => {+ const actual = await importActual();+ return {+ ...actual,+ limits: {+ ...actual.limits,+ mcp3dGenerate: vi.fn(async () => ({ success: true, reset: Date.now() + 1000 })),+ mcp3dGenerateFree: vi.fn(async () => ({ success: true, reset: Date.now() + 1000 })),+ },+ clientIp: () => '203.0.113.9',+ };+});++const { default: handler } = await import('../../api/forge.js');++function makeReq(body) {+ return {+ method: 'POST',+ url: '/api/forge',+ headers: { 'content-type': 'application/json', 'x-forge-client': 'tester' },+ on(event, cb) {+ if (event === 'data') cb(Buffer.from(JSON.stringify(body)));+ if (event === 'end') cb();+ },+ };+}++function makeRes() {+ return {+ statusCode: 200,+ headers: {},+ body: null,+ setHeader(name, value) {+ this.headers[String(name).toLowerCase()] = value;+ },+ end(body) {+ this.body = body ? JSON.parse(body) : null;+ },+ };+}++const PHOTO = 'https://cdn.example/photo.png';++beforeEach(() => {+ gcpSubmit.mockClear();+ synthesizeTurnaroundViews.mockClear();+});++describe('single-photo image→3D gains synthesized turnaround views on the fusing lane', () => {+ it('submits the photo plus side + back views to the self-host TRELLIS worker', async () => {+ const req = makeReq({ image_urls: [PHOTO], tier: 'standard', path: 'image', skip_validation: true });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(res.body.backend).toBe('trellis_selfhost');+ expect(res.body.status).toBe('queued');+ expect(synthesizeTurnaroundViews).toHaveBeenCalledWith(PHOTO);+ expect(gcpSubmit).toHaveBeenCalledTimes(1);+ expect(gcpSubmit.mock.calls[0][0].params.images).toEqual([+ PHOTO,+ 'https://cdn.example/photo-side.png',+ 'https://cdn.example/photo-back.png',+ ]);+ // Provenance reports every view the worker fuses, primary first.+ expect(res.body.reference_image_urls).toHaveLength(3);+ expect(res.body.reference_image_urls[0]).toBe(PHOTO);+ expect(res.body.preview_image_url).toBe(PHOTO);+ });++ it('keeps draft single-view for speed (no synthesis call)', async () => {+ const req = makeReq({ image_urls: [PHOTO], tier: 'draft', path: 'image', skip_validation: true });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(res.body.backend).toBe('trellis_selfhost');+ expect(synthesizeTurnaroundViews).not.toHaveBeenCalled();+ expect(gcpSubmit.mock.calls[0][0].params.images).toEqual([PHOTO]);+ });++ it('forwards caller-supplied multi-view inputs untouched (their views win)', async () => {+ const supplied = [PHOTO, 'https://cdn.example/photo-left.png'];+ const req = makeReq({ image_urls: supplied, tier: 'standard', path: 'image', skip_validation: true });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(synthesizeTurnaroundViews).not.toHaveBeenCalled();+ expect(gcpSubmit.mock.calls[0][0].params.images).toEqual(supplied);+ });++ it('degrades to the single photo when synthesis fails: never a failed generation', async () => {+ synthesizeTurnaroundViews.mockRejectedValueOnce(new Error('vertex edit lane down'));+ const req = makeReq({ image_urls: [PHOTO], tier: 'standard', path: 'image', skip_validation: true });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(res.body.backend).toBe('trellis_selfhost');+ expect(res.body.status).toBe('queued');+ expect(gcpSubmit.mock.calls[0][0].params.images).toEqual([PHOTO]);+ });+});diff --git a/vercel.json b/vercel.jsonindex 0d98c0a96..cc057610c 100644--- a/vercel.json+++ b/vercel.json@@ -1363,6 +1363,13 @@},"dest": "/viewer.html"},+ {+ "src": "/ar/studio/?",+ "headers": {+ "permissions-policy": "xr-spatial-tracking=*, camera=(self), gyroscope=(self), accelerometer=(self), microphone=()"+ },+ "dest": "/ar-studio.html"+ },{"src": "/ar/?","headers": {diff --git a/vite.config.js b/vite.config.jsindex 0a3879414..f46d804d4 100644--- a/vite.config.js+++ b/vite.config.js@@ -543,6 +543,7 @@ const appConfig = {xr: resolve(__dirname, 'pages/xr.html'),temporary: resolve(__dirname, 'pages/temporary.html'),irl: resolve(__dirname, 'pages/irl.html'),+ 'ar-studio': resolve(__dirname, 'pages/ar-studio.html'),'irl-privacy': resolve(__dirname, 'pages/irl-privacy.html'),'world-lines': resolve(__dirname, 'pages/world-lines.html'),communities: resolve(__dirname, 'pages/communities.html'),@@ -1137,6 +1138,8 @@ support: resolve(__dirname, 'pages/support.html'),'/temporary/': resolve(root, 'pages/temporary.html'),'/irl': resolve(root, 'pages/irl.html'),'/irl/': resolve(root, 'pages/irl.html'),+ '/ar/studio': resolve(root, 'pages/ar-studio.html'),+ '/ar/studio/': resolve(root, 'pages/ar-studio.html'),'/irl-privacy': resolve(root, 'pages/irl-privacy.html'),'/irl-privacy/': resolve(root, 'pages/irl-privacy.html'),'/world-lines': resolve(root, 'pages/world-lines.html'),