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
Add guide for using custom layered images in parallax hero
nirholasd2470dda5f4e
diff --git "a/Screenshot 2026-04-27 at 6.05.50\342\200\257AM.png" "b/Screenshot 2026-04-27 at 6.05.50\342\200\257AM.png"deleted file mode 100644index de6d54fca..000000000Binary files "a/Screenshot 2026-04-27 at 6.05.50\342\200\257AM.png" and /dev/null differdiff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mddeleted file mode 100644index 3e82d74ab..000000000--- a/docs/ARCHITECTURE.md+++ /dev/null@@ -1,343 +0,0 @@-# Architecture--This document provides a deep technical overview of how three.ws is structured, how data flows through the system, and how each module fulfills its responsibilities.-------## High-Level Overview--three.ws is a single-page application (SPA) that runs entirely in the browser. There is no backend server — all model parsing, rendering, and validation happens client-side using WebGL 2.0.--```-┌─────────────────────────────────────────────────────────────┐-│ Browser │-│ │-│ index.html │-│ ├── style.css (all styles) │-│ └── src/app.js (ES module entry point) │-│ ├── Viewer (Three.js scene, renderer, GUI) │-│ │ └── environments.js (HDR map registry) │-│ ├── Validator (glTF spec validation) │-│ │ ├── ValidatorToggle (status bar) │-│ │ ├── ValidatorReport (full report) │-│ │ └── ValidatorTable (issue tables) │-│ └── Footer (social links) │-│ │-│ public/avatars/cz.glb (default model) │-└─────────────────────────────────────────────────────────────┘-```-------## Data Flow--### 1. Application Boot--```-DOMContentLoaded- └─► new App(document.body, location)- ├─► Parse URL hash parameters (model, kiosk, preset, cameraPosition)- ├─► Create SimpleDropzone (drag-and-drop handler)- ├─► Create Validator instance- └─► Load default model (hash `model` param, or `/avatars/cz.glb`)- └─► this.view(modelURL, '', new Map())-```--### 2. Model Loading (via URL)--```-App.view(rootFile, rootPath, fileMap)- ├─► Create Viewer if not already created- ├─► Generate blob URL (if File object) or use string URL directly- └─► Viewer.load(fileURL, rootPath, fileMap)- ├─► Configure MANAGER.setURLModifier() for blob URL resolution- ├─► GLTFLoader.load()- │ ├─► DRACOLoader (if Draco compressed)- │ ├─► KTX2Loader (if KTX2 textures)- │ └─► MeshoptDecoder (if meshopt compressed)- ├─► Viewer.setContent(scene, clips)- │ ├─► Compute bounding box, center model- │ ├─► Position camera based on model size- │ ├─► Detect embedded lights (disable punctual if found)- │ ├─► Set up AnimationMixer with clips- │ ├─► Update GUI folders (animations, morph targets, cameras)- │ └─► Apply lighting, environment, display settings- └─► Validator.validate(fileURL, rootPath, fileMap, gltf)- ├─► Fetch model as ArrayBuffer- ├─► validateBytes() from gltf-validator- ├─► Categorize issues by severity- └─► Render toggle bar + bind click → lightbox report-```--### 3. Model Loading (via Drag-and-Drop)--```-User drops files onto page- └─► SimpleDropzone 'drop' event- └─► App.load(fileMap: Map<string, File>)- ├─► Find root .gltf/.glb file in the fileset- ├─► Extract rootPath (directory prefix)- └─► App.view(rootFile, rootPath, fileMap)- └─► (same flow as URL loading above)-```--### 4. Multi-File Resolution--When a user drops a multi-file glTF (e.g., `scene.gltf` + `scene.bin` + textures), the `Viewer.load()` method installs a URL modifier on the Three.js `LoadingManager`:--```javascript-MANAGER.setURLModifier((url, path) => {- const normalizedURL =- rootPath +- decodeURI(url)- .replace(baseURL, '')- .replace(/^(\.?\/)/, '');-- if (assetMap.has(normalizedURL)) {- const blob = assetMap.get(normalizedURL);- return URL.createObjectURL(blob); // Serve from local blob- }-- return (path || '') + url; // Fall back to network fetch-});-```--This intercepts every resource request from GLTFLoader and serves matching files from the user's dropped fileset as blob URLs, avoiding any server round-trips.--### 5. Render Loop--```-requestAnimationFrame(this.animate)- └─► animate(time)- ├─► controls.update() (OrbitControls)- ├─► stats.update() (FPS/MS counter)- ├─► mixer.update(dt) (AnimationMixer)- └─► render()- ├─► renderer.render(scene, activeCamera) (main viewport)- └─► axesRenderer.render(axesScene, axesCamera) (axes helper)-```-------## Module Reference--### `App` — `src/app.js`--The application controller. Creates the dropzone, viewer, and validator. Routes user interactions.--| Method | Description |-| ----------------------------------- | ----------------------------------------------------------- |-| `constructor(el, location)` | Parses hash params, sets up dropzone, loads initial model |-| `createDropzone()` | Binds SimpleDropzone to `.wrap` element and `#file-input` |-| `createViewer()` | Instantiates `Viewer` on first model load |-| `load(fileMap)` | Finds root glTF/GLB in a dropped fileset and calls `view()` |-| `view(rootFile, rootPath, fileMap)` | Passes model to `Viewer.load()` and `Validator.validate()` |-| `onError(error)` | Normalizes error messages and shows `window.alert()` |-| `showSpinner()` / `hideSpinner()` | Toggle loading indicator visibility |--### `Viewer` — `src/viewer.js`--The Three.js rendering engine. Manages the full 3D pipeline: scene, camera, renderer, lights, environment, controls, animations, and GUI.--See [API Reference](API.md#viewer) for the complete method listing.--### `Validator` — `src/validator.js`--Runs the Khronos glTF-Validator against loaded models and renders results.--See [API Reference](API.md#validator) for the complete method listing.--### `environments` — `src/environments.js`--Exports a flat array of environment map definitions:--```javascript-[- { id: '', name: 'None', path: null },- { id: 'neutral', name: 'Neutral', path: null },- { id: 'venice-sunset', name: 'Venice Sunset', path: '...1k.exr' },- { id: 'footprint-court', name: 'Footprint Court', path: '...2k.exr' },-];-```--- `id: ''` — no environment map applied-- `id: 'neutral'` — uses `THREE.RoomEnvironment` (procedural, no network fetch)-- All others — fetched via `EXRLoader` and processed through `PMREMGenerator`--### Components — `src/components/`--All components use [vhtml](https://github.com/developit/vhtml) — a JSX-compatible library that outputs plain HTML strings (no virtual DOM, no reactivity).--| Component | File | Description |-| ----------------- | ---------------------- | ---------------------------------------------------------- |-| `Footer` | `footer.jsx` | Social links (X/Twitter, GitHub) and feedback link |-| `ValidatorToggle` | `validator-toggle.jsx` | Status bar with severity color and dismiss button |-| `ValidatorReport` | `validator-report.jsx` | Full report with metadata, stats, extensions, issue tables |-| `ValidatorTable` | `validator-table.jsx` | Color-coded table of issues (code, message, JSON pointer) |-------## Three.js Setup Details--### Renderer--```javascript-new WebGLRenderer({ antialias: true })- .setClearColor(0xcccccc)- .setPixelRatio(window.devicePixelRatio)- .setSize(el.clientWidth, el.clientHeight);-```--### Camera--- **Default camera:** `PerspectiveCamera(60°, aspect, 0.01, 1000)`-- **Asset generator preset:** `PerspectiveCamera(0.8 * 180/π ≈ 45.8°, ...)`-- Near/far planes are dynamically adjusted based on model bounding box size-- Embedded glTF cameras can be selected; they disable OrbitControls--### Lights--When the model does **not** contain embedded lights (`state.punctualLights = true`):--| Light | Type | Default Intensity | Position |-| ----------- | ------------------ | ----------------- | --------------------------- |-| Ambient | `AmbientLight` | 0.3 | Attached to camera |-| Directional | `DirectionalLight` | 0.8π ≈ 2.51 | `(0.5, 0, 0.866)` on camera |--When the model **does** contain lights, punctual lights are disabled and the model's own lights are used.--Asset generator preset uses a single `HemisphereLight` instead.--### Loaders--| Loader | CDN Source | Purpose |-| ---------------- | -------------------------------------------------------------- | ---------------------------------------- |-| `GLTFLoader` | Bundled (three.js) | Core glTF 2.0 parser |-| `DRACOLoader` | `unpkg.com/three@0.{REVISION}.x/examples/jsm/libs/draco/gltf/` | Draco mesh decompression |-| `KTX2Loader` | `unpkg.com/three@0.{REVISION}.x/examples/jsm/libs/basis/` | KTX2/Basis Universal texture transcoding |-| `MeshoptDecoder` | Bundled (three.js) | Meshopt compression decoding |--All loaders are shared singleton instances to avoid redundant initialization.--### Caching--`THREE.Cache.enabled = true` — enables the built-in three.js HTTP request cache, preventing duplicate fetches for shared resources (textures referenced by multiple materials, etc.).-------## Validation Pipeline--```-Validator.validate(fileURL, rootPath, assetMap, gltfResponse)- │- ├─► fetch(fileURL) → ArrayBuffer- │- ├─► validateBytes(Uint8Array, { externalResourceFunction })- │ │- │ └─► For each external URI:- │ resolveExternalResource(uri, rootFile, rootPath, assetMap)- │ ├─► Check assetMap (dropped files) → blob URL- │ └─► Fall back to network fetch- │- ├─► setReport(report, response)- │ ├─► Determine maxSeverity (0=Error, 1=Warning, 2=Info, 3=Hint)- │ ├─► Split messages into errors[], warnings[], infos[], hints[]- │ ├─► Aggregate repetitive messages (ACCESSOR_NON_UNIT, etc.)- │ ├─► Extract asset.extras metadata (author, license, source, title)- │ └─► Render ValidatorToggle HTML- │- └─► Bind click → open ValidatorReport in new tab-```--### Severity Levels--| Level | Color | CSS Class | Meaning |-| ----- | ------ | --------- | --------------------------- |-| 0 | Red | `level-0` | Errors — spec violations |-| 1 | Yellow | `level-1` | Warnings — potential issues |-| 2 | Blue | — | Informational notes |-| 3 | Green | — | Optimization hints |--### Message Aggregation--Certain high-frequency validation messages (like `ACCESSOR_NON_UNIT` appearing thousands of times for vertex normals) are aggregated into a single summary message with a count, to keep reports readable.-------## GUI Structure (dat.gui)--The dat.gui panel is built programmatically in `Viewer.addGUI()`:--```-dat.gui-├── Display/-│ ├── background (boolean)-│ ├── autoRotate (boolean)-│ ├── wireframe (boolean)-│ ├── skeleton (boolean)-│ ├── grid (boolean)-│ ├── screenSpacePanning (boolean)-│ ├── pointSize (number: 1–16)-│ └── bgColor (color)-│-├── Lighting/-│ ├── environment (dropdown: None/Neutral/Venice Sunset/Footprint Court)-│ ├── toneMapping (dropdown: Linear/ACES Filmic)-│ ├── exposure (number: -10–10)-│ ├── punctualLights (boolean, listen)-│ ├── ambientIntensity (number: 0–2)-│ ├── ambientColor (color)-│ ├── directIntensity (number: 0–4)-│ └── directColor (color)-│-├── Animation/ (hidden if no clips)-│ ├── playbackSpeed (number: 0–1)-│ ├── playAll (button)-│ └── [per-clip toggles] (boolean, dynamic)-│-├── Morph Targets/ (hidden if no morphs)-│ └── [per-mesh per-target sliders] (number: 0–1, dynamic)-│-├── Cameras/ (hidden if no embedded cameras)-│ └── camera (dropdown: [default] + glTF camera names)-│-└── Performance/- └── stats.js panel (FPS / MS / MB)-```--Dynamic folders (Animation, Morph Targets, Cameras) have their controls rebuilt every time a new model loads via `Viewer.updateGUI()`.-------## Styling Architecture--All styles live in a single `style.css` file with clearly delineated sections:--| Section | Description |-| ------------------- | ------------------------------------------------------------------- |-| Base reset | `html, body` reset, dark background, Inter font |-| Layout | Flexbox column: header → main (viewer + dropzone) |-| Viewer | Full-bleed canvas container |-| Axes | Fixed 100×100 px overlay, bottom-left, `pointer-events: none` |-| Header | Sticky top bar, blur backdrop, 3.5rem height |-| GUI wrap | Absolute positioning, right side, `pointer-events: none` on wrapper |-| dat.gui overrides | Dark theme: `#0a0a0a` backgrounds, subtle borders |-| Responsive (≤700px) | Collapsed header, hidden drop hint, 65vw max GUI width |-| Footer | Absolute bottom-right, monospace, low opacity |-| Upload button | Custom file input styling |-| Validation report | Tables, toggle bar, severity colors |-| Spinner | CSS-only pulsing circle animation |--### Safe Area Support--The layout respects iOS safe areas via `env(safe-area-inset-*)` for notch/home-indicator clearance on the header, footer, and dropzone.-------## Security Considerations--- **No server uploads** — files are read via the File API and rendered locally-- **Blob URL lifecycle** — all `URL.createObjectURL()` calls are paired with `URL.revokeObjectURL()` in cleanup callbacks-- **HTML escaping** — the validator escapes HTML in asset metadata via `escapeHTML()` before rendering, then applies `linkify()` to convert URLs to `<a>` tags-- **CORS** — the `cors.json` configuration restricts cross-origin access to known domains-- **CSP** — no inline scripts; the entry point uses `<script defer type="module">`diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.mddeleted file mode 100644index 96eb47fc8..000000000--- a/docs/DEPLOYMENT.md+++ /dev/null@@ -1,362 +0,0 @@-# Deployment Guide--This guide covers building and deploying three.ws to production.-------## Table of Contents--- [Prerequisites](#prerequisites)-- [Build](#build)-- [Deploy to Vercel](#deploy-to-vercel)-- [Vercel Configuration](#vercel-configuration)-- [CORS Configuration](#cors-configuration)-- [Custom Domain](#custom-domain)-- [Embedding](#embedding)-- [Self-Hosting](#self-hosting)-- [CDN and Caching](#cdn-and-caching)-- [Environment Variables](#environment-variables)-- [Troubleshooting](#troubleshooting)-------## Prerequisites--- **Node.js** ≥ 18-- **npm** (included with Node.js)-- **Vercel CLI** (installed globally or via npx): `npm i -g vercel`-- **Vercel account** linked via `vercel login`-------## Build--```bash-# Production build-npm run build-```--This runs `vite build`, which:--1. Bundles all JavaScript from `src/` into optimized chunks-2. Processes CSS-3. Outputs to `dist/`--To inspect the build output:--```bash-ls -la dist/-```--To clean previous builds:--```bash-npm run clean # Removes dist/-```-------## Deploy to Vercel--The one-command deploy:--```bash-npm run deploy-```--This runs `npm run build` followed by `vercel --local-config vercel.json --prod`.--### Manual deployment steps:--```bash-# 1. Build-npm run build--# 2. Deploy to preview-vercel--# 3. Deploy to production-vercel --prod-```-------## Vercel Configuration--**File:** `vercel.json`--```json-{- "public": true,- "routes": [- {- "src": "/assets/(.*)",- "headers": { "cache-control": "max-age=604800, public" },- "dest": "/assets/$1"- },- {- "src": "/(.*)",- "dest": "/public/$1"- }- ]-}-```--### Route Breakdown--| Route | Behavior |-| ----------- | ------------------------------------------------------- |-| `/assets/*` | Static assets served with 7-day cache (604,800 seconds) |-| `/*` | Everything else rewrites to `/public/*` |--The `public: true` flag allows listing of the deployment.-------## CORS Configuration--**File:** `cors.json`--```json-[- {- "method": ["GET"],- "origin": [- "https://three.ws/",- "https://*.three.ws",- "https://chat.sperax.io",- "https://sperax-jam2emun9-moomsi.vercel.app",- "https://sperax-iota.vercel.app",- "http://localhost:*",- "https://localhost:*"- ],- "responseHeader": ["Content-Type"],- "maxAgeSeconds": 3600- }-]-```--This allows:--- The production domain and all subdomains-- Partner domains (Sperax)-- Local development on any port-- Only GET requests-- 1-hour CORS preflight cache--### Adding a New Origin--To allow a new domain to embed three.ws:--1. Add the origin to the `origin` array in `cors.json`-2. Redeploy-------## Custom Domain--The production deployment uses `three.ws`. To use a custom domain:--1. Add the domain in the Vercel dashboard under **Settings → Domains**-2. Configure DNS:- - **A record:** `76.76.21.21`- - **CNAME:** `cname.vercel-dns.com`-3. Vercel automatically provisions an SSL certificate-------## Embedding--three.ws supports embedding via `<iframe>` with kiosk mode for a clean, UI-free experience:--```html-<iframe- src="https://three.ws/#model=https://your-cdn.com/model.glb&kiosk=true"- width="100%"- height="600"- frameborder="0"- allow="autoplay; fullscreen"- style="border: none;"-></iframe>-```--### Kiosk Mode--Add `kiosk=true` to the hash to:--- Hide the top header bar-- Auto-close the dat.gui panel-- Hide the validation toggle--### CORS Requirement--The model URL **must** allow cross-origin requests from the embedding page. If the model is on a different domain:--- Configure the CDN/server to include `Access-Control-Allow-Origin` headers-- Or serve the model from the same domain as three.ws--### Custom Camera Position--Set the initial viewpoint for an embed:--```-#model=URL&kiosk=true&cameraPosition=0,1.5,3-```--The coordinates are in Three.js world space (x, y, z).-------## Self-Hosting--To host three.ws on your own infrastructure:--### With a Static File Server--```bash-# Build-npm run build--# Serve the dist/ directory-npx serve dist--# Or with nginx, Apache, Caddy, etc.-```--### Nginx Example--```nginx-server {- listen 80;- server_name 3d.yourdomain.com;- root /var/www/3d-agent/dist;- index index.html;-- # SPA fallback- location / {- try_files $uri $uri/ /index.html;- }-- # Cache static assets- location /assets/ {- expires 7d;- add_header Cache-Control "public, immutable";- }-- # CORS for model loading- add_header Access-Control-Allow-Origin "*";- add_header Access-Control-Allow-Methods "GET";-}-```--### Docker--```dockerfile-FROM node:18-alpine AS build-WORKDIR /app-COPY package*.json ./-RUN npm ci-COPY . .-RUN npm run build--FROM nginx:alpine-COPY --from=build /app/dist /usr/share/nginx/html-EXPOSE 80-```--```bash-docker build -t 3d-agent .-docker run -p 8080:80 3d-agent-```-------## CDN and Caching--### External CDN Dependencies--The app loads decoder libraries from unpkg at runtime:--| Library | CDN URL Pattern |-| --------------------- | ---------------------------------------------------------------------- |-| Draco decoder | `https://unpkg.com/three@0.{REVISION}.x/examples/jsm/libs/draco/gltf/` |-| KTX2/Basis transcoder | `https://unpkg.com/three@0.{REVISION}.x/examples/jsm/libs/basis/` |--These are versioned to the installed three.js revision, so they automatically match.--### HDR Environment Maps--Environment maps are loaded from Google Cloud Storage:--| Map | URL |-| --------------- | ------------------------------------------------------------------------- |-| Venice Sunset | `https://storage.googleapis.com/donmccurdy-static/venice_sunset_1k.exr` |-| Footprint Court | `https://storage.googleapis.com/donmccurdy-static/footprint_court_2k.exr` |--For self-hosting, download these files and update the paths in `src/environments.js`.--### Caching Strategy--| Resource | Cache Duration |-| ------------------------- | ------------------------- |-| `/assets/*` | 7 days (`max-age=604800`) |-| Decoder libraries (unpkg) | CDN-controlled |-| HDR maps (GCS) | CDN-controlled |-| Application bundles | Content-hashed by Vite |-------## Environment Variables--three.ws does not require any environment variables. All configuration is done via:--- URL hash parameters (runtime)-- `src/environments.js` (build-time)-- `vercel.json` (deployment)-- `cors.json` (CORS)-------## Troubleshooting--### Build fails with "out of memory"--```bash-NODE_OPTIONS=--max-old-space-size=4096 npm run build-```--### Model doesn't load (CORS error)--Check the browser console for CORS errors. The model URL must either:--- Be on the same domain as the app-- Include proper `Access-Control-Allow-Origin` headers--### Blank page after deploy--Verify that `vercel.json` routing is correct. The `/(.*) → /public/$1` rewrite must match your build output structure.--### Draco models fail to load--Draco decoders are loaded from unpkg. If the CDN is down or blocked:--1. Download the Draco decoder files-2. Serve them locally-3. Update the `DRACO_LOADER.setDecoderPath()` call in `src/viewer.js`--### Environment maps don't appear--EXR files are large. Check:--- Network tab for failed requests-- Console for `EXRLoader` errors-- That the GCS URLs are accessible from your deployment--### Version management--```bash-# Bump version (patch/minor/major)-npm version patch--# This triggers postversion: git push && git push --tags-```diff --git a/docs/MCP.md b/docs/MCP.mddeleted file mode 100644index e8947b2f6..000000000--- a/docs/MCP.md+++ /dev/null@@ -1,77 +0,0 @@-# three.ws MCP Server--The three.ws MCP server lets any Model Context Protocol client — Claude Desktop,-Claude Code, custom agents built on the Claude Agent SDK, or any other-MCP-compatible app — list, render, and manage a user's 3D avatars.--- **URL:** `https://three.ws/api/mcp`-- **Transport:** Streamable HTTP (MCP spec `2025-06-18`)-- **Auth:** OAuth 2.1 (end-user) or API key (server-to-server)-- **Docs:** <https://three.ws/docs/mcp>--## Tools--| Name | Scope | Description |-| ----------------------- | ---------------- | ----------------------------------------------------------------------- |-| `list_my_avatars` | `avatars:read` | Paginated list of the caller's avatars. |-| `get_avatar` | `avatars:read` | Fetch one avatar by `id` or `slug`. |-| `search_public_avatars` | — | Discover public avatars (no auth needed for read). |-| `render_avatar` | `avatars:read` | Returns ready-to-embed `<model-viewer>` HTML. Use as a Claude artifact. |-| `delete_avatar` | `avatars:delete` | Soft-delete an avatar you own. |--## Auth: OAuth 2.1--Claude handles the handshake automatically via dynamic client registration:--1. Client POSTs to `https://three.ws/oauth/register` (RFC 7591).-2. User is redirected to `https://three.ws/oauth/authorize?...` to sign in + consent.-3. Client exchanges the code at `https://three.ws/oauth/token` with PKCE.-4. Resulting access token is a short-lived JWT with `aud=https://three.ws/api/mcp`.--Metadata discovery:--- Authorization Server: `GET /.well-known/oauth-authorization-server`-- Protected Resource: `GET /.well-known/oauth-protected-resource`--On a 401 from `/api/mcp`, the `WWW-Authenticate` header points clients at the-protected-resource metadata URL, per RFC 9728.--## Auth: API key--For server-to-server usage (scripts, agents, CI), create a key in the dashboard-under _API keys_ and pass it as a bearer token:--```bash-curl -X POST https://three.ws/api/mcp \- -H "authorization: Bearer sk_live_…" \- -H "content-type: application/json" \- -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'-```--Keys are owned by a single user and inherit that user's plan limits.--## Example: render an avatar in Claude--Once connected, ask Claude:--> List my avatars, then render my `nich-holographic` avatar as an interactive-> 3D viewer.--Claude will call `list_my_avatars`, then `render_avatar({ slug: "nich-holographic" })`,-and emit the returned HTML as an inline artifact.--## Plans & quotas--| Plan | Avatars | Size / file | Total storage | MCP calls / day |-| ---------- | ------- | ----------- | ------------- | --------------- |-| Free | 10 | 25 MB | 250 MB | 1 000 |-| Pro | 500 | 50 MB | 25 GB | 50 000 |-| Team | 5 000 | 100 MB | 500 GB | 500 000 |-| Enterprise | 100 000 | 500 MB | 10 TB | 10 000 000 |--## Credits--three.ws provides authentication, storage, MCP access, and multi-tenant-infrastructure. The avatar creation engine is pluggable — the default-build uses the Avaturn SDK under the hood, but the provider can be-swapped at [src/avatar-creator.js](../src/avatar-creator.js).diff --git a/docs/WIDGETS.md b/docs/WIDGETS.mddeleted file mode 100644index 9ad7be4d3..000000000--- a/docs/WIDGETS.md+++ /dev/null@@ -1,270 +0,0 @@-# Widgets--Embeddable 3D — a configured, shareable view of an avatar that any site can drop in with one line of HTML.--A widget is a saved bundle of: an avatar (GLB stored in R2), a widget type (turntable, animation gallery, talking agent, ERC-8004 passport, hotspot tour), and brand config (background, accent, caption, controls, camera). Widgets are created in the [Widget Studio](https://three.ws/studio) and shared via short URLs.-------## Table of Contents--- [Quick start](#quick-start)-- [Widget types](#widget-types)-- [URLs](#urls)-- [Embedding](#embedding)-- [postMessage API](#postmessage-api)-- [OG / oEmbed](#og--oembed)-- [CSP / CORS](#csp--cors)-- [Privacy & analytics](#privacy--analytics)-- [FAQ](#faq)-------## Quick start--1. Sign in at [three.ws](https://three.ws/).-2. Open the [Studio](https://three.ws/studio).-3. Pick an avatar, pick a widget type, tweak brand colors and controls, click **Generate Embed**.-4. Copy the iframe snippet into any HTML page, blog post, Notion doc, or CMS.-------## Widget types--| Type | Best for | Default size |-| ------------------- | ---------------------------------------------------- | ------------ |-| `turntable` | Hero banners, product showcases. Auto-rotate, no UI. | 600 × 600 |-| `animation-gallery` | Showcasing a rigged avatar's animation library. | 720 × 720 |-| `talking-agent` | Embodied chat — your agent on your site. | 420 × 600 |-| `passport` | On-chain identity card backed by ERC-8004. | 480 × 560 |-| `hotspot-tour` | Annotated 3D scenes with clickable POIs. | 800 × 600 |-------## URLs--Every widget has three canonical URLs.--| URL | Use it for |-| ------------------------------------------------ | --------------------------------------------------------------- |-| `https://three.ws/w/<id>` | Sharing in Slack/Discord/X — server-rendered with rich OG card. |-| `https://three.ws/app#widget=<id>` | The SPA viewer with the widget config applied. |-| `https://three.ws/api/widgets/<id>/og` | The 1200×630 preview image. |--`/w/<id>` is the recommended share URL — bots get an OG preview, browsers fall through to the SPA.--### Hash parameters--The viewer supports the following hash params (combine with `&`):--| Param | Type | Description |-| ---------------- | --------- | ---------------------------------------------------------- |-| `widget` | `string` | Loads a saved widget by id. |-| `model` | `string` | Loads a raw GLB by URL (mutually exclusive with `widget`). |-| `kiosk` | `boolean` | Hides the header chrome for clean iframe embeds. |-| `cameraPosition` | `x,y,z` | Comma-separated camera position override. |-| `preset` | `string` | HDR environment preset name. |-------## Embedding--### iframe (recommended)--```html-<iframe- src="https://three.ws/app#widget=wdgt_abc123def456&kiosk=true"- width="600"- height="600"- style="border:0;border-radius:12px;max-width:100%"- allow="autoplay; xr-spatial-tracking; clipboard-write"- loading="lazy"-></iframe>-```--**Size guidance:**--- Turntable / hotspot-tour: 1:1 or 4:3 — let the user breathe.-- Animation-gallery: 1:1 or slightly wider — picker docks to the top-right on desktop, bottom on mobile.-- Talking-agent: 7:10 portrait — chat needs vertical space.-- Passport: anything ≥ 360 × 480.--### Animation Gallery specifics--The `animation-gallery` widget renders every skinned clip on the avatar as a keyboard-navigable list.--| Config key | Type | Default | Description |-| ---------------- | --------- | ------- | ------------------------------------------------------------------------------------ |-| `defaultClip` | `string` | `''` | Clip name to autoplay on mount. Falls back to the first clip if the name is unknown. |-| `loopAll` | `boolean` | `false` | When true, each clip plays once then advances to the next; wraps to the first. |-| `showClipPicker` | `boolean` | `true` | Hide the picker chrome while keeping clip playback driven by `widget:command`. |--Keyboard: ↑/↓ (or `k`/`j`) to move, Home/End to jump, Enter or Space to (re)play the highlighted clip. The picker pins to the top-right; on narrow viewports it docks to the bottom.--### Script embed--```html-<script async src="https://three.ws/embed.js" data-widget="wdgt_abc123def456"></script>-```--The script injects a sandboxed iframe at the script tag's location and forwards size/postMessage events to the parent. Use this when you want auto-resize behavior; use a raw iframe when you want full control.--### oEmbed (WordPress, Ghost, Notion)--Most CMSes auto-detect oEmbed. Paste a `https://three.ws/w/<id>` URL on its own line and the editor should turn it into a live embed automatically. If not, use the iframe snippet above.-------## postMessage API--Widgets communicate with the parent page via `window.postMessage`. **Always check `event.origin === 'https://three.ws/'` (or your custom domain) before trusting any message.**--### iframe → parent--| Event | Payload | When |-| --------------------- | ------------------- | ----------------------------------------- |-| `widget:ready` | `{ id, type }` | Widget runtime has booted. |-| `widget:load` | `{ id, model_url }` | Underlying GLB loaded successfully. |-| `widget:load:error` | `{ id, error }` | GLB or config failed to load. |-| `widget:chat:message` | `{ role, content }` | Talking-agent only — a new chat turn. |-| `widget:hotspot:open` | `{ id, label }` | Hotspot-tour only — visitor opened a POI. |-| `widget:resize` | `{ width, height }` | Widget reports its preferred size. |--```js-window.addEventListener('message', (e) => {- if (e.origin !== 'https://three.ws/') return;- if (e.data?.type === 'widget:ready') {- console.log('Widget mounted:', e.data.id);- }-});-```--### parent → iframe--| Event | Payload | Effect |-| ---------------- | ----------------------------------------- | ------------------------------------------------------ |-| `widget:config` | `{ background, accent, autoRotate, ... }` | Live-update brand config (used by the Studio preview). |-| `widget:command` | `{ command, args }` | Trigger a runtime action (e.g. `play_clip`, `wave`). |--```js-const iframe = document.querySelector('iframe');-iframe.contentWindow.postMessage(- { type: 'widget:config', config: { background: '#ff00aa' } },- 'https://three.ws/',-);-```-------## OG / oEmbed--Every widget URL serves rich-preview metadata.--### Open Graph--`/w/<id>` returns a server-rendered HTML page with:--```html-<meta property="og:title" content="…" />-<meta property="og:description" content="…" />-<meta property="og:image" content="https://three.ws/api/widgets/<id>/og" />-<meta name="twitter:card" content="summary_large_image" />-<link- rel="alternate"- type="application/json+oembed"- href="https://three.ws/api/widgets/oembed?url=…"-/>-```--### oEmbed endpoint--```-GET /api/widgets/oembed?url=<widget-url>&format=json-```--Returns standard [oEmbed v1.0](https://oembed.com) JSON, type `rich`.--```json-{- "type": "rich",- "version": "1.0",- "provider_name": "three.ws",- "provider_url": "https://three.ws/",- "title": "…",- "html": "<iframe …></iframe>",- "width": 600,- "height": 600,- "thumbnail_url": "…",- "thumbnail_width": 1200,- "thumbnail_height": 630-}-```--Accepts both `https://host/w/<id>` and `https://host/app#widget=<id>` forms. Optional `maxwidth` / `maxheight` clamp the returned iframe dimensions.-------## CSP / CORS--Widgets run in a sandboxed iframe with these `allow` flags:--- `autoplay` — needed for ambient animations.-- `xr-spatial-tracking` — for future WebXR support.-- `clipboard-write` — passport widget copies its address.--If your site uses a strict Content Security Policy, allow:--```-frame-src https://three.ws/;-img-src https://three.ws/ data:;-```--The widget iframe makes outbound requests to `three.ws` and (for some widgets) to public RPC endpoints / R2 storage CDNs. None of these require parent-side CORS configuration.-------## Privacy & analytics--We log a minimal first-party event per widget load:--| Field | Source |-| -------------- | -------------------------------------------------- |-| `widget_id` | the widget being loaded |-| `type` | the widget type |-| `country` | Vercel edge header (`x-vercel-ip-country`) |-| `referer_host` | hostname of the embedding page (no path, no query) |-| `created_at` | timestamp |--We **do not** log:--- IP addresses-- User agent strings-- Cookies (we don't set any on the embed)-- Chat message content (talking-agent transcripts stay between visitor and agent brain)-- Full URLs (only the host)--The widget owner can see aggregated counts in their [Dashboard](https://three.ws/dashboard). No cross-widget tracking.-------## FAQ--**Can I self-host?** The runtime is open source. The Studio + saved-widgets API depends on Neon + R2; you'd need to wire those yourself. See [DEPLOYMENT.md](./DEPLOYMENT.md).--**Why no WordPress plugin?** The oEmbed endpoint already does what a plugin would. Paste a `/w/<id>` URL into a Gutenberg paragraph block — done.--**How big is the bundle?** The widget runtime lazy-loads only the code needed for its type. Cold load with a small GLB lands ~400KB JS + the GLB itself. Use `loading="lazy"` on the iframe to defer until scroll.--**Mobile?** Yes — every widget type works on iOS Safari and Android Chrome. Touch controls are first-class. `kiosk=true` is enabled by default in embed mode.--**Can I customize per-page?** Use `postMessage` to send live `widget:config` events from the parent page (e.g. tie the widget background to your site theme).--**What about offline?** The viewer registers a service worker for repeat-visit caching. First load is online-only.-------## Known issues--- iOS Safari may require a user gesture before `speechSynthesis.getVoices()` returns voices for the talking-agent widget.-- Some browser extensions (uBlock + strict mode) will block the analytics POST. The widget itself still works.-- Embedding inside a parent iframe that's _also_ sandboxed can break WebGL initialization. Add `allow-scripts allow-same-origin` to the parent sandbox.diff --git a/docs/AUTO_DRIVE_REPORT.md b/docs/internal/AUTO_DRIVE_REPORT.mdsimilarity index 100%rename from docs/AUTO_DRIVE_REPORT.mdrename to docs/internal/AUTO_DRIVE_REPORT.mddiff --git a/docs/CZ_DEMO_FAILURE_MODES.md b/docs/internal/CZ_DEMO_FAILURE_MODES.mdsimilarity index 100%rename from docs/CZ_DEMO_FAILURE_MODES.mdrename to docs/internal/CZ_DEMO_FAILURE_MODES.mddiff --git a/docs/CZ_DEMO_RUNBOOK.md b/docs/internal/CZ_DEMO_RUNBOOK.mdsimilarity index 100%rename from docs/CZ_DEMO_RUNBOOK.mdrename to docs/internal/CZ_DEMO_RUNBOOK.mddiff --git a/docs/DEVELOPMENT.md b/docs/internal/DEVELOPMENT.mdsimilarity index 100%rename from docs/DEVELOPMENT.mdrename to docs/internal/DEVELOPMENT.mddiff --git a/docs/PAGES.md b/docs/internal/PAGES.mdsimilarity index 100%rename from docs/PAGES.mdrename to docs/internal/PAGES.mddiff --git a/docs/SETUP.md b/docs/internal/SETUP.mdsimilarity index 100%rename from docs/SETUP.mdrename to docs/internal/SETUP.mddiff --git a/docs/SMOKE_TEST.md b/docs/internal/SMOKE_TEST.mdsimilarity index 100%rename from docs/SMOKE_TEST.mdrename to docs/internal/SMOKE_TEST.mddiff --git a/docs/VALIDATION_DEPLOY.md b/docs/internal/VALIDATION_DEPLOY.mdsimilarity index 100%rename from docs/VALIDATION_DEPLOY.mdrename to docs/internal/VALIDATION_DEPLOY.mddiff --git a/docs/api-inventory.md b/docs/internal/api-inventory.mdsimilarity index 100%rename from docs/api-inventory.mdrename to docs/internal/api-inventory.mddiff --git a/docs/tutorial-build-pai-site.md b/docs/internal/tutorial-build-pai-site.mdsimilarity index 100%rename from docs/tutorial-build-pai-site.mdrename to docs/internal/tutorial-build-pai-site.mddiff --git a/home.css b/home.cssindex 7598a159a..61fa77608 100644--- a/home.css+++ b/home.css@@ -232,7 +232,7 @@.h-bento-card {background: rgba(255, 255, 255, 0.025);border: 1px solid rgba(255, 255, 255, 0.06);- border-radius: 16px;+ border-radius: 8px;overflow: hidden;transition: border-color 0.3s ease, transform 0.3s ease;display: flex;@@ -452,7 +452,7 @@color: rgba(167, 139, 250, 0.65);font-family: 'Space Grotesk', sans-serif;border: 1px solid rgba(167, 139, 250, 0.2);- border-radius: 999px;+ border-radius: 4px;padding: 0.2rem 0.55rem;}@@ -516,7 +516,7 @@.h-dev-code {background: #0a0a0e;border: 1px solid rgba(255, 255, 255, 0.07);- border-radius: 14px;+ border-radius: 8px;overflow: hidden;}@@ -767,7 +767,7 @@align-items: center;gap: 0.4rem;padding: 0.32rem 0.7rem;- border-radius: 999px;+ border-radius: 6px;border: 1px solid rgba(255, 255, 255, 0.09);background: rgba(255, 255, 255, 0.025);color: rgba(255, 255, 255, 0.62);@@ -1148,8 +1148,8 @@.h-layer-orb--mint {background: radial-gradient(circle, color-mix(in srgb, #6ee7b7 60%, #38bdf8 40%), transparent 70%);- top: 18%;- right: 8%;+ top: 33%;+ right: 36%;}/* ── Floating word glyphs (Act 2 depth 4) ───────────────────────────────── */@@ -1182,7 +1182,7 @@color: rgba(110, 231, 183, 0.18);text-transform: uppercase;border: 1px solid rgba(110, 231, 183, 0.1);- border-radius: 999px;+ border-radius: 6px;padding: 0.4rem 1rem;white-space: nowrap;}@@ -1347,7 +1347,7 @@padding: 0.45rem 1.1rem;background: rgba(255, 255, 255, 0.04);border: 1px solid rgba(255, 255, 255, 0.12);- border-radius: 999px;+ border-radius: 6px;color: rgba(255, 255, 255, 0.65);font-size: 13px;font-weight: 500;@@ -1383,7 +1383,7 @@padding: 0.5rem 0.9rem;background: rgba(255, 255, 255, 0.04);border: 1px solid rgba(255, 215, 106, 0.2);- border-radius: 999px;+ border-radius: 6px;color: rgba(255, 255, 255, 0.8);font-size: 13px;font-weight: 500;@@ -1572,7 +1572,7 @@padding: 0.5rem 1.2rem;background: linear-gradient(135deg, #ffd76a 0%, #ff8f4d 100%);color: #1a0f08;- border-radius: 999px;+ border-radius: 6px;font-weight: 600;font-size: 0.9rem;box-shadow: 0 4px 18px -6px rgba(255, 143, 77, 0.6);@@ -1721,7 +1721,7 @@padding: 0.5rem 1.1rem;background: rgba(255, 175, 60, 0.08);border: 1px solid rgba(255, 175, 60, 0.25);- border-radius: 999px;+ border-radius: 6px;font-size: 0.85rem;color: rgba(255, 220, 150, 0.9);letter-spacing: 0.01em;@@ -1809,7 +1809,7 @@color: #1a0f08;font-size: 0.95rem;font-weight: 600;- border-radius: 999px;+ border-radius: 8px;text-decoration: none;letter-spacing: 0.005em;font-family: 'Space Grotesk', 'Inter', sans-serif;@@ -1842,7 +1842,7 @@letter-spacing: 0.005em;font-family: 'Space Grotesk', 'Inter', sans-serif;border: 1px solid rgba(255, 255, 255, 0.18);- border-radius: 999px;+ border-radius: 8px;transition: all 0.3s cubic-bezier(.2,.9,.3,1);background: rgba(255, 255, 255, 0.03);backdrop-filter: blur(8px);diff --git a/docs/avaturn-docs.md b/public/docs/avaturn.mdsimilarity index 100%rename from docs/avaturn-docs.mdrename to public/docs/avaturn.mddiff --git a/docs/how-it-works.md b/public/docs/how-it-works.mdsimilarity index 100%rename from docs/how-it-works.mdrename to public/docs/how-it-works.mddiff --git a/docs/API.md b/public/docs/js-api.mdsimilarity index 100%rename from docs/API.mdrename to public/docs/js-api.mddiff --git a/docs/your-own-layers.md b/public/docs/layers.mdsimilarity index 100%rename from docs/your-own-layers.mdrename to public/docs/layers.md