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.

7.5 KB
Raw Blame
{"jsonrpc":"2.0","id":3,"result":{"contents":[{"uri":"ui://widget/three-studio-model.html","mimeType":"text/html+skybridge","text":"<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n<title>three.ws 3D Studio</title>\n<script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js\"></script>\n<style>\n  :root { color-scheme: dark; }\n  * { box-sizing: border-box; }\n  html, body { margin: 0; height: 100%; }\n  body {\n    font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif;\n    background: radial-gradient(120% 120% at 50% 0%, #14161c 0%, #0b0c10 60%, #08090c 100%);\n    color: #e8eaf0;\n  }\n  .wrap { display: flex; flex-direction: column; height: 100%; min-height: 320px; }\n  .stage { position: relative; flex: 1 1 auto; min-height: 260px; }\n  model-viewer {\n    width: 100%; height: 100%;\n    --poster-color: transparent;\n    --progress-bar-color: #6ea8fe;\n    background: transparent;\n  }\n  .overlay {\n    position: absolute; inset: 0;\n    display: flex; flex-direction: column; align-items: center; justify-content: center;\n    gap: 12px; text-align: center; padding: 24px;\n  }\n  .spinner {\n    width: 34px; height: 34px; border-radius: 50%;\n    border: 3px solid rgba(255,255,255,0.14); border-top-color: #6ea8fe;\n    animation: spin 0.9s linear infinite;\n  }\n  @keyframes spin { to { transform: rotate(360deg); } }\n  @media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }\n  .muted { color: #9aa3b2; font-size: 13px; line-height: 1.45; max-width: 36ch; }\n  .title { font-size: 14px; font-weight: 600; }\n  .bar {\n    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;\n    padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.07);\n    background: rgba(10,11,14,0.6); backdrop-filter: blur(6px);\n  }\n  .prompt {\n    flex: 1 1 160px; min-width: 0; font-size: 12.5px; color: #aeb6c4;\n    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\n  }\n  .chip {\n    font-size: 11px; font-weight: 600; letter-spacing: .02em;\n    color: #bcd3ff; background: rgba(110,168,254,0.13);\n    border: 1px solid rgba(110,168,254,0.28); border-radius: 999px;\n    padding: 3px 9px; text-transform: capitalize;\n  }\n  .actions { display: flex; gap: 8px; }\n  a.btn, button.btn {\n    appearance: none; cursor: pointer; text-decoration: none;\n    font-size: 12.5px; font-weight: 600; color: #e8eaf0;\n    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14);\n    border-radius: 9px; padding: 7px 12px; transition: background .15s, border-color .15s, transform .05s;\n  }\n  a.btn:hover, button.btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.28); }\n  a.btn:active, button.btn:active { transform: translateY(1px); }\n  a.btn:focus-visible, button.btn:focus-visible { outline: 2px solid #6ea8fe; outline-offset: 2px; }\n  .hidden { display: none !important; }\n</style>\n</head>\n<body>\n<div class=\"wrap\">\n  <div class=\"stage\">\n    <model-viewer id=\"mv\" class=\"hidden\" camera-controls auto-rotate touch-action=\"pan-y\"\n      shadow-intensity=\"1\" exposure=\"1.05\" environment-image=\"neutral\"\n      ar ar-modes=\"webxr scene-viewer quick-look\" alt=\"Generated 3D model\">\n    </model-viewer>\n\n    <div id=\"loading\" class=\"overlay\">\n      <div class=\"spinner\" aria-hidden=\"true\"></div>\n      <div class=\"title\">Generating your 3D model…</div>\n      <div class=\"muted\">Text-to-3D runs on free GPU lanes and usually takes 15–60 seconds.</div>\n    </div>\n\n    <div id=\"empty\" class=\"overlay hidden\">\n      <div class=\"title\">No model yet</div>\n      <div class=\"muted\">Describe an object, character, or creature and the studio will turn it into an interactive 3D model.</div>\n    </div>\n\n    <div id=\"error\" class=\"overlay hidden\">\n      <div class=\"title\">Couldn't load the model</div>\n      <div id=\"errmsg\" class=\"muted\">Something went wrong generating or displaying this model.</div>\n    </div>\n  </div>\n\n  <div id=\"bar\" class=\"bar hidden\">\n    <span id=\"kind\" class=\"chip\">model</span>\n    <span id=\"prompt\" class=\"prompt\"></span>\n    <div class=\"actions\">\n      <a id=\"open\" class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\">Open viewer</a>\n      <a id=\"download\" class=\"btn\" download>Download GLB</a>\n    </div>\n  </div>\n</div>\n\n<script>\n(function () {\n  var mv = document.getElementById('mv');\n  var loading = document.getElementById('loading');\n  var empty = document.getElementById('empty');\n  var errEl = document.getElementById('error');\n  var errMsg = document.getElementById('errmsg');\n  var bar = document.getElementById('bar');\n  var promptEl = document.getElementById('prompt');\n  var kindEl = document.getElementById('kind');\n  var openEl = document.getElementById('open');\n  var downloadEl = document.getElementById('download');\n\n  function show(el) { [loading, empty, errEl].forEach(function (n) { n.classList.add('hidden'); }); if (el) el.classList.remove('hidden'); }\n\n  function fail(msg) {\n    mv.classList.add('hidden');\n    bar.classList.add('hidden');\n    errMsg.textContent = msg || 'Something went wrong displaying this model.';\n    show(errEl);\n  }\n\n  function render(out) {\n    if (!out) { mv.classList.add('hidden'); bar.classList.add('hidden'); show(empty); return; }\n    if (out.error || out.message && !out.glbUrl) { fail(out.message || 'Generation did not return a model.'); return; }\n    var glb = out.glbUrl;\n    if (!glb || typeof glb !== 'string' || !/^https:\\/\\//.test(glb)) { mv.classList.add('hidden'); bar.classList.add('hidden'); show(empty); return; }\n\n    show(loading);\n    mv.classList.add('hidden');\n    mv.setAttribute('src', glb);\n\n    var kind = (out.kind || 'model').replace(/_/g, ' ');\n    kindEl.textContent = out.rigged ? 'rigged ' + kind : kind;\n    if (out.prompt) { promptEl.textContent = out.prompt; promptEl.title = out.prompt; }\n    else { promptEl.textContent = ''; }\n    openEl.href = out.viewerUrl || glb;\n    downloadEl.href = glb;\n    bar.classList.remove('hidden');\n  }\n\n  mv.addEventListener('load', function () { show(null); mv.classList.remove('hidden'); });\n  mv.addEventListener('error', function () { fail('The 3D model could not be displayed. You can still download the GLB file.'); });\n\n  function current() {\n    try { return (window.openai && window.openai.toolOutput) || null; } catch (e) { return null; }\n  }\n\n  // Initial paint (toolOutput may already be present) + live updates from the host.\n  render(current());\n  window.addEventListener('openai:set_globals', function () { render(current()); });\n  window.addEventListener('message', function (ev) {\n    var d = ev && ev.data;\n    if (d && d.type === 'openai:set_globals') render(current());\n    if (d && d.params && d.params.structuredContent) render(d.params.structuredContent);\n  });\n})();\n</script>\n</body>\n</html>","_meta":{"openai/widgetDescription":"Interactive 3D viewer for a generated model — rotate, view, and download the GLB.","openai/widgetCSP":{"connect_domains":["https://three.ws","https://*.three.ws","https://cdn.jsdelivr.net","https://replicate.delivery","https://*.replicate.delivery"],"resource_domains":["https://three.ws","https://*.three.ws","https://cdn.jsdelivr.net","https://replicate.delivery","https://*.replicate.delivery"]},"openai/widgetDomain":"https://three.ws","openai/widgetPrefersBorder":true}}]}}