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: video create flow, dashboard topbar, video generate API updates
nirholas42c2c1623d98
diff --git a/api/avatar/video-generate.js b/api/avatar/video-generate.jsindex 0e52f767e..464b15483 100644--- a/api/avatar/video-generate.js+++ b/api/avatar/video-generate.js@@ -3,22 +3,24 @@// Submits a talking-avatar video generation job to the LongCat-Video-Avatar-1.5// Cloud Run worker. Returns immediately with a job_id for polling.//+// Free-plan users get 1 lifetime generation. Paid users are unlimited.+//// Request body (JSON):// image_url string — publicly accessible reference image (PNG/JPG)// audio_url string — publicly accessible audio file (WAV/MP3)-// prompt string? — optional text description (default: natural speech)-// avatar_id string? — three.ws avatar id; resolved to a GLB render URL-// if image_url is not supplied+// prompt string? — optional text description+// avatar_id string? — three.ws avatar id; resolved to a render URL+// when image_url is not supplied//// Response 202:// { job_id, status: "queued" }//// Errors:-// 400 invalid_request — missing required fields-// 502 worker_error — Cloud Run worker returned an error+// 400 invalid_request — missing required fields+// 402 free_trial_used — free user has already used their 1 free generation+// 502 worker_error — Cloud Run worker returned an errorimport { cors, error, json, wrap } from '../_lib/http.js';-import { env } from '../_lib/env.js';import { sql } from '../_lib/db.js';import { publicUrl } from '../_lib/r2.js';import { requireSession } from '../_lib/zauth.js';@@ -56,6 +58,22 @@ export default wrap(async (req, res) => {return error(res, 401, 'unauthorized', 'valid session required');}+ const userId = session.id ?? session.userId;++ // Check plan + usage. Free plan users get exactly 1 lifetime generation.+ const [userRow] = await sql`+ select plan from users where id = ${userId} and deleted_at is null limit 1+ `;+ if (userRow?.plan === 'free') {+ const [usageRow] = await sql`+ select count(*) as n from usage_events+ where user_id = ${userId} and kind = 'video_generate'+ `;+ if (Number(usageRow?.n) >= 1) {+ return error(res, 402, 'free_trial_used', 'You have used your 1 free video. Upgrade to generate more.');+ }+ }+const body = req.body || {};let { image_url: imageUrl, audio_url: audioUrl, avatar_id: avatarId, prompt } = body;@@ -71,12 +89,6 @@ export default wrap(async (req, res) => {if (!imageUrl) return error(res, 400, 'invalid_request', 'image_url or avatar_id is required');- const workerBody = {- image_url: imageUrl,- audio_url: audioUrl,- prompt: prompt || 'A person talking naturally.',- };-let workerRes;try {workerRes = await fetch(`${workerUrl()}/generate`, {@@ -85,7 +97,11 @@ export default wrap(async (req, res) => {'content-type': 'application/json',authorization: `Bearer ${workerKey()}`,},- body: JSON.stringify(workerBody),+ body: JSON.stringify({+ image_url: imageUrl,+ audio_url: audioUrl,+ prompt: prompt || 'A person talking naturally.',+ }),});} catch (err) {return error(res, 502, 'worker_unreachable', err?.message || 'worker request failed');@@ -97,5 +113,12 @@ export default wrap(async (req, res) => {}const result = await workerRes.json();++ // Record usage so we can enforce the free trial limit.+ await sql`+ insert into usage_events (user_id, kind, meta)+ values (${userId}, 'video_generate', ${JSON.stringify({ job_id: result.job_id })}::jsonb)+ `.catch(() => {});+return json(res, 202, { job_id: result.job_id, status: result.status });});diff --git a/pages/create/video.html b/pages/create/video.htmlnew file mode 100644index 000000000..2a97f0b55--- /dev/null+++ b/pages/create/video.html@@ -0,0 +1,553 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />+ <title>Talking avatar video · three.ws</title>+ <meta name="theme-color" content="#000000" />+ <meta name="robots" content="noindex" />+ <link rel="icon" href="/favicon.ico" />+ <link rel="apple-touch-icon" href="/pwa-192x192.png" />+ <link rel="stylesheet" href="/nav.css" />++ <style>+ :root {+ color-scheme: dark;+ --accent: #d6ff3d;+ --accent-ink: #0a0a0a;+ --bg: #05060a;+ --panel: #0f1018;+ --panel2: #13141f;+ --border: #1e1f2b;+ --text: #eee;+ --muted: #8a8d98;+ --radius: 16px;+ }+ * { box-sizing: border-box; }+ html, body { margin: 0; padding: 0; }+ body {+ font: 15px/1.55 -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;+ color: var(--text);+ background: var(--bg);+ min-height: 100vh;+ }+ body::before {+ content: '';+ position: fixed;+ inset: 0;+ z-index: -1;+ pointer-events: none;+ background:+ radial-gradient(800px 500px at 50% -100px, rgba(106,92,255,.1) 0, transparent 70%),+ radial-gradient(600px 400px at 50% 110%, rgba(214,255,61,.04) 0, transparent 70%),+ #05060a;+ }++ /* ── Page chrome ───────────────────────────────────────────── */+ :root {+ --space-xs: 0.382rem; --space-sm: 0.618rem;+ --space-md: 1rem; --space-lg: 1.618rem;+ --text-sm: 0.764rem; --text-lg: 1.236rem;+ --radius-md: 5px; --header-h: 3.5rem;+ --font-display: 'Space Grotesk','Inter',system-ui,sans-serif;+ }+ .skip-link { position:absolute; left:-9999px; top:auto; width:1px; height:1px; overflow:hidden; }+ .skip-link:focus { left:1rem; top:1rem; width:auto; height:auto; padding:.5rem 1rem; background:var(--bg); border:1px solid var(--border); border-radius:6px; z-index:9999; }++ header.site-header {+ display:flex; background:rgba(0,0,0,.8);+ backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);+ padding:0 var(--space-lg); height:var(--header-h);+ align-items:center; overflow-x:auto; overflow-y:hidden;+ white-space:nowrap; border-bottom:1px solid rgba(255,255,255,.06); z-index:10;+ }+ header.site-header h1 {+ color:#fff; font-family:var(--font-display); font-size:var(--text-lg);+ font-weight:600; margin:0; letter-spacing:-.01em;+ display:flex; align-items:center; gap:var(--space-xs); line-height:var(--header-h);+ }+ header.site-header h1>a { color:inherit; font-size:inherit; text-decoration:none; display:flex; align-items:center; gap:.5rem; }+ .wordmark-dot { width:8px; height:8px; border-radius:50%; background:linear-gradient(135deg,#a78bfa,#6366f1); box-shadow:0 0 10px rgba(139,92,246,.6); display:inline-block; }+ .nav-logo-img { width:28px; height:28px; object-fit:contain; border-radius:6px; }+ .features-nav { margin-left:auto; display:flex; gap:var(--space-md); align-items:center; }+ .features-nav a { color:rgba(255,255,255,.5); text-decoration:none; font-size:var(--text-sm); font-weight:500; padding:.35rem .7rem; border-radius:var(--radius-md); transition:color .18s,background .18s; }+ .features-nav a:hover { color:#fff; background:rgba(255,255,255,.04); }+ .nav-sign-in { border:1px solid rgba(255,255,255,.12); border-radius:var(--radius-md); }+ .nav-user { display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:20px; border:1px solid rgba(255,255,255,.1); background:rgba(255,255,255,.04); font-size:var(--text-sm); color:rgba(255,255,255,.55); max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }+ .nav-user::before { content:''; width:6px; height:6px; border-radius:50%; background:#4ade80; flex-shrink:0; }+ #btn-wallet-signin { background:none; border:1px solid rgba(255,255,255,.12); color:rgba(255,255,255,.5); font-size:var(--text-sm); font-weight:500; padding:.35rem .7rem; border-radius:var(--radius-md); cursor:pointer; transition:color .18s,background .18s,border-color .18s; font-family:inherit; }+ #btn-wallet-signin:hover { color:#fff; background:rgba(255,255,255,.04); border-color:rgba(255,255,255,.2); }++ /* ── Layout ─────────────────────────────────────────────────── */+ main {+ max-width: 1100px;+ margin: 0 auto;+ padding: 48px 24px 80px;+ }++ .page-header {+ display: flex;+ align-items: center;+ gap: 14px;+ margin-bottom: 40px;+ }+ .back-btn {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ width: 36px;+ height: 36px;+ border-radius: 10px;+ background: rgba(255,255,255,.04);+ border: 1px solid var(--border);+ color: var(--muted);+ cursor: pointer;+ text-decoration: none;+ flex-shrink: 0;+ transition: color .15s, border-color .15s;+ }+ .back-btn:hover { color: var(--text); border-color: #2c2d3d; }+ .back-btn svg { width: 18px; height: 18px; }+ .page-title { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -.01em; }+ .page-subtitle { font-size: 13px; color: var(--muted); margin: 4px 0 0; }++ /* ── Two-panel layout ───────────────────────────────────────── */+ .workspace {+ display: grid;+ grid-template-columns: 1fr 380px;+ gap: 24px;+ align-items: start;+ }++ /* ── Left: avatar preview ───────────────────────────────────── */+ .avatar-panel {+ background: var(--panel);+ border: 1.5px solid var(--border);+ border-radius: var(--radius);+ overflow: hidden;+ }+ .avatar-preview-wrap {+ position: relative;+ aspect-ratio: 4/5;+ background: radial-gradient(circle at 50% 30%, rgba(214,255,61,.05) 0, transparent 60%), rgba(255,255,255,.015);+ }+ model-viewer {+ width: 100%;+ height: 100%;+ --poster-color: transparent;+ }+ .avatar-select-bar {+ padding: 12px 16px;+ border-top: 1px solid var(--border);+ display: flex;+ align-items: center;+ gap: 8px;+ overflow-x: auto;+ scrollbar-width: none;+ }+ .avatar-select-bar::-webkit-scrollbar { display: none; }+ .avatar-thumb {+ width: 48px;+ height: 48px;+ border-radius: 10px;+ border: 2px solid var(--border);+ overflow: hidden;+ cursor: pointer;+ flex-shrink: 0;+ background: var(--panel2);+ transition: border-color .15s;+ position: relative;+ }+ .avatar-thumb.is-selected { border-color: var(--accent); }+ .avatar-thumb img { width: 100%; height: 100%; object-fit: cover; }+ .avatar-thumb-placeholder {+ width: 100%;+ height: 100%;+ display: flex;+ align-items: center;+ justify-content: center;+ color: var(--muted);+ }+ .avatar-thumb-placeholder svg { width: 20px; height: 20px; }+ .avatar-select-loading {+ color: var(--muted);+ font-size: 12px;+ padding: 4px 0;+ }++ /* ── Right: controls ────────────────────────────────────────── */+ .controls-panel {+ display: flex;+ flex-direction: column;+ gap: 20px;+ }+ .control-block {+ background: var(--panel);+ border: 1.5px solid var(--border);+ border-radius: var(--radius);+ padding: 20px;+ }+ .control-label {+ font-size: 12px;+ font-weight: 600;+ letter-spacing: .06em;+ text-transform: uppercase;+ color: var(--muted);+ margin: 0 0 12px;+ }++ /* Audio upload */+ .audio-drop {+ border: 1.5px dashed var(--border);+ border-radius: 12px;+ padding: 28px 20px;+ text-align: center;+ cursor: pointer;+ transition: border-color .2s, background .2s;+ color: var(--muted);+ font-size: 13px;+ position: relative;+ }+ .audio-drop:hover, .audio-drop.is-dragover {+ border-color: rgba(214,255,61,.4);+ background: rgba(214,255,61,.03);+ color: var(--text);+ }+ .audio-drop svg { width: 28px; height: 28px; margin-bottom: 10px; display: block; margin-left: auto; margin-right: auto; }+ .audio-drop input[type="file"] {+ position: absolute;+ inset: 0;+ opacity: 0;+ cursor: pointer;+ width: 100%;+ height: 100%;+ }+ .audio-file-name {+ display: none;+ align-items: center;+ gap: 10px;+ padding: 10px 12px;+ border-radius: 10px;+ background: rgba(255,255,255,.04);+ border: 1px solid var(--border);+ font-size: 13px;+ }+ .audio-file-name.is-visible { display: flex; }+ .audio-file-name svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }+ .audio-file-name .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .audio-file-clear {+ background: none;+ border: none;+ color: var(--muted);+ cursor: pointer;+ padding: 2px;+ border-radius: 4px;+ display: flex;+ align-items: center;+ }+ .audio-file-clear:hover { color: var(--text); }+ .audio-file-clear svg { width: 14px; height: 14px; }++ /* Prompt */+ .prompt-input {+ width: 100%;+ background: rgba(255,255,255,.04);+ border: 1px solid var(--border);+ border-radius: 10px;+ padding: 10px 12px;+ color: var(--text);+ font: inherit;+ font-size: 13px;+ resize: vertical;+ min-height: 72px;+ transition: border-color .15s;+ outline: none;+ }+ .prompt-input:focus { border-color: rgba(214,255,61,.35); }+ .prompt-input::placeholder { color: var(--muted); }++ /* Generate button */+ .generate-btn {+ width: 100%;+ padding: 13px 20px;+ border-radius: 12px;+ background: var(--accent);+ border: none;+ color: var(--accent-ink);+ font: inherit;+ font-size: 15px;+ font-weight: 700;+ cursor: pointer;+ display: flex;+ align-items: center;+ justify-content: center;+ gap: 8px;+ transition: opacity .15s, transform .12s;+ }+ .generate-btn:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }+ .generate-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }+ .generate-btn svg { width: 18px; height: 18px; }++ /* ── Progress / result ──────────────────────────────────────── */+ .result-block {+ background: var(--panel);+ border: 1.5px solid var(--border);+ border-radius: var(--radius);+ overflow: hidden;+ display: none;+ }+ .result-block.is-visible { display: block; }++ .progress-area {+ padding: 32px 24px;+ text-align: center;+ display: none;+ }+ .progress-area.is-visible { display: block; }+ .progress-spinner {+ width: 36px;+ height: 36px;+ border: 3px solid rgba(255,255,255,.08);+ border-top-color: var(--accent);+ border-radius: 50%;+ animation: spin .8s linear infinite;+ margin: 0 auto 16px;+ }+ @keyframes spin { to { transform: rotate(360deg); } }+ .progress-label { font-size: 14px; font-weight: 500; margin: 0 0 6px; }+ .progress-sublabel { font-size: 12px; color: var(--muted); margin: 0; }++ .video-area {+ display: none;+ }+ .video-area.is-visible { display: block; }+ .result-video {+ width: 100%;+ display: block;+ background: #000;+ max-height: 480px;+ }+ .video-actions {+ display: flex;+ gap: 10px;+ padding: 14px 16px;+ border-top: 1px solid var(--border);+ }+ .video-action-btn {+ flex: 1;+ padding: 9px 14px;+ border-radius: 10px;+ background: rgba(255,255,255,.05);+ border: 1px solid var(--border);+ color: var(--text);+ font: inherit;+ font-size: 13px;+ font-weight: 500;+ cursor: pointer;+ display: flex;+ align-items: center;+ justify-content: center;+ gap: 6px;+ text-decoration: none;+ transition: background .15s, border-color .15s;+ }+ .video-action-btn:hover { background: rgba(255,255,255,.09); border-color: #2c2d3d; }+ .video-action-btn svg { width: 15px; height: 15px; }++ .error-area {+ padding: 24px;+ display: none;+ text-align: center;+ }+ .error-area.is-visible { display: block; }+ .error-msg { font-size: 13px; color: #ffb3b3; margin: 0 0 14px; }+ .retry-btn {+ padding: 8px 16px;+ border-radius: 10px;+ background: rgba(255,255,255,.05);+ border: 1px solid var(--border);+ color: var(--text);+ font: inherit;+ font-size: 13px;+ cursor: pointer;+ }+ .retry-btn:hover { background: rgba(255,255,255,.09); }++ /* ── Status toast ───────────────────────────────────────────── */+ .status-toast {+ position: fixed;+ bottom: 32px;+ left: 50%;+ transform: translateX(-50%);+ padding: 11px 20px;+ border-radius: 12px;+ font-size: 13px;+ font-weight: 500;+ border: 1px solid var(--border);+ background: var(--panel);+ white-space: nowrap;+ z-index: 50;+ display: flex;+ align-items: center;+ gap: 8px;+ box-shadow: 0 8px 24px rgba(0,0,0,.5);+ }+ .status-toast.error { border-color: rgba(255,92,92,.4); color: #ffb3b3; background: #140a0a; }++ /* ── Responsive ─────────────────────────────────────────────── */+ @media (max-width: 780px) {+ main { padding: 32px 16px 60px; }+ .workspace { grid-template-columns: 1fr; }+ .avatar-preview-wrap { aspect-ratio: 1; }+ }+ </style>+ </head>+ <body>+ <a href="#main-content" class="skip-link">Skip to main content</a>+ <header>+ <div id="nav-container"></div>+ </header>+ <script src="/nav.js"></script>++ <main id="main-content">+ <div class="page-header">+ <a href="/create" class="back-btn" aria-label="Back to Create">+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>+ </a>+ <div>+ <h1 class="page-title">Talking avatar video</h1>+ <p class="page-subtitle">Pick your avatar, upload audio, and generate a lip-synced video.</p>+ </div>+ </div>++ <div class="workspace">+ <!-- Left: 3D avatar preview + selector -->+ <div class="avatar-panel">+ <div class="avatar-preview-wrap">+ <model-viewer+ id="avatar-viewer"+ src="/avatars/default.glb"+ alt="Selected avatar preview"+ auto-rotate+ auto-rotate-delay="500"+ rotation-per-second="12deg"+ interaction-prompt="none"+ disable-zoom+ disable-pan+ camera-orbit="0deg 80deg auto"+ shadow-intensity="0.4"+ exposure="0.95"+ environment-image="neutral"+ loading="eager"+ ></model-viewer>+ </div>+ <div class="avatar-select-bar" id="avatar-bar">+ <span class="avatar-select-loading" id="avatar-bar-loading">Loading avatars…</span>+ </div>+ </div>++ <!-- Right: controls -->+ <div class="controls-panel">+ <!-- Audio -->+ <div class="control-block">+ <p class="control-label">Audio file</p>+ <div class="audio-drop" id="audio-drop">+ <input type="file" accept="audio/*,.wav,.mp3,.m4a,.ogg,.flac" id="audio-input" aria-label="Upload audio file" />+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">+ <path d="M9 18V5l12-2v13"/>+ <circle cx="6" cy="18" r="3"/>+ <circle cx="18" cy="16" r="3"/>+ </svg>+ <div>Drop a WAV, MP3, or M4A here</div>+ <div style="font-size:11.5px; margin-top:5px; opacity:.6">or click to browse</div>+ </div>+ <div class="audio-file-name" id="audio-file-name">+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>+ <span class="fname" id="audio-fname"></span>+ <button class="audio-file-clear" id="audio-clear" aria-label="Remove audio">+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>+ </button>+ </div>+ </div>++ <!-- Prompt -->+ <div class="control-block">+ <p class="control-label">Scene description <span style="font-weight:400;text-transform:none;letter-spacing:0;color:var(--muted)">(optional)</span></p>+ <textarea+ class="prompt-input"+ id="prompt-input"+ placeholder="e.g. A person speaking on a stage with dramatic lighting…"+ rows="3"+ ></textarea>+ </div>++ <!-- Generate -->+ <button class="generate-btn" id="generate-btn" disabled>+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="5 3 19 12 5 21 5 3"/></svg>+ Generate video+ </button>++ <!-- Result block -->+ <div class="result-block" id="result-block">+ <!-- Progress -->+ <div class="progress-area" id="progress-area">+ <div class="progress-spinner"></div>+ <p class="progress-label" id="progress-label">Generating…</p>+ <p class="progress-sublabel">Takes 2–4 minutes on GPU. Hang tight.</p>+ </div>+ <!-- Video -->+ <div class="video-area" id="video-area">+ <video class="result-video" id="result-video" controls playsinline></video>+ <div class="video-actions">+ <a class="video-action-btn" id="download-btn" download="avatar-video.mp4">+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>+ Download+ </a>+ <button class="video-action-btn" id="new-video-btn">+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 .49-3.43"/></svg>+ New video+ </button>+ </div>+ </div>+ <!-- Error -->+ <div class="error-area" id="error-area">+ <p class="error-msg" id="error-msg">Generation failed. Please try again.</p>+ <button class="retry-btn" id="retry-btn">Try again</button>+ </div>+ </div>+ </div>+ </div>+ </main>++ <div class="status-toast" id="status-toast" role="status" aria-live="polite" aria-atomic="true" hidden></div>++ <script+ type="module"+ src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"+ ></script>+ <script type="module" src="/src/create-video.js"></script>+ <script>+ (function () {+ try {+ const raw = localStorage.getItem('3dagent:auth-hint');+ if (raw) {+ const { authed, name } = JSON.parse(raw);+ if (authed) {+ const el = document.getElementById('nav-sign-in');+ if (el) { el.textContent = 'Dashboard'; el.href = '/dashboard'; }+ const myAgents = document.getElementById('nav-my-agents');+ if (myAgents) myAgents.hidden = false;+ const userEl = document.getElementById('nav-user');+ if (userEl && name) { userEl.textContent = name; userEl.hidden = false; }+ }+ }+ } catch (_) {}+ })();+ </script>+ <script type="module">+ import { wireSigninButton } from '/src/wallet-auth.js';+ const btn = document.getElementById('btn-wallet-signin');+ if (btn) wireSigninButton(btn);+ </script>+ </body>+</html>diff --git a/pages/home-next.html b/pages/home-next.htmlindex 0b1ae40bc..99a183a24 100644--- a/pages/home-next.html+++ b/pages/home-next.html@@ -545,9 +545,14 @@</div><agent-3dclass="hero-agent"+ mode="inline"+ responsivebackground="transparent"name-plate="off"+ avatar-chat="off"+ kioskeager+ style="display:block;position:absolute;inset:56px 0 0;width:100%;height:calc(100% - 56px);"></agent-3d></div></div>diff --git a/public/dashboard/index.html b/public/dashboard/index.htmlindex 14ea5b3c3..12109f411 100644--- a/public/dashboard/index.html+++ b/public/dashboard/index.html@@ -1236,8 +1236,10 @@color: #c8bfff;"><span>- ✦ The redesigned dashboard is in preview —- <a href="/dashboard-next" style="color:#b39bff;font-weight:600;text-decoration:underline">try it now</a>+ ✦ Beta: New dashboard available —+ <button id="switch-to-next" style="background:none;border:none;color:#b39bff;font-weight:600;text-decoration:underline;cursor:pointer;padding:0;font-family:inherit;font-size:inherit">+ switch to new version+ </button></span><button onclick="document.getElementById('dn-next-banner').remove();localStorage.setItem('dn-next-dismissed','1')"style="background:none;border:none;color:#888;font-size:18px;cursor:pointer;line-height:1;padding:0 2px"@@ -1248,6 +1250,10 @@var __dnb = document.getElementById('dn-next-banner');if (__dnb) __dnb.style.display = 'none';}+ document.getElementById('switch-to-next').addEventListener('click', () => {+ localStorage.setItem('dashboard-version', 'next');+ location.href = '/dashboard-next';+ });</script><header><h1>diff --git a/public/features.json b/public/features.jsonindex 24d9672d3..d84cb210c 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-05-25T14:11:00.766Z",+ "generated_at": "2026-05-25T14:25:04.225Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/public/next/index.html b/public/next/index.htmlindex 758e36a99..90f8b4c18 100644--- a/public/next/index.html+++ b/public/next/index.html@@ -161,7 +161,7 @@pointer-events: none;}section.s {- padding: 140px 32px;+ padding: 96px 32px;max-width: 1280px; margin: 0 auto;}.s-num {@@ -308,17 +308,21 @@<div class="stage" aria-hidden="true"><model-viewerid="hero-mv"- src="https://three.ws/avatars/cz.glb"+ src="https://three.ws/animations/robotexpressive.glb"camera-controlsdisable-zoominteraction-prompt="none"- exposure="1.1"- shadow-intensity="0.8"+ exposure="1.05"+ shadow-intensity="0.9"shadow-softness="1"- camera-orbit="0deg 90deg 2.2m"- field-of-view="28deg"+ camera-orbit="15deg 82deg 4.2m"+ camera-target="0m 1m 0m"+ min-camera-orbit="auto auto 3.5m"+ max-camera-orbit="auto auto 5.5m"+ field-of-view="32deg"touch-action="pan-y"autoplay+ animation-name="Wave"></model-viewer></div>@@ -489,7 +493,7 @@var mv = document.getElementById('hero-mv');if (!mv) return;- var baseTheta = 0, baseRadius = 2.2, basePhi = 90;+ var baseTheta = 15, baseRadius = 4.2, basePhi = 82;var mouseX = 0, mouseY = 0, scrollY = 0;var raf = null;diff --git a/src/create-video.js b/src/create-video.jsnew file mode 100644index 000000000..1d005438c--- /dev/null+++ b/src/create-video.js@@ -0,0 +1,339 @@+import { apiFetch } from './account.js';++const viewer = document.getElementById('avatar-viewer');+const avatarBar = document.getElementById('avatar-bar');+const barLoading = document.getElementById('avatar-bar-loading');+const audioDrop = document.getElementById('audio-drop');+const audioInput = document.getElementById('audio-input');+const audioName = document.getElementById('audio-file-name');+const audioFname = document.getElementById('audio-fname');+const audioClear = document.getElementById('audio-clear');+const promptInput = document.getElementById('prompt-input');+const generateBtn = document.getElementById('generate-btn');+const resultBlock = document.getElementById('result-block');+const progressArea = document.getElementById('progress-area');+const progressLabel = document.getElementById('progress-label');+const videoArea = document.getElementById('video-area');+const resultVideo = document.getElementById('result-video');+const downloadBtn = document.getElementById('download-btn');+const newVideoBtn = document.getElementById('new-video-btn');+const errorArea = document.getElementById('error-area');+const errorMsg = document.getElementById('error-msg');+const retryBtn = document.getElementById('retry-btn');+const statusToast = document.getElementById('status-toast');++// ── State ──────────────────────────────────────────────────────────────────────++let selectedAvatarId = null;+let selectedGlbUrl = null;+let selectedThumbnail = null;+let audioFile = null;+let currentJobId = null;+let pollTimer = null;++// ── Boot ──────────────────────────────────────────────────────────────────────++async function boot() {+ // Auth gate — redirect to login if not signed in.+ const authRes = await fetch('/api/auth/me', { credentials: 'include' }).catch(() => null);+ if (!authRes?.ok) {+ window.location.replace(`/login?next=${encodeURIComponent('/create/video')}`);+ return;+ }+ const authData = await authRes.json().catch(() => null);+ if (!authData?.user) {+ window.location.replace(`/login?next=${encodeURIComponent('/create/video')}`);+ return;+ }++ await loadAvatars();+ wireControls();+}++// ── Avatar loading ─────────────────────────────────────────────────────────────++async function loadAvatars() {+ let avatars = [];+ try {+ const res = await apiFetch('/api/avatars');+ if (res.ok) avatars = (await res.json()) ?? [];+ } catch {+ // fall through — show default avatar only+ }++ barLoading.remove();++ if (avatars.length === 0) {+ addDefaultThumb();+ return;+ }++ for (const av of avatars) {+ addThumb(av.id, av.glb_url ?? av.storage_url, av.thumbnail_url, av.display_name || 'Avatar');+ }++ // Auto-select the first one.+ const first = avatars[0];+ selectAvatar(first.id, first.glb_url ?? first.storage_url, first.thumbnail_url);+}++function addDefaultThumb() {+ const url = '/avatars/default.glb';+ const thumb = createThumb('default', url, null, 'Default');+ avatarBar.appendChild(thumb);+ selectAvatar('default', url, null);+}++function addThumb(id, glbUrl, thumbUrl, label) {+ const el = createThumb(id, glbUrl, thumbUrl, label);+ avatarBar.appendChild(el);+}++function createThumb(id, glbUrl, thumbUrl, label) {+ const el = document.createElement('div');+ el.className = 'avatar-thumb';+ el.title = label;+ el.setAttribute('role', 'button');+ el.setAttribute('tabindex', '0');+ el.setAttribute('aria-label', `Select ${label}`);+ el.dataset.id = id;+ el.dataset.glb = glbUrl;+ el.dataset.thumb = thumbUrl || '';++ if (thumbUrl) {+ const img = document.createElement('img');+ img.src = thumbUrl;+ img.alt = label;+ el.appendChild(img);+ } else {+ el.innerHTML = `<div class="avatar-thumb-placeholder"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M4 20c0-4 3.58-7 8-7s8 3 8 7"/></svg></div>`;+ }++ el.addEventListener('click', () => selectAvatar(id, glbUrl, thumbUrl));+ el.addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); selectAvatar(id, glbUrl, thumbUrl); }+ });+ return el;+}++function selectAvatar(id, glbUrl, thumbUrl) {+ selectedAvatarId = id;+ selectedGlbUrl = glbUrl;+ selectedThumbnail = thumbUrl;++ viewer.src = glbUrl;++ document.querySelectorAll('.avatar-thumb').forEach((el) => {+ el.classList.toggle('is-selected', el.dataset.id === String(id));+ });++ updateGenerateBtn();+}++// ── Audio handling ─────────────────────────────────────────────────────────────++function wireControls() {+ audioInput.addEventListener('change', () => {+ if (audioInput.files?.[0]) setAudioFile(audioInput.files[0]);+ });++ audioDrop.addEventListener('dragover', (e) => { e.preventDefault(); audioDrop.classList.add('is-dragover'); });+ audioDrop.addEventListener('dragleave', () => audioDrop.classList.remove('is-dragover'));+ audioDrop.addEventListener('drop', (e) => {+ e.preventDefault();+ audioDrop.classList.remove('is-dragover');+ const file = e.dataTransfer?.files?.[0];+ if (file && file.type.startsWith('audio/')) setAudioFile(file);+ else showToast('Please drop an audio file (WAV, MP3, M4A…).', 'error');+ });++ audioClear.addEventListener('click', clearAudio);+ generateBtn.addEventListener('click', startGeneration);+ newVideoBtn.addEventListener('click', resetToIdle);+ retryBtn.addEventListener('click', resetToIdle);+}++function setAudioFile(file) {+ audioFile = file;+ audioFname.textContent = file.name;+ audioDrop.style.display = 'none';+ audioName.classList.add('is-visible');+ updateGenerateBtn();+}++function clearAudio() {+ audioFile = null;+ audioInput.value = '';+ audioDrop.style.display = '';+ audioName.classList.remove('is-visible');+ updateGenerateBtn();+}++function updateGenerateBtn() {+ generateBtn.disabled = !(selectedGlbUrl && audioFile);+}++// ── Generation flow ────────────────────────────────────────────────────────────++async function startGeneration() {+ if (!selectedGlbUrl || !audioFile) return;++ generateBtn.disabled = true;+ showResult('progress');+ setProgressLabel('Uploading audio…');++ let audioUrl;+ try {+ audioUrl = await uploadAudio(audioFile);+ } catch (err) {+ showResult('error', `Audio upload failed: ${err.message}`);+ generateBtn.disabled = false;+ return;+ }++ setProgressLabel('Queuing generation job…');++ let jobId;+ try {+ const res = await apiFetch('/api/avatar/video-generate', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({+ image_url: selectedThumbnail || selectedGlbUrl,+ audio_url: audioUrl,+ avatar_id: selectedAvatarId !== 'default' ? selectedAvatarId : undefined,+ prompt: promptInput.value.trim() || undefined,+ }),+ });++ if (!res.ok) {+ const e = await res.json().catch(() => ({}));+ if (res.status === 402 && e.error === 'free_trial_used') {+ showResult('error', 'You've used your 1 free video. Upgrade to generate more.');+ retryBtn.textContent = 'Upgrade plan';+ retryBtn.onclick = () => { window.location.href = '/dashboard'; };+ generateBtn.disabled = false;+ return;+ }+ throw new Error(e.error_description || `HTTP ${res.status}`);+ }++ const data = await res.json();+ jobId = data.job_id;+ currentJobId = jobId;+ } catch (err) {+ showResult('error', `Could not start generation: ${err.message}`);+ generateBtn.disabled = false;+ return;+ }++ setProgressLabel('Generating video…');+ pollTimer = setInterval(() => pollJob(jobId), 5000);+}++async function pollJob(jobId) {+ if (currentJobId !== jobId) return;++ let data;+ try {+ const res = await apiFetch(`/api/avatar/video-status?job_id=${encodeURIComponent(jobId)}`);+ if (!res.ok) return;+ data = await res.json();+ } catch {+ return;+ }++ if (data.status === 'running') {+ setProgressLabel('Rendering frames…');+ } else if (data.status === 'done' && data.video_url) {+ clearInterval(pollTimer);+ pollTimer = null;+ currentJobId = null;+ showVideo(data.video_url);+ } else if (data.status === 'failed') {+ clearInterval(pollTimer);+ pollTimer = null;+ currentJobId = null;+ showResult('error', 'Generation failed on the server. Please try again.');+ generateBtn.disabled = false;+ }+}++function showVideo(url) {+ resultVideo.src = url;+ downloadBtn.href = url;+ showResult('video');+}++function resetToIdle() {+ if (pollTimer) { clearInterval(pollTimer); pollTimer = null; }+ currentJobId = null;+ resultVideo.src = '';+ resultBlock.classList.remove('is-visible');+ progressArea.classList.remove('is-visible');+ videoArea.classList.remove('is-visible');+ errorArea.classList.remove('is-visible');+ generateBtn.disabled = !(selectedGlbUrl && audioFile);+}++// ── Audio upload ──────────────────────────────────────────────────────────────+// Uploads the audio file and returns a publicly accessible URL.+// Uses the existing presigned-upload flow via R2/S3.++async function uploadAudio(file) {+ // Get a presigned upload URL from the server.+ const presignRes = await apiFetch('/api/avatars/presign', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ filename: file.name, content_type: file.type || 'audio/mpeg', kind: 'audio' }),+ });++ if (!presignRes.ok) {+ // Fallback: convert to data URI if presign endpoint isn't available yet.+ // The LongCat worker supports downloading from data URIs via httpx.+ return await fileToDataUri(file);+ }++ const { upload_url, public_url } = await presignRes.json();++ const uploadRes = await fetch(upload_url, {+ method: 'PUT',+ headers: { 'content-type': file.type || 'audio/mpeg' },+ body: file,+ });++ if (!uploadRes.ok) throw new Error(`Upload failed: HTTP ${uploadRes.status}`);+ return public_url;+}++function fileToDataUri(file) {+ return new Promise((resolve, reject) => {+ const reader = new FileReader();+ reader.onload = () => resolve(reader.result);+ reader.onerror = () => reject(new Error('FileReader failed'));+ reader.readAsDataURL(file);+ });+}++// ── UI helpers ────────────────────────────────────────────────────────────────++function showResult(state, msg) {+ resultBlock.classList.add('is-visible');+ progressArea.classList.toggle('is-visible', state === 'progress');+ videoArea.classList.toggle('is-visible', state === 'video');+ errorArea.classList.toggle('is-visible', state === 'error');+ if (state === 'error' && msg) errorMsg.textContent = msg;+}++function setProgressLabel(text) {+ progressLabel.textContent = text;+}++function showToast(msg, type = 'info') {+ statusToast.textContent = msg;+ statusToast.className = `status-toast ${type}`;+ statusToast.hidden = false;+ setTimeout(() => { statusToast.hidden = true; }, 4000);+}++boot();diff --git a/src/create.js b/src/create.jsindex 35f168c3e..1fe39b251 100644--- a/src/create.js+++ b/src/create.js@@ -110,7 +110,7 @@ async function boot() {if (await isAtAvatarLimit()) return;window.location.href = '/create/selfie';});- wireCard('card-video-avatar', async () => {+ wireCard('card-video-avatar', () => {if (!_videoAvatarReady) {showStatus('Talking avatar video is coming soon — stay tuned.', 'info');return;@@ -119,19 +119,6 @@ async function boot() {window.location.replace(`/login?next=${encodeURIComponent('/create/video')}`);return;}- // Gate on paid plan — free users see an upgrade prompt.- try {- const res = await apiFetch('/api/usage/summary');- if (res.ok) {- const { plan } = await res.json();- if (plan?.plan === 'free') {- showStatus('Talking avatar video requires a paid plan. Upgrade in your dashboard.', 'error');- return;- }- }- } catch {- // network blip — let the destination page do the final auth check.- }window.location.href = '/create/video';});wireCard('card-upload-glb', (e) => {diff --git a/src/dashboard-next/components/topbar.js b/src/dashboard-next/components/topbar.jsindex 61fb6fed1..ed587758f 100644--- a/src/dashboard-next/components/topbar.js+++ b/src/dashboard-next/components/topbar.js@@ -40,6 +40,9 @@ export function renderTopbar(pathname) {<button type="button" class="dn-topbar-btn" data-action="toggle-drawer" aria-label="Toggle activity drawer" aria-pressed="false"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2M3.2 3.2l1.4 1.4M11.4 11.4l1.4 1.4M3.2 12.8l1.4-1.4M11.4 4.6l1.4-1.4"/></svg></button>+ <button type="button" class="dn-topbar-btn" data-action="back-to-classic" aria-label="Return to classic dashboard" title="Return to classic dashboard" style="font-size:11px;font-weight:600;opacity:0.7">+ ↶ Classic+ </button><div class="dn-topbar-user" data-action="toggle-user-menu" data-component="topbar-user" aria-haspopup="true"><div class="dn-topbar-user-avatar" data-slot="initials">··</div><span data-slot="label">Loading…</span>@@ -68,6 +71,12 @@ export function mountTopbarBehavior(shellEl) {catch { /* private mode */ }return;}+ if (e.target.closest?.('[data-action="back-to-classic"]')) {+ localStorage.removeItem('dashboard-version');+ const path = location.pathname.replace(/^\/dashboard-next/, '/dashboard');+ location.href = path || '/dashboard';+ return;+ }if (e.target.closest?.('[data-action="toggle-notifs"]')) {const btn = e.target.closest('[data-action="toggle-notifs"]');toggleNotifsDropdown(btn);diff --git a/vercel.json b/vercel.jsonindex 50527215c..bf2f160eb 100644--- a/vercel.json+++ b/vercel.json@@ -1894,6 +1894,10 @@"src": "/import/rpm/","dest": "/import-rpm.html"},+ {+ "src": "/create/video/?",+ "dest": "/create/video.html"+ },{"src": "/create/selfie","dest": "/create-selfie.html"