Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: avatar studio page, review features overhaul, walk/hero/dashboard updates

nirholas7ef711ba38e0
diff --git a/pages/avatar-studio.html b/pages/avatar-studio.html
new file mode 100644
index 000000000..f5fa64e0a
--- /dev/null
+++ b/pages/avatar-studio.html
@@ -0,0 +1,793 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <title>Avatar Studio · three.ws</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="theme-color" content="#000000" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <meta name="description" content="Build a custom 3D avatar from scratch. Choose body type, sculpt face and body, add outfits and accessories — no selfie required." />
+ <meta property="og:type" content="website" />
+ <meta property="og:site_name" content="three.ws" />
+ <meta property="og:url" content="https://three.ws/create/studio" />
+ <meta property="og:title" content="Avatar Studio · three.ws" />
+ <meta property="og:description" content="Build a custom 3D avatar from scratch. Choose body type, sculpt face and body, add outfits and accessories." />
+ <meta property="og:image" content="https://three.ws/assets/og-image.png" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/fonts/fonts.css" />
+ <link rel="stylesheet" href="/mobile.css" />
+
+ <style>
+ :root {
+ --bg: #0a0a0a;
+ --panel: #111;
+ --panel-2: #161616;
+ --border: #1f1f1f;
+ --border-2: #2a2a2a;
+ --text: #fafafa;
+ --text-2: #a1a1aa;
+ --text-3: #71717a;
+ --accent: #d6ff3d;
+ --accent-dim: rgba(214, 255, 61, 0.12);
+ --accent-ink: #0a0a0a;
+ --success: #34d399;
+ --danger: #f43f5e;
+ --radius: 14px;
+ }
+ html, body {
+ margin: 0;
+ background: var(--bg);
+ color: var(--text);
+ font-family: 'Inter', system-ui, sans-serif;
+ -webkit-font-smoothing: antialiased;
+ }
+ body {
+ display: flex;
+ flex-direction: column;
+ min-height: 100vh;
+ }
+
+ /* ── Top bar ──────────────────────────────────────────── */
+ .as-bar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ padding: 12px 24px;
+ border-bottom: 1px solid var(--border);
+ background: rgba(10, 10, 10, 0.85);
+ backdrop-filter: blur(8px);
+ position: sticky;
+ top: 0;
+ z-index: 20;
+ }
+ .as-back {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ color: var(--text-2);
+ text-decoration: none;
+ font-size: 13px;
+ }
+ .as-back:hover { color: var(--text); }
+ .as-bar-title {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 14px;
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ color: var(--text);
+ text-align: center;
+ flex: 1;
+ }
+ .as-actions { display: flex; gap: 8px; }
+ .as-btn {
+ background: transparent;
+ border: 1px solid var(--border-2);
+ color: var(--text-2);
+ padding: 7px 14px;
+ border-radius: 8px;
+ cursor: pointer;
+ font-size: 13px;
+ font-family: inherit;
+ font-weight: 500;
+ transition: color 0.15s, border-color 0.15s, background 0.15s;
+ }
+ .as-btn:hover { color: var(--text); border-color: var(--text-3); }
+ .as-btn[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }
+ .as-btn.primary {
+ background: var(--accent);
+ color: var(--accent-ink);
+ border-color: var(--accent);
+ font-weight: 600;
+ }
+ .as-btn.primary:hover { filter: brightness(1.06); }
+ .as-btn.primary[disabled] { filter: none; opacity: 0.4; }
+
+ /* ── Main layout ──────────────────────────────────────── */
+ .as-shell {
+ display: grid;
+ grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
+ flex: 1;
+ min-height: 0;
+ }
+ .as-stage {
+ border-right: 1px solid var(--border);
+ background:
+ radial-gradient(ellipse at 50% 35%, rgba(214, 255, 61, 0.04), transparent 60%),
+ radial-gradient(ellipse at 70% 80%, rgba(167, 139, 250, 0.03), transparent 50%),
+ var(--bg);
+ position: relative;
+ min-height: 500px;
+ }
+ .as-stage-loading {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: var(--text-3);
+ font-size: 13px;
+ pointer-events: none;
+ }
+
+ .as-side {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ }
+
+ /* ── Body type selector ───────────────────────────────── */
+ .as-body-type {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 12px 16px;
+ border-bottom: 1px solid var(--border);
+ background: var(--panel);
+ }
+ .as-body-label {
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ color: var(--text-3);
+ font-weight: 600;
+ }
+ .as-body-toggle {
+ display: inline-flex;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ border-radius: 8px;
+ padding: 2px;
+ gap: 2px;
+ }
+ .as-body-toggle button {
+ background: transparent;
+ border: none;
+ color: var(--text-3);
+ font: 600 12px/1 inherit;
+ padding: 7px 14px;
+ border-radius: 6px;
+ cursor: pointer;
+ transition: color 0.12s, background 0.12s;
+ }
+ .as-body-toggle button[aria-pressed="true"] {
+ background: rgba(214, 255, 61, 0.12);
+ color: var(--text);
+ }
+ .as-body-toggle button:hover { color: var(--text); }
+
+ /* ── Name input ───────────────────────────────────────── */
+ .as-name-row {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 12px 16px;
+ border-bottom: 1px solid var(--border);
+ background: var(--panel);
+ }
+ .as-name-input {
+ flex: 1;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ border-radius: 8px;
+ color: var(--text);
+ padding: 8px 12px;
+ font-size: 13px;
+ font-family: inherit;
+ outline: none;
+ transition: border-color 0.15s;
+ }
+ .as-name-input:focus { border-color: var(--accent); }
+ .as-name-input::placeholder { color: var(--text-3); }
+
+ /* ── Tabs ─────────────────────────────────────────────── */
+ .as-tabs {
+ display: flex;
+ border-bottom: 1px solid var(--border);
+ background: var(--panel);
+ padding: 0 8px;
+ overflow-x: auto;
+ }
+ .as-tab {
+ background: transparent;
+ border: 0;
+ color: var(--text-3);
+ padding: 12px 14px;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ font-family: inherit;
+ border-bottom: 2px solid transparent;
+ transition: color 0.15s, border-color 0.15s;
+ white-space: nowrap;
+ }
+ .as-tab:hover { color: var(--text-2); }
+ .as-tab.active { color: var(--text); border-color: var(--accent); }
+
+ /* ── Chips ────────────────────────────────────────────── */
+ .as-chips {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 10px 16px;
+ border-bottom: 1px solid var(--border);
+ background: var(--panel);
+ min-height: 44px;
+ overflow-x: auto;
+ white-space: nowrap;
+ }
+ .as-chips:empty::before {
+ content: 'Nothing on yet. Pick something below.';
+ color: var(--text-3);
+ font-size: 12px;
+ }
+ .as-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ border-radius: 999px;
+ padding: 4px 6px 4px 10px;
+ font-size: 12px;
+ color: var(--text);
+ white-space: nowrap;
+ font-family: inherit;
+ }
+ .as-chip .as-chip-kind {
+ color: var(--text-3);
+ font-size: 10px;
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ }
+ .as-chip button {
+ background: transparent;
+ border: 0;
+ color: var(--text-3);
+ cursor: pointer;
+ font-size: 14px;
+ line-height: 1;
+ padding: 2px 6px;
+ border-radius: 999px;
+ font-family: inherit;
+ }
+ .as-chip button:hover { color: var(--danger); background: rgba(244, 63, 94, 0.08); }
+
+ /* ── Panel (tile grid + sculpt) ────────────────────────── */
+ .as-panel {
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+ padding: 16px;
+ }
+ .as-search-wrap {
+ position: sticky;
+ top: -16px;
+ margin: -16px -16px 12px;
+ padding: 12px 16px;
+ background: var(--bg);
+ border-bottom: 1px solid var(--border);
+ z-index: 2;
+ }
+ .as-search {
+ width: 100%;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ border-radius: 8px;
+ color: var(--text);
+ padding: 8px 12px;
+ font-size: 13px;
+ font-family: inherit;
+ outline: none;
+ transition: border-color 0.15s;
+ }
+ .as-search:focus { border-color: var(--accent); }
+ .as-search::placeholder { color: var(--text-3); }
+ .as-empty {
+ color: var(--text-3);
+ font-size: 13px;
+ padding: 24px 4px;
+ text-align: center;
+ }
+ .as-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
+ gap: 10px;
+ }
+ .as-tile {
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 10px 10px 8px;
+ cursor: pointer;
+ transition: border-color 0.15s, transform 0.15s, background 0.15s;
+ color: inherit;
+ text-align: left;
+ font-family: inherit;
+ }
+ .as-tile:hover {
+ border-color: var(--accent);
+ transform: translateY(-1px);
+ background: rgba(214, 255, 61, 0.03);
+ }
+ .as-tile.selected {
+ border-color: var(--accent);
+ background: rgba(214, 255, 61, 0.05);
+ }
+ .as-tile.previewing {
+ border-color: #a78bfa;
+ box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35);
+ }
+ .as-tile-preview {
+ aspect-ratio: 1 / 1;
+ border-radius: 8px;
+ background:
+ radial-gradient(ellipse at center, rgba(255,255,255,0.05), transparent 70%),
+ var(--panel-2);
+ margin-bottom: 8px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 36px;
+ overflow: hidden;
+ position: relative;
+ }
+ .as-tile-preview img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ display: block;
+ }
+ .as-tile-name {
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--text);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .as-tile-kind {
+ font-size: 10px;
+ color: var(--text-3);
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ margin-top: 1px;
+ }
+ .as-tile-none {
+ background: transparent;
+ border-style: dashed;
+ }
+
+ /* ── Status bar ────────────────────────────────────────── */
+ .as-status {
+ padding: 10px 16px;
+ border-top: 1px solid var(--border);
+ background: var(--panel);
+ font-size: 12px;
+ color: var(--text-3);
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-height: 36px;
+ }
+ .as-status.ok { color: var(--success); }
+ .as-status.err { color: var(--danger); }
+ .as-status .spin {
+ width: 11px; height: 11px;
+ border-radius: 50%;
+ border: 2px solid rgba(255,255,255,0.2);
+ border-top-color: var(--accent);
+ animation: as-spin 0.9s linear infinite;
+ }
+ @keyframes as-spin { to { transform: rotate(360deg); } }
+
+ .as-error {
+ padding: 80px 24px;
+ text-align: center;
+ color: var(--text-3);
+ font-size: 14px;
+ }
+
+ @media (max-width: 980px) {
+ .as-shell { grid-template-columns: 1fr; }
+ .as-stage { border-right: 0; border-bottom: 1px solid var(--border); min-height: 380px; }
+ }
+
+ /* ── Reuse avatar-edit sculpt styles ─────────────────── */
+ .ae-sculpt-head {
+ display: flex;
+ gap: 8px;
+ margin-bottom: 10px;
+ }
+ .ae-sculpt-capture {
+ flex: 1;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ }
+ .ae-sculpt-capture-icon { font-size: 14px; line-height: 1; }
+ .ae-sculpt-note {
+ font-size: 12px;
+ color: var(--text-3);
+ line-height: 1.55;
+ margin: 0 0 14px;
+ }
+ .ae-sculpt-mirror {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ margin: 0 0 8px;
+ padding: 6px 10px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: var(--panel);
+ cursor: pointer;
+ font-size: 12px;
+ color: var(--text-2);
+ user-select: none;
+ }
+ .ae-sculpt-mirror input { accent-color: var(--accent); }
+ .ae-sculpt-mirror:hover { color: var(--text); border-color: var(--border-2); }
+ .ae-sculpt-group {
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ background: var(--panel);
+ margin-bottom: 8px;
+ overflow: hidden;
+ }
+ .ae-sculpt-group summary {
+ list-style: none;
+ cursor: pointer;
+ padding: 10px 14px;
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--text);
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ transition: background 0.12s;
+ user-select: none;
+ }
+ .ae-sculpt-group summary::-webkit-details-marker { display: none; }
+ .ae-sculpt-group summary::before {
+ content: '\25B8';
+ color: var(--text-3);
+ font-size: 11px;
+ margin-right: 8px;
+ display: inline-block;
+ transition: transform 0.18s;
+ }
+ .ae-sculpt-group[open] summary::before { transform: rotate(90deg); }
+ .ae-sculpt-group summary:hover { background: var(--panel-2); }
+ .ae-sculpt-count {
+ font-size: 10px;
+ color: var(--text-3);
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ padding: 2px 7px;
+ border-radius: 999px;
+ margin-left: auto;
+ }
+ .ae-sculpt-rows {
+ padding: 6px 14px 14px;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ border-top: 1px solid var(--border);
+ background: rgba(0, 0, 0, 0.2);
+ }
+ .ae-sculpt-row {
+ display: grid;
+ grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr) 36px;
+ align-items: center;
+ gap: 10px;
+ padding: 6px 0;
+ }
+ .ae-sculpt-label {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+ }
+ .ae-sculpt-name {
+ font-size: 12px;
+ color: var(--text);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ .ae-sculpt-meta {
+ font-size: 9px;
+ color: var(--text-3);
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ }
+ .ae-sculpt-row input[type='range'] {
+ appearance: none;
+ -webkit-appearance: none;
+ width: 100%;
+ background: transparent;
+ height: 16px;
+ cursor: pointer;
+ }
+ .ae-sculpt-row input[type='range']::-webkit-slider-runnable-track {
+ height: 4px;
+ border-radius: 999px;
+ background: var(--border-2);
+ }
+ .ae-sculpt-row input[type='range']::-moz-range-track {
+ height: 4px;
+ border-radius: 999px;
+ background: var(--border-2);
+ }
+ .ae-sculpt-row input[type='range']::-webkit-slider-thumb {
+ appearance: none;
+ -webkit-appearance: none;
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background: var(--accent);
+ margin-top: -5px;
+ border: 0;
+ box-shadow: 0 0 0 2px rgba(214, 255, 61, 0.18);
+ cursor: pointer;
+ }
+ .ae-sculpt-row input[type='range']::-moz-range-thumb {
+ width: 14px;
+ height: 14px;
+ border-radius: 50%;
+ background: var(--accent);
+ border: 0;
+ cursor: pointer;
+ }
+ .ae-sculpt-value {
+ font-family: ui-monospace, 'SF Mono', monospace;
+ font-size: 11px;
+ color: var(--text-3);
+ text-align: right;
+ font-variant-numeric: tabular-nums;
+ }
+
+ /* ── Blend wheel ──────────────────────────────────────── */
+ .ae-blend-group > .ae-blend-body {
+ padding: 16px 14px 14px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 10px;
+ }
+ .ae-blend-canvas {
+ position: relative;
+ width: 220px;
+ height: 220px;
+ border: 1px solid var(--border-2);
+ border-radius: 50%;
+ background: radial-gradient(circle at 50% 50%, rgba(214, 255, 61, 0.03) 0%, rgba(255,255,255,0.015) 60%, transparent 100%);
+ cursor: crosshair;
+ flex-shrink: 0;
+ outline: none;
+ }
+ .ae-blend-canvas::before, .ae-blend-canvas::after {
+ content: '';
+ position: absolute;
+ background: rgba(255, 255, 255, 0.07);
+ pointer-events: none;
+ }
+ .ae-blend-canvas::before { left: 0; right: 0; top: 50%; height: 1px; transform: translateY(-50%); }
+ .ae-blend-canvas::after { top: 0; bottom: 0; left: 50%; width: 1px; transform: translateX(-50%); }
+ .ae-blend-canvas:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
+ .ae-blend-label {
+ position: absolute;
+ transform: translate(-50%, -50%);
+ font-size: 9px;
+ font-weight: 600;
+ color: rgba(255, 255, 255, 0.45);
+ letter-spacing: 0.07em;
+ text-transform: uppercase;
+ white-space: nowrap;
+ pointer-events: none;
+ user-select: none;
+ }
+ .ae-blend-puck {
+ position: absolute;
+ left: 50%; top: 50%;
+ width: 20px; height: 20px;
+ border-radius: 50%;
+ background: var(--accent);
+ box-shadow: 0 0 0 3px rgba(214, 255, 61, 0.25), 0 2px 8px rgba(0,0,0,0.5);
+ transform: translate(-50%, -50%);
+ cursor: grab;
+ touch-action: none;
+ z-index: 2;
+ transition: box-shadow 0.12s;
+ }
+ .ae-blend-puck:active { cursor: grabbing; box-shadow: 0 0 0 5px rgba(214, 255, 61, 0.35), 0 3px 12px rgba(0,0,0,0.6); }
+ .ae-blend-desc {
+ font-size: 11px;
+ color: var(--text-3);
+ text-align: center;
+ margin: 0;
+ min-height: 16px;
+ }
+
+ /* ── Face capture modal ─────────────────────────────── */
+ .ae-face-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 200;
+ background: rgba(0, 0, 0, 0.72);
+ backdrop-filter: blur(8px);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 20px;
+ animation: asFaceFade 0.18s ease-out;
+ }
+ @keyframes asFaceFade { from { opacity: 0 } to { opacity: 1 } }
+ .ae-face-dialog {
+ background: var(--panel);
+ border: 1.5px solid var(--border-2);
+ border-radius: 14px;
+ width: 100%;
+ max-width: 520px;
+ max-height: calc(100vh - 40px);
+ overflow-y: auto;
+ padding: 24px;
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
+ font-family: inherit;
+ }
+ .ae-face-dialog h3 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
+ .ae-face-lede { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
+ .ae-face-close {
+ position: absolute;
+ top: 12px; right: 12px;
+ background: var(--panel-2);
+ border: 1px solid var(--border-2);
+ color: var(--text-2);
+ width: 28px; height: 28px;
+ border-radius: 999px;
+ cursor: pointer;
+ font: inherit;
+ font-size: 13px;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .ae-face-close:hover { color: var(--text); border-color: var(--text-3); }
+ .ae-face-stage {
+ position: relative;
+ aspect-ratio: 1 / 1;
+ background: #000;
+ border: 1px solid var(--border-2);
+ border-radius: 10px;
+ overflow: hidden;
+ }
+ .ae-face-stage video {
+ width: 100%; height: 100%;
+ object-fit: cover;
+ transform: scaleX(-1);
+ display: block;
+ }
+ .ae-face-status {
+ position: absolute;
+ left: 0; right: 0; bottom: 0;
+ padding: 8px 12px;
+ font-size: 12px;
+ color: rgba(255,255,255,0.85);
+ background: linear-gradient(180deg, transparent, rgba(0,0,0,0.7));
+ text-align: center;
+ }
+ .ae-face-actions {
+ display: flex;
+ gap: 8px;
+ justify-content: flex-end;
+ }
+
+ /* ── Save overlay ─────────────────────────────────────── */
+ .as-save-overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 300;
+ background: rgba(0, 0, 0, 0.85);
+ backdrop-filter: blur(12px);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 16px;
+ }
+ .as-save-overlay .spin-lg {
+ width: 40px; height: 40px;
+ border-radius: 50%;
+ border: 3px solid rgba(255,255,255,0.12);
+ border-top-color: var(--accent);
+ animation: as-spin 0.8s linear infinite;
+ }
+ .as-save-label {
+ font-size: 15px;
+ font-weight: 500;
+ color: var(--text);
+ }
+ .as-save-sublabel {
+ font-size: 12px;
+ color: var(--text-3);
+ margin-top: -8px;
+ }
+ .as-progress-bar {
+ width: 260px;
+ height: 4px;
+ border-radius: 999px;
+ background: var(--border-2);
+ overflow: hidden;
+ }
+ .as-progress-fill {
+ height: 100%;
+ border-radius: 999px;
+ background: var(--accent);
+ transition: width 0.3s ease;
+ width: 0%;
+ }
+ </style>
+ </head>
+ <body>
+ <header class="as-bar">
+ <a class="as-back" id="as-back" href="/create">
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
+ Back
+ </a>
+ <div class="as-bar-title">Avatar Studio</div>
+ <div class="as-actions">
+ <button class="as-btn" id="as-reset" type="button">Reset</button>
+ <button class="as-btn primary" id="as-save" type="button">Save avatar</button>
+ </div>
+ </header>
+ <main class="as-shell" id="as-shell">
+ <div class="as-stage" id="as-stage">
+ <div class="as-stage-loading" id="as-loading">Loading avatar...</div>
+ </div>
+ <aside class="as-side">
+ <div class="as-name-row">
+ <input class="as-name-input" id="as-name" type="text" placeholder="Name your avatar" maxlength="60" autocomplete="off" aria-label="Avatar name" />
+ </div>
+ <div class="as-body-type">
+ <span class="as-body-label">Body</span>
+ <div class="as-body-toggle" role="group" aria-label="Body type">
+ <button type="button" data-body="male" aria-pressed="true">Masculine</button>
+ <button type="button" data-body="female" aria-pressed="false">Feminine</button>
+ </div>
+ </div>
+ <nav class="as-tabs" id="as-tabs" role="tablist"></nav>
+ <div class="as-chips" id="as-chips" aria-label="Current outfit"></div>
+ <div class="as-panel" id="as-panel"></div>
+ <div class="as-status" id="as-status">Choose a style below to get started.</div>
+ </aside>
+ </main>
+ <script src="/src/avatar-studio.js" type="module"></script>
+ </body>
+</html>
diff --git a/pages/create-review.html b/pages/create-review.html
index 51be47172..eb7042e9a 100644
--- a/pages/create-review.html
+++ b/pages/create-review.html
@@ -48,7 +48,6 @@
.topbar {
display: flex;
align-items: center;
- gap: 14px;
margin-bottom: 20px;
}
.back-link {
@@ -58,16 +57,22 @@
background: var(--panel);
border: 1px solid var(--border);
color: var(--muted);
- padding: 8px 14px 8px 10px;
+ padding: 10px 16px 10px 12px;
border-radius: 9px;
font-size: 13px;
font-weight: 500;
text-decoration: none;
cursor: pointer;
- transition: border-color 120ms, color 120ms;
+ transition: border-color 150ms, color 150ms, background 150ms;
+ -webkit-tap-highlight-color: transparent;
+ }
+ .back-link:hover {
+ border-color: #2a2c3a;
+ color: var(--text);
+ background: #13141d;
}
- .back-link:hover { border-color: var(--border-strong, #2a2c3a); color: var(--text); }
- .back-link svg { flex-shrink: 0; }
+ .back-link:active { transform: scale(0.97); }
+ .back-link svg { flex-shrink: 0; display: block; }
main.stage {
flex: 1;
@@ -102,6 +107,12 @@
native rather than "desktop dialog squashed onto a phone". */
@media (max-width: 560px) {
main.stage { padding: 12px 14px 60px; }
+ .topbar { margin-bottom: 14px; }
+ .back-link {
+ padding: 11px 16px 11px 12px;
+ font-size: 14px;
+ border-radius: 10px;
+ }
h1 { font-size: 22px; }
.sub { margin-bottom: 18px; font-size: 14px; }
.viewer { min-height: 360px; aspect-ratio: 3 / 4; }
@@ -1209,7 +1220,7 @@
<main class="stage" id="main">
<div class="topbar">
- <a href="/create/selfie" class="back-link" id="back-link" aria-label="Back to create">
+ <a href="/create" class="back-link" id="back-link" aria-label="Back to create">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<line x1="19" y1="12" x2="5" y2="12" />
<polyline points="12 19 5 12 12 5" />
diff --git a/pages/walk.html b/pages/walk.html
index a3b79b876..2a7c5f91e 100644
--- a/pages/walk.html
+++ b/pages/walk.html
@@ -448,54 +448,74 @@
animation: walk-rec-pulse 0.9s infinite;
}
</style>
+ <link rel="stylesheet" href="/nav.css" />
</head>
<body>
+ <header class="walk-site-header" id="walk-header">
+ <h1 class="site-header-brand">
+ <a href="/" aria-label="three.ws home">
+ <img class="wordmark-logo" src="/three.svg" alt="" aria-hidden="true" /><span class="wordmark-dot" aria-hidden="true"></span>three.ws
+ </a>
+ </h1>
+ <div id="nav-container"></div>
+ </header>
+ <script src="/nav.js"></script>
+
+ <!-- Loading overlay -->
+ <div id="walk-loading" class="walk-loading">
+ <div class="walk-loading-inner">
+ <div class="walk-loading-spinner"></div>
+ <p class="walk-loading-text" id="walk-loading-text">Loading avatar...</p>
+ </div>
+ </div>
+
<div id="walk-stage">
<video id="walk-camera-feed" autoplay playsinline muted></video>
<canvas id="walk-canvas"></canvas>
<div id="walk-hud">
- <div class="walk-card">
- <h1>three.ws · walk</h1>
+ <div class="walk-card" id="walk-identity-card">
+ <div class="walk-identity-row">
+ <input type="text" id="walk-name-input" class="walk-name-input"
+ placeholder="your name" maxlength="24" autocomplete="off" spellcheck="false"
+ aria-label="Your display name" />
+ </div>
<p>Drag to orbit. Joystick or <kbd>WASD</kbd> to move.</p>
</div>
<div class="walk-actions">
- <button
- type="button"
- id="walk-online"
- data-status="idle"
- title="Multiplayer presence"
- >
+ <button type="button" id="walk-online" data-status="idle" title="Players online">
<span class="dot"></span>
<span data-label>solo</span>
<span class="count" id="walk-online-count">1</span>
</button>
- <button
- type="button"
- class="walk-btn"
- id="walk-ar-toggle"
- aria-pressed="false"
- title="Put your avatar on your real floor"
- >
+ <button type="button" class="walk-btn" id="walk-ar-toggle"
+ aria-pressed="false" title="Put your avatar on your real floor">
<span class="dot"></span>
<span data-label>AR</span>
</button>
- <button
- type="button"
- class="walk-btn"
- id="walk-record-btn"
- data-recording="false"
- title="Record a 6-second clip to share"
- >
+ <button type="button" class="walk-btn" id="walk-record-btn"
+ data-recording="false" title="Record a 6-second clip to share">
<span class="dot"></span>
<span data-label>Record</span>
</button>
- <a class="walk-btn" href="/" title="Back to three.ws home" style="text-decoration:none">
- <span>← home</span>
- </a>
+ <button type="button" class="walk-btn" id="walk-help-toggle" title="Show controls">
+ <span>?</span>
+ </button>
</div>
</div>
+ <!-- Player list panel -->
+ <div id="walk-players-panel" class="walk-players-panel" hidden>
+ <div class="walk-players-header">
+ <span>Players</span>
+ <button type="button" id="walk-players-close" aria-label="Close">&times;</button>
+ </div>
+ <ul id="walk-players-list" class="walk-players-list"></ul>
+ </div>
+
+ <!-- Emote tray -->
+ <div id="walk-emote-tray" class="walk-emote-tray" hidden></div>
+
<button type="button" id="walk-ar-cta" aria-hidden="true">
<span class="pulse"></span>
<span>See your avatar on your floor — tap for AR</span>
@@ -512,6 +532,8 @@
<div id="walk-help" aria-hidden="true">
<span class="walk-key"><kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> move</span>
<span class="walk-key"><kbd>shift</kbd> run</span>
+ <span class="walk-key"><kbd>space</kbd> jump</span>
+ <span class="walk-key"><kbd>Q</kbd><kbd>E</kbd> snap turn</span>
<span class="walk-key"><kbd>drag</kbd> orbit camera</span>
</div>
diff --git a/public/app-next.css b/public/app-next.css
index 5bf50432c..697dfd717 100644
--- a/public/app-next.css
+++ b/public/app-next.css
@@ -184,8 +184,9 @@ body.app-next-body {
.nxt-more-menu {
position: fixed;
top: var(--nxt-header-h);
- right: 0;
+ right: 12px;
min-width: 200px;
+ max-width: calc(100vw - 24px);
padding: 6px;
background: var(--nxt-glass-strong);
border: 1px solid var(--nxt-stroke);
@@ -1452,6 +1453,8 @@ body.app-next-body.nxt-chat-active .nxt-chat-dock {
@media (max-width: 640px) {
.nxt-brand-tag { display: none; }
.nxt-more { padding: 7px 8px; }
+ .nxt-more-menu a,
+ .nxt-more-menu button { padding: 12px 14px; font-size: 15px; min-height: 44px; }
.nxt-action kbd { display: none; }
.nxt-action { padding: 7px 10px; font-size: 12px; }
.nxt-action span { display: none; }
diff --git a/src/app-next-overlay.js b/src/app-next-overlay.js
index 7acceb2f0..a8793296e 100644
--- a/src/app-next-overlay.js
+++ b/src/app-next-overlay.js
@@ -618,8 +618,14 @@ function wireExploreMenu() {
const positionMenu = () => {
const r = btn.getBoundingClientRect();
+ const rightOffset = window.innerWidth - r.right;
+ const minEdge = 12;
menu.style.top = `${r.bottom + 6}px`;
- menu.style.right = `${window.innerWidth - r.right}px`;
+ menu.style.right = `${Math.max(minEdge, rightOffset)}px`;
+ menu.style.left = '';
+ if (rightOffset < minEdge) {
+ menu.style.right = `${minEdge}px`;
+ }
};
const close = () => {
@@ -647,6 +653,10 @@ function wireExploreMenu() {
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && !menu.hidden) close();
});
+
+ window.addEventListener('resize', () => {
+ if (!menu.hidden) close();
+ });
}
function wireUserMenu() {
diff --git a/src/create-review-features.js b/src/create-review-features.js
index b62be3dc4..496e2a288 100644
--- a/src/create-review-features.js
+++ b/src/create-review-features.js
@@ -330,35 +330,37 @@ export function openPaidSkillsModal(ctx = {}) {
const handle = slugify(ctx.name) || 'your-agent';
const endpoint = `https://three.ws/api/agent/${handle}/ask`;
const snippets = {
- curl: `# 1. Make the request — server replies 402 with payment terms
+ fetch: `import { withX402 } from '@three.ws/x402-fetch';
+
+const fetchPaid = withX402(fetch, {
+ wallet,
+ network: 'solana',
+});
+
+const res = await fetchPaid('${endpoint}', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ message: 'hello' }),
+});
+
+const { reply, tx } = await res.json();`,
+ curl: `# 1. Hit the endpoint — server quotes a price
curl -sS -X POST ${endpoint} \\
-H 'content-type: application/json' \\
-d '{"message":"hello"}'
-# → HTTP/1.1 402 Payment Required
-# → {"accepts":[{"network":"solana","asset":"USDC",
-# → "amount":"0.05","payTo":"<agent·wallet>"}]}
+# HTTP/1.1 402 Payment Required
+# {"accepts":[{"network":"solana","asset":"USDC",
+# "amount":"0.05","payTo":"<agent-wallet>"}]}
-# 2. Sign a USDC transfer for the quoted amount, retry with X-PAYMENT
+# 2. Sign a USDC transfer, retry with X-PAYMENT
curl -sS -X POST ${endpoint} \\
-H 'content-type: application/json' \\
-H 'x-payment: <base64-signed-payload>' \\
-d '{"message":"hello"}'
-# → HTTP/1.1 200 OK
-# → {"reply":"Hi! How can I help?","tx":"<solana·tx·sig>"}`,
- fetch: `import { withX402 } from '@three.ws/x402-fetch';
-
-// withX402 wraps fetch — intercepts 402, signs USDC, retries.
-const fetchPaid = withX402(fetch, { wallet, network: 'solana' });
-
-const res = await fetchPaid('${endpoint}', {
- method: 'POST',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({ message: 'hello' }),
-});
-
-console.log(await res.json()); // { reply, tx }`,
+# HTTP/1.1 200 OK
+# {"reply":"Hi! How can I help?","tx":"<solana-tx-sig>"}`,
python: `from three_ws import X402Client
client = X402Client(wallet=wallet, network="solana")
@@ -367,62 +369,84 @@ reply = client.post(
"${endpoint}",
json={"message": "hello"},
)
-print(reply.json()) # {"reply": "...", "tx": "<sig>"}`,
+print(reply.json()) # {"reply": ..., "tx": "<sig>"}`,
};
const body = document.createElement('div');
body.innerHTML = `
<ul class="fm-bullets">
- <li>Quoted in USDC on Solana — payments settle in seconds, signed end-to-end.</li>
- <li>Set a price per skill (chat, render, custom endpoint) after saving.</li>
- <li>Earnings stream into your agent's wallet, withdrawable any time.</li>
+ <li>Your agent earns USDC every time another agent or app calls it — no API keys, no invoicing.</li>
+ <li>Payments settle on Solana in seconds, signed end-to-end via the <code>x402</code> protocol.</li>
+ <li>Set a price per skill after saving — chat, render, or any custom endpoint you define.</li>
</ul>
- <div class="fm-handshake" aria-label="x402 handshake">
- <div class="fm-handshake-step">
- <span class="fm-handshake-num">1</span>
- <div>
- <strong>Client calls</strong>
- <div class="muted">No auth, just hits the endpoint.</div>
- </div>
- <span class="fm-handshake-code">POST</span>
+ <div class="fm-flow" aria-label="x402 payment flow">
+ <div class="fm-flow-step">
+ <div class="fm-flow-num" aria-hidden="true">1</div>
+ <div class="fm-flow-label"><strong>Request</strong></div>
+ <div class="fm-flow-detail">Client hits your endpoint. No auth needed.</div>
+ <span class="fm-flow-badge">POST</span>
</div>
- <div class="fm-handshake-arrow">→</div>
- <div class="fm-handshake-step">
- <span class="fm-handshake-num">2</span>
- <div>
- <strong>Server replies <code>402</code></strong>
- <div class="muted">Quotes <code>$0.05</code> USDC on Solana.</div>
- </div>
- <span class="fm-handshake-code">402</span>
+ <div class="fm-flow-connector" aria-hidden="true">
+ <div class="fm-flow-line"></div>
+ <div class="fm-flow-pulse"></div>
+ </div>
+ <div class="fm-flow-step fm-flow-step--mid">
+ <div class="fm-flow-num" aria-hidden="true">2</div>
+ <div class="fm-flow-label"><strong>Quote</strong></div>
+ <div class="fm-flow-detail">Server replies <code>402</code> with USDC price.</div>
+ <span class="fm-flow-badge fm-flow-badge--warn">402</span>
</div>
- <div class="fm-handshake-arrow">→</div>
- <div class="fm-handshake-step">
- <span class="fm-handshake-num">3</span>
- <div>
- <strong>Client signs &amp; retries</strong>
- <div class="muted"><code>X-PAYMENT</code> header carries the signed transfer.</div>
+ <div class="fm-flow-connector" aria-hidden="true">
+ <div class="fm-flow-line"></div>
+ <div class="fm-flow-pulse"></div>
+ </div>
+ <div class="fm-flow-step fm-flow-step--end">
+ <div class="fm-flow-num" aria-hidden="true">3</div>
+ <div class="fm-flow-label"><strong>Paid</strong></div>
+ <div class="fm-flow-detail">Client signs USDC transfer, retries. Done.</div>
+ <span class="fm-flow-badge fm-flow-badge--ok">200</span>
+ </div>
+ </div>
+
+ <div class="fm-pricing-preview">
+ <div class="fm-pricing-head">
+ <span class="fm-pricing-title">Skill pricing</span>
+ <span class="fm-pricing-pill">CONFIGURE AFTER SAVE</span>
+ </div>
+ <div class="fm-pricing-rows">
+ <div class="fm-pricing-row">
+ <span class="fm-pricing-skill">Chat</span>
+ <span class="fm-pricing-amount">$0.02 <span class="muted">USDC / call</span></span>
+ </div>
+ <div class="fm-pricing-row">
+ <span class="fm-pricing-skill">Render</span>
+ <span class="fm-pricing-amount">$0.10 <span class="muted">USDC / call</span></span>
+ </div>
+ <div class="fm-pricing-row">
+ <span class="fm-pricing-skill">Custom endpoint</span>
+ <span class="fm-pricing-amount">$0.05 <span class="muted">USDC / call</span></span>
</div>
- <span class="fm-handshake-code">200</span>
</div>
+ <div class="fm-pricing-foot">Earnings stream into your agent's wallet, withdrawable any time.</div>
</div>
<div class="fm-tabs" role="tablist" aria-label="Client language">
- <button class="fm-tab is-active" role="tab" data-tab="curl">cURL</button>
- <button class="fm-tab" role="tab" data-tab="fetch">JavaScript</button>
+ <button class="fm-tab is-active" role="tab" data-tab="fetch">JavaScript</button>
+ <button class="fm-tab" role="tab" data-tab="curl">cURL</button>
<button class="fm-tab" role="tab" data-tab="python">Python</button>
</div>
- <div class="fm-code" data-copy-target>
+ <div class="fm-code fm-code--highlighted" data-copy-target>
<pre data-snippet></pre>
<button class="fm-copy" type="button">Copy</button>
</div>
- <p class="fm-note">Endpoint shape is real — your handle is filled in as you name your avatar. Pricing &amp; gating is configured after save.</p>
+ <p class="fm-note">Endpoint uses your avatar's handle — filled in live as you type. Pricing is configured after save.</p>
`;
openFeatureModal({
icon: '💸',
title: 'Paid Skills (x402)',
- lede: 'Charge per call in USDC over the x402 protocol. Other agents (and apps) pay yours automatically — no API keys, no invoicing.',
+ lede: 'Turn every skill into revenue. Other agents pay yours automatically — USDC settles in seconds.',
body,
actions: [{ label: 'Got it' }],
dialogClass: 'fm-dialog--wide',
@@ -430,15 +454,46 @@ print(reply.json()) # {"reply": "...", "tx": "<sig>"}`,
const codeEl = body.querySelector('[data-copy-target]');
const snippetEl = body.querySelector('[data-snippet]');
+
+ function highlightSnippet(lang, raw) {
+ const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+ const lines = raw.split('\n');
+ return lines
+ .map((line) => {
+ const e = esc(line);
+ if (lang === 'curl') {
+ if (/^\s*#/.test(line)) return `<span class="syn-comment">${e}</span>`;
+ return e
+ .replace(/('(?:[^'\\]|\\.)*')/g, '<span class="syn-string">$1</span>')
+ .replace(/(\b(?:curl)\b)/g, '<span class="syn-keyword">$1</span>');
+ }
+ if (lang === 'fetch') {
+ if (/^\s*\/\//.test(line)) return `<span class="syn-comment">${e}</span>`;
+ return e
+ .replace(/(import|from|const|await|new)\b/g, '<span class="syn-keyword">$1</span>')
+ .replace(/('(?:[^'\\]|\\.)*')/g, '<span class="syn-string">$1</span>')
+ .replace(/(`(?:[^`\\]|\\.)*`)/g, '<span class="syn-string">$1</span>');
+ }
+ if (lang === 'python') {
+ if (/^\s*#/.test(line)) return `<span class="syn-comment">${e}</span>`;
+ return e
+ .replace(/(from|import)\b/g, '<span class="syn-keyword">$1</span>')
+ .replace(/("(?:[^"\\]|\\.)*")/g, '<span class="syn-string">$1</span>');
+ }
+ return e;
+ })
+ .join('\n');
+ }
+
function setTab(name) {
body.querySelectorAll('.fm-tab').forEach((t) => t.classList.toggle('is-active', t.dataset.tab === name));
- snippetEl.textContent = snippets[name];
+ snippetEl.innerHTML = highlightSnippet(name, snippets[name]);
codeEl.dataset.copy = snippets[name];
}
body.querySelectorAll('.fm-tab').forEach((t) => {
t.addEventListener('click', () => setTab(t.dataset.tab));
});
- setTab('curl');
+ setTab('fetch');
}
export function openEmbedModal(ctx = {}) {
diff --git a/src/create-review.js b/src/create-review.js
index e93902537..00131fa01 100644
--- a/src/create-review.js
+++ b/src/create-review.js
@@ -214,7 +214,7 @@ function handleFeatureClick(feature) {
openVoicePreview({ glbBlob: staged.blob, name });
return;
case 'identity':
- openIdentityModal(ctx);
+ openIdentityModal({ ...ctx, canvas: viewerScene?.renderer?.domElement });
return;
case 'paid':
openPaidSkillsModal(ctx);
diff --git a/src/dashboard-next/pages/agents.js b/src/dashboard-next/pages/agents.js
index e1dae5cab..79700d8bf 100644
--- a/src/dashboard-next/pages/agents.js
+++ b/src/dashboard-next/pages/agents.js
@@ -53,6 +53,7 @@ function truncMid(s, head = 6, tail = 4) {
try {
const main = await mountShell();
await requireUser();
+ injectStyles();
main.innerHTML = `
<div style="display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:6px">
@@ -601,3 +602,62 @@ function makeOverlay() {
`;
return el;
}
+
+function injectStyles() {
+ if (document.getElementById('dn-agents-css')) return;
+ const css = document.createElement('style');
+ css.id = 'dn-agents-css';
+ css.textContent = `
+ .dn-agent-card {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 16px;
+ align-items: start;
+ }
+ .dn-agent-actions {
+ grid-column: 1 / -1;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ padding-top: 10px;
+ border-top: 1px solid var(--nxt-stroke);
+ }
+ .dn-agent-actions-primary {
+ display: flex;
+ gap: 6px;
+ flex-wrap: wrap;
+ }
+ .dn-agent-actions-secondary {
+ display: flex;
+ gap: 6px;
+ flex-wrap: wrap;
+ margin-left: auto;
+ }
+ .dn-agent-links {
+ grid-column: 1 / -1;
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ padding-top: 4px;
+ }
+ @media (max-width: 600px) {
+ .dn-agent-actions {
+ flex-direction: column;
+ align-items: stretch;
+ }
+ .dn-agent-actions-primary,
+ .dn-agent-actions-secondary {
+ justify-content: stretch;
+ }
+ .dn-agent-actions-primary { order: 0; }
+ .dn-agent-actions-secondary { margin-left: 0; order: 1; }
+ .dn-agent-actions-primary .dn-btn,
+ .dn-agent-actions-secondary .dn-btn {
+ flex: 1 1 auto;
+ text-align: center;
+ }
+ }
+ `;
+ document.head.appendChild(css);
+}
diff --git a/src/dashboard-next/pages/home.js b/src/dashboard-next/pages/home.js
index 80dce7931..80e9863ec 100644
--- a/src/dashboard-next/pages/home.js
+++ b/src/dashboard-next/pages/home.js
@@ -110,6 +110,15 @@ function renderSkeletons(main) {
<div class="dn-skeleton" style="height:28px;width:100px;margin-bottom:10px"></div>
<div class="dn-skeleton" style="height:36px;width:100%"></div></div>
`).join('');
+ main.querySelector('[data-slot="quick"]').innerHTML = Array.from({ length: 4 }, () => `
+ <div class="dn-panel" style="display:flex;align-items:center;gap:14px;padding:16px">
+ <div class="dn-skeleton" style="width:40px;height:40px;border-radius:10px;flex-shrink:0"></div>
+ <div style="flex:1;min-width:0">
+ <div class="dn-skeleton" style="height:13px;width:60%;margin-bottom:6px"></div>
+ <div class="dn-skeleton" style="height:11px;width:40%"></div>
+ </div>
+ </div>
+ `).join('');
main.querySelector('[data-slot="activity"]').innerHTML = `
<div class="dn-panel">
<div class="dn-panel-title">Recent activity</div>
diff --git a/src/home-v4-hero.js b/src/home-v4-hero.js
index 08c29d837..be315407a 100644
--- a/src/home-v4-hero.js
+++ b/src/home-v4-hero.js
@@ -1,9 +1,3 @@
-/**
- * Hero particle-to-avatar materialization for home-v4.
- * Loads a GLB, samples 6000 points from the mesh surface,
- * animates particles converging into the avatar shape,
- * then crossfades to the solid model.
- */
import {
WebGLRenderer,
Scene,
@@ -71,6 +65,7 @@ export class HeroScene {
this.canvas = canvas;
this._raf = 0;
this._disposed = false;
+ this._visible = true;
const LOW_MEMORY = typeof navigator.deviceMemory === 'number' && navigator.deviceMemory < 2;
const REDUCED_MOTION = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -117,8 +112,20 @@ export class HeroScene {
this._focusY = 1.0;
this._resize();
- const ro = new ResizeObserver(() => this._resize());
- ro.observe(canvas);
+ this._ro = new ResizeObserver(() => this._resize());
+ this._ro.observe(canvas);
+
+ this._visibilityObserver = new IntersectionObserver(
+ (entries) => {
+ this._visible = entries[0].isIntersecting;
+ if (this._visible && !this._raf) {
+ this._clock.start();
+ this._raf = requestAnimationFrame(this._tick);
+ }
+ },
+ { rootMargin: '100px' },
+ );
+ this._visibilityObserver.observe(canvas);
this._onMouseMove = this._onMouseMove.bind(this);
window.addEventListener('mousemove', this._onMouseMove, { passive: true });
@@ -144,7 +151,12 @@ export class HeroScene {
}
async _load() {
- const gltf = await this._loader.loadAsync(MODEL_URL);
+ let gltf;
+ try {
+ gltf = await this._loader.loadAsync(MODEL_URL);
+ } catch {
+ return;
+ }
if (this._disposed) return;
this.model = gltf.scene;
@@ -157,6 +169,8 @@ export class HeroScene {
this.model.position.z -= center.z;
this.model.position.y -= box.min.y;
+ this.model.updateMatrixWorld(true);
+
const targetHeight = size.y;
const dist = (targetHeight / 2) / Math.tan((this.camera.fov / 2) * (Math.PI / 180));
this._focusY = targetHeight * 0.5;
@@ -207,7 +221,7 @@ export class HeroScene {
const filtered = new AnimationClip(clip.name, clip.duration, tracks);
const action = this.mixer.clipAction(filtered);
action.play();
- } catch { /* non-critical */ }
+ } catch { /* manifest/clip fetch is non-critical enhancement */ }
}
_collectOpacityTargets() {
@@ -250,18 +264,17 @@ export class HeroScene {
for (let i = 0; i < count; i++) {
sampler.sample(pos);
pos.applyMatrix4(mesh.matrixWorld);
- pos.x -= this.model.position.x === 0 ? 0 : 0;
- targets[idx * 3] = pos.x + this.model.position.x;
- targets[idx * 3 + 1] = pos.y + this.model.position.y;
- targets[idx * 3 + 2] = pos.z + this.model.position.z;
+ targets[idx * 3] = pos.x;
+ targets[idx * 3 + 1] = pos.y;
+ targets[idx * 3 + 2] = pos.z;
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
const r = 2 + Math.random() * 4;
- starts[idx * 3] = targets[idx * 3] + r * Math.sin(phi) * Math.cos(theta);
- starts[idx * 3 + 1] = targets[idx * 3 + 1] + r * Math.sin(phi) * Math.sin(theta);
- starts[idx * 3 + 2] = targets[idx * 3 + 2] + r * Math.cos(phi);
+ starts[idx * 3] = pos.x + r * Math.sin(phi) * Math.cos(theta);
+ starts[idx * 3 + 1] = pos.y + r * Math.sin(phi) * Math.sin(theta);
+ starts[idx * 3 + 2] = pos.z + r * Math.cos(phi);
seeds[idx] = Math.random();
idx++;
@@ -298,6 +311,12 @@ export class HeroScene {
_tick() {
if (this._disposed) return;
+
+ if (!this._visible && this._materialized) {
+ this._raf = 0;
+ return;
+ }
+
const dt = this._clock.getDelta();
const elapsed = this._clock.getElapsedTime();
@@ -348,6 +367,8 @@ export class HeroScene {
dispose() {
this._disposed = true;
cancelAnimationFrame(this._raf);
+ this._ro.disconnect();
+ this._visibilityObserver.disconnect();
window.removeEventListener('mousemove', this._onMouseMove);
if (this.particles) {
this.particles.geometry.dispose();