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: enhance pricing page and animations gallery

fudjiabcac9c2cd376
diff --git a/pages/animations.html b/pages/animations.html
index 3be93bd8f..76a8c54a2 100644
--- a/pages/animations.html
+++ b/pages/animations.html
@@ -6,21 +6,21 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Animation Gallery · three.ws</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="description" content="Browse community-authored animations for three.ws avatars. Preview, remix, and use any public animation in the studio." />
+ <meta name="description" content="Browse 2,000+ motion-capture and community animations for three.ws avatars. Live previews, categories, and one-click use in the Animation Studio." />
<meta name="theme-color" content="#000000" />
<link rel="canonical" href="https://three.ws/animations" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="three.ws" />
<meta property="og:title" content="Animation Gallery · three.ws" />
- <meta property="og:description" content="Browse community animations for three.ws avatars. Preview and use in the Animation Studio." />
+ <meta property="og:description" content="Browse 2,000+ motion-capture and community animations. Preview live and use in the Animation Studio." />
<meta property="og:url" content="https://three.ws/animations" />
- <meta property="og:image" content="https://three.ws/api/page-og?s=main&amp;t=Animation+Gallery&amp;d=Browse+and+preview+public+animations+authored+by+the+three.ws+community.+Apply+any+clip+to+your+avatar+in+the+Animation+Studio.&amp;p=%2Fanimations" />
+ <meta property="og:image" content="https://three.ws/api/page-og?s=main&amp;t=Animation+Gallery&amp;d=2%2C000%2B+motion-capture+and+community+animations.+Preview+live+on+an+avatar+and+use+any+clip+in+the+Animation+Studio.&amp;p=%2Fanimations" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@trythreews" />
<meta name="twitter:title" content="Animation Gallery · three.ws" />
- <meta name="twitter:description" content="Browse community animations for three.ws avatars." />
- <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&amp;t=Animation+Gallery&amp;d=Browse+and+preview+public+animations+authored+by+the+three.ws+community.+Apply+any+clip+to+your+avatar+in+the+Animation+Studio.&amp;p=%2Fanimations" />
+ <meta name="twitter:description" content="2,000+ motion-capture and community animations with live previews." />
+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=main&amp;t=Animation+Gallery&amp;d=2%2C000%2B+motion-capture+and+community+animations.+Preview+live+on+an+avatar+and+use+any+clip+in+the+Animation+Studio.&amp;p=%2Fanimations" />
<link rel="icon" href="/favicon.ico" sizes="any" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
@@ -35,8 +35,20 @@
<style>
:root {
- --ag-card-w: 280px;
- --ag-preview-h: 340px;
+ --ag-card-w: 240px;
+ --ag-radius: 14px;
+ --ag-border: rgba(255, 255, 255, 0.08);
+ --ag-border-strong: rgba(255, 255, 255, 0.18);
+ --ag-surface: rgba(255, 255, 255, 0.03);
+ --ag-surface-2: rgba(255, 255, 255, 0.06);
+ --ag-surface-3: rgba(255, 255, 255, 0.1);
+ }
+ :root[data-theme='light'] {
+ --ag-border: rgba(0, 0, 0, 0.09);
+ --ag-border-strong: rgba(0, 0, 0, 0.22);
+ --ag-surface: rgba(0, 0, 0, 0.03);
+ --ag-surface-2: rgba(0, 0, 0, 0.05);
+ --ag-surface-3: rgba(0, 0, 0, 0.08);
}
.ag-page {
@@ -49,8 +61,8 @@
/* ── Hero ──────────────────────────────────────────────────────── */
.ag-hero {
- padding: 64px 24px 40px;
- max-width: 900px;
+ padding: 56px 24px 28px;
+ max-width: 1280px;
margin: 0 auto;
}
.ag-hero-chip {
@@ -58,8 +70,8 @@
align-items: center;
gap: 6px;
padding: 4px 10px;
- background: rgba(255,255,255,0.06);
- border: 1px solid rgba(255,255,255,0.1);
+ background: var(--ag-surface-2);
+ border: 1px solid var(--ag-border);
border-radius: 20px;
font-size: 11px;
color: var(--text-2, #a1a1aa);
@@ -71,31 +83,38 @@
width: 6px;
height: 6px;
border-radius: 50%;
- background: var(--success);
+ background: var(--success, #34d399);
animation: ag-pulse 2.4s ease-out infinite;
}
@keyframes ag-pulse {
- 0%,100% { opacity: 1; }
+ 0%, 100% { opacity: 1; }
50% { opacity: 0.35; }
}
.ag-hero h1 {
- font-size: clamp(28px, 5vw, 44px);
+ font-size: clamp(28px, 5vw, 46px);
font-weight: 700;
letter-spacing: -0.02em;
- margin: 0 0 12px;
- line-height: 1.1;
+ margin: 0 0 10px;
+ line-height: 1.08;
}
.ag-hero p {
color: var(--text-2, #a1a1aa);
font-size: 15px;
- margin: 0 0 24px;
- max-width: 520px;
+ margin: 0 0 22px;
+ max-width: 560px;
}
.ag-hero-actions {
display: flex;
gap: 10px;
flex-wrap: wrap;
+ align-items: center;
+ }
+ .ag-hero-stats {
+ font-size: 12px;
+ color: var(--text-3, #71717a);
+ font-variant-numeric: tabular-nums;
}
+
.ag-btn {
display: inline-flex;
align-items: center;
@@ -107,47 +126,53 @@
text-decoration: none;
border: none;
cursor: pointer;
- transition: opacity 0.15s, background 0.15s;
+ transition: opacity 0.15s, background 0.15s, transform 0.15s;
}
.ag-btn:focus-visible {
- outline: 2px solid var(--focus-ring-color, #fff);
+ outline: 2px solid var(--focus-ring-color, currentColor);
outline-offset: 2px;
}
- .ag-btn--primary {
- background: #fff;
- color: #000;
- }
- .ag-btn--primary:hover { background: #e5e5e5; }
- .ag-btn--primary:active { background: #ccc; }
+ .ag-btn--primary { background: var(--text, #fff); color: var(--bg, #000); }
+ .ag-btn--primary:hover { opacity: 0.85; }
+ .ag-btn--primary:active { opacity: 0.7; }
.ag-btn--secondary {
- background: rgba(255,255,255,0.08);
+ background: var(--ag-surface-2);
color: var(--text, #fafafa);
- border: 1px solid rgba(255,255,255,0.12);
+ border: 1px solid var(--ag-border);
}
- .ag-btn--secondary:hover { background: rgba(255,255,255,0.12); }
- .ag-btn--secondary:active { background: rgba(255,255,255,0.18); }
+ .ag-btn--secondary:hover { background: var(--ag-surface-3); }
+ .ag-btn--secondary:active { background: var(--ag-surface-3); }
- /* ── Toolbar ──────────────────────────────────────────────────── */
+ /* ── Sticky toolbar ───────────────────────────────────────────── */
.ag-toolbar {
+ position: sticky;
+ top: 0;
+ z-index: 30;
+ background: color-mix(in srgb, var(--bg, #000) 82%, transparent);
+ backdrop-filter: blur(14px);
+ -webkit-backdrop-filter: blur(14px);
+ border-bottom: 1px solid var(--ag-border);
+ }
+ .ag-toolbar-inner {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 10px 24px;
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+ .ag-toolbar-row {
display: flex;
align-items: center;
gap: 10px;
- padding: 0 24px 24px;
- max-width: 1200px;
- margin: 0 auto;
flex-wrap: wrap;
}
- .ag-search-wrap {
- position: relative;
- flex: 1;
- min-width: 200px;
- max-width: 360px;
- }
+ .ag-search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 340px; }
.ag-search {
width: 100%;
- padding: 9px 34px 9px 36px;
- background: rgba(255,255,255,0.06);
- border: 1px solid rgba(255,255,255,0.1);
+ padding: 8px 30px 8px 34px;
+ background: var(--ag-surface-2);
+ border: 1px solid var(--ag-border);
border-radius: 8px;
color: var(--text, #fafafa);
font-size: 13px;
@@ -155,7 +180,7 @@
box-sizing: border-box;
transition: border-color 0.15s;
}
- .ag-search:focus { border-color: rgba(255,255,255,0.3); }
+ .ag-search:focus { border-color: var(--ag-border-strong); }
.ag-search::placeholder { color: var(--text-3, #71717a); }
.ag-search-icon {
position: absolute;
@@ -165,140 +190,215 @@
color: var(--text-3, #71717a);
pointer-events: none;
}
+ .ag-search-kbd {
+ position: absolute;
+ right: 9px;
+ top: 50%;
+ transform: translateY(-50%);
+ font-size: 10px;
+ padding: 1px 5px;
+ border: 1px solid var(--ag-border);
+ border-radius: 4px;
+ color: var(--text-3, #71717a);
+ pointer-events: none;
+ }
+ .ag-seg {
+ display: inline-flex;
+ border: 1px solid var(--ag-border);
+ border-radius: 8px;
+ overflow: hidden;
+ }
+ .ag-seg button {
+ padding: 7px 12px;
+ font-size: 12px;
+ background: transparent;
+ border: none;
+ color: var(--text-2, #a1a1aa);
+ cursor: pointer;
+ transition: background 0.15s, color 0.15s;
+ }
+ .ag-seg button + button { border-left: 1px solid var(--ag-border); }
+ .ag-seg button:hover { background: var(--ag-surface-2); color: var(--text, #fafafa); }
+ .ag-seg button[aria-pressed='true'] {
+ background: var(--text, #fff);
+ color: var(--bg, #000);
+ }
+ .ag-seg button:focus-visible {
+ outline: 2px solid var(--focus-ring-color, currentColor);
+ outline-offset: -2px;
+ }
+ .ag-sort {
+ padding: 7px 10px;
+ background: var(--ag-surface-2);
+ border: 1px solid var(--ag-border);
+ border-radius: 8px;
+ color: var(--text, #fafafa);
+ font-size: 12px;
+ cursor: pointer;
+ }
+ .ag-sort:focus-visible { outline: 2px solid var(--focus-ring-color, currentColor); }
+ .ag-count {
+ margin-left: auto;
+ font-size: 12px;
+ color: var(--text-3, #71717a);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+ }
+
+ /* Category chips — one scrollable row */
.ag-filter-chips {
display: flex;
gap: 6px;
- flex-wrap: wrap;
+ overflow-x: auto;
+ scrollbar-width: none;
+ padding-bottom: 2px;
+ -webkit-overflow-scrolling: touch;
}
+ .ag-filter-chips::-webkit-scrollbar { display: none; }
.ag-chip {
+ flex: 0 0 auto;
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
- border: 1px solid rgba(255,255,255,0.1);
+ border: 1px solid var(--ag-border);
background: transparent;
color: var(--text-2, #a1a1aa);
cursor: pointer;
transition: background 0.15s, border-color 0.15s, color 0.15s;
+ white-space: nowrap;
}
- .ag-chip:hover { background: rgba(255,255,255,0.06); color: var(--text, #fafafa); }
- .ag-chip:active { background: rgba(255,255,255,0.12); }
- .ag-chip[aria-selected="true"] {
- background: #fff;
- color: #000;
- border-color: #fff;
+ .ag-chip:hover { background: var(--ag-surface-2); color: var(--text, #fafafa); }
+ .ag-chip[aria-selected='true'] {
+ background: var(--text, #fff);
+ color: var(--bg, #000);
+ border-color: var(--text, #fff);
}
- .ag-chip[aria-selected="true"]:active { background: #ccc; }
.ag-chip:focus-visible {
- outline: 2px solid var(--focus-ring-color, #fff);
+ outline: 2px solid var(--focus-ring-color, currentColor);
outline-offset: 2px;
}
+ .ag-chip-count { opacity: 0.55; font-size: 11px; font-variant-numeric: tabular-nums; }
/* ── Grid ──────────────────────────────────────────────────────── */
.ag-content {
- max-width: 1200px;
+ max-width: 1280px;
margin: 0 auto;
- padding: 0 24px 80px;
+ padding: 24px 24px 80px;
}
.ag-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--ag-card-w), 1fr));
- gap: 20px;
+ gap: 16px;
}
/* ── Card ──────────────────────────────────────────────────────── */
.ag-card {
- background: rgba(255,255,255,0.03);
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 14px;
+ background: var(--ag-surface);
+ border: 1px solid var(--ag-border);
+ border-radius: var(--ag-radius);
overflow: hidden;
display: flex;
flex-direction: column;
- transition: border-color 0.2s, transform 0.2s;
- position: relative;
+ transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
+ content-visibility: auto;
+ contain-intrinsic-size: 240px 420px;
}
.ag-card:hover {
- border-color: rgba(255,255,255,0.18);
+ border-color: var(--ag-border-strong);
transform: translateY(-2px);
+ box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
- .ag-card:focus-within {
- outline: 2px solid rgba(255,255,255,0.4);
- outline-offset: 2px;
- }
+ .ag-card:focus-within { border-color: var(--ag-border-strong); }
- /* Thumbnail / preview */
.ag-card-preview {
position: relative;
aspect-ratio: 3/4;
- background: rgba(255,255,255,0.04);
+ background:
+ radial-gradient(90% 60% at 50% 38%, var(--ag-surface-3) 0%, transparent 70%),
+ var(--ag-surface);
overflow: hidden;
cursor: pointer;
}
+ .ag-card-preview:focus-visible {
+ outline: 2px solid var(--focus-ring-color, currentColor);
+ outline-offset: -2px;
+ }
.ag-card-thumb {
+ position: absolute;
+ inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
display: block;
+ transition: opacity 0.25s, transform 0.35s ease;
}
- .ag-card-thumb-placeholder {
- width: 100%;
- height: 100%;
+ .ag-card:hover .ag-card-thumb { transform: scale(1.03); }
+ .ag-card-thumb-fallback {
+ position: absolute;
+ inset: 0;
display: flex;
align-items: center;
justify-content: center;
- font-size: 48px;
- color: rgba(255,255,255,0.15);
+ font-size: 52px;
+ opacity: 0.35;
}
- /* Hover overlay with live preview iframe */
- .ag-card-preview-overlay {
+ .ag-card-live {
position: absolute;
inset: 0;
opacity: 0;
- transition: opacity 0.3s;
+ transition: opacity 0.25s;
pointer-events: none;
}
- .ag-card:hover .ag-card-preview-overlay,
- .ag-card-preview-overlay.is-active {
- opacity: 1;
- pointer-events: auto;
- }
- .ag-card-preview-overlay iframe {
- width: 100%;
- height: 100%;
- border: none;
- display: block;
+ .ag-card.is-live .ag-card-live { opacity: 1; }
+ .ag-card.is-live .ag-card-thumb { opacity: 0; }
+ .ag-card-live canvas { width: 100%; height: 100%; display: block; }
+ .ag-card.is-loading-preview .ag-card-preview::after {
+ content: '';
+ position: absolute;
+ top: 10px;
+ left: 10px;
+ width: 12px;
+ height: 12px;
+ border: 2px solid var(--text-3, #71717a);
+ border-top-color: transparent;
+ border-radius: 50%;
+ animation: ag-spin 0.7s linear infinite;
}
- .ag-play-hint {
+ @keyframes ag-spin { to { transform: rotate(360deg); } }
+
+ .ag-card-duration,
+ .ag-card-once,
+ .ag-card-price {
position: absolute;
- inset: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- background: rgba(0,0,0,0.3);
- transition: opacity 0.2s;
+ top: 8px;
+ font-size: 10px;
+ font-weight: 500;
+ padding: 3px 7px;
+ border-radius: 5px;
+ background: rgba(0, 0, 0, 0.55);
+ color: #fff;
+ backdrop-filter: blur(4px);
+ letter-spacing: 0.02em;
+ font-variant-numeric: tabular-nums;
pointer-events: none;
}
- .ag-card:hover .ag-play-hint { opacity: 0; }
- .ag-play-icon {
- width: 40px;
- height: 40px;
- background: rgba(255,255,255,0.15);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- backdrop-filter: blur(6px);
- }
+ .ag-card-duration { right: 8px; }
+ .ag-card-duration:empty { display: none; }
+ .ag-card-once { left: 8px; text-transform: uppercase; color: #fbbf24; }
+ .ag-card-price { left: 8px; color: #60a5fa; }
- /* Meta */
.ag-card-meta {
- padding: 14px 16px 16px;
+ padding: 12px 14px 14px;
display: flex;
flex-direction: column;
gap: 8px;
flex: 1;
}
.ag-card-title {
- font-size: 14px;
+ font-size: 13.5px;
font-weight: 600;
color: var(--text, #fafafa);
margin: 0;
@@ -306,43 +406,34 @@
overflow: hidden;
text-overflow: ellipsis;
}
- .ag-card-badges {
+ .ag-card-sub {
display: flex;
- gap: 5px;
- flex-wrap: wrap;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
}
- .ag-badge {
- padding: 2px 7px;
- border-radius: 4px;
- font-size: 10px;
- font-weight: 500;
- letter-spacing: 0.02em;
- text-transform: uppercase;
- background: rgba(255,255,255,0.07);
+ .ag-card-cat {
+ border: none;
+ background: var(--ag-surface-2);
color: var(--text-2, #a1a1aa);
+ font-size: 11px;
+ padding: 3px 8px;
+ border-radius: 5px;
+ cursor: pointer;
+ transition: background 0.15s, color 0.15s;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
- .ag-badge--loop { color: #34d399; background: rgba(52,211,153,0.12); }
- .ag-badge--once { color: var(--warn); background: rgba(251,191,36,0.12); }
- .ag-badge--price { color: #60a5fa; background: rgba(96,165,250,0.12); }
- .ag-badge--source { color: var(--text-3, #71717a); background: rgba(255,255,255,0.05); }
- .ag-card-tags {
- display: flex;
- gap: 4px;
- flex-wrap: wrap;
- }
- .ag-tag {
- padding: 2px 6px;
- border-radius: 4px;
+ .ag-card-cat:hover { background: var(--ag-surface-3); color: var(--text, #fafafa); }
+ .ag-card-cat:focus-visible { outline: 2px solid var(--focus-ring-color, currentColor); }
+ .ag-card-source {
font-size: 10px;
- background: rgba(255,255,255,0.05);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
color: var(--text-3, #71717a);
}
- .ag-card-actions {
- display: flex;
- gap: 6px;
- margin-top: auto;
- padding-top: 4px;
- }
+ .ag-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 2px; }
.ag-card-btn {
flex: 1;
padding: 7px 10px;
@@ -351,36 +442,33 @@
font-weight: 500;
text-align: center;
text-decoration: none;
- border: 1px solid rgba(255,255,255,0.1);
- background: rgba(255,255,255,0.05);
+ border: 1px solid var(--ag-border);
+ background: var(--ag-surface);
color: var(--text-2, #a1a1aa);
cursor: pointer;
transition: background 0.15s, color 0.15s;
}
- .ag-card-btn:hover { background: rgba(255,255,255,0.1); color: var(--text, #fafafa); }
- .ag-card-btn:active { background: rgba(255,255,255,0.16); }
+ .ag-card-btn:hover { background: var(--ag-surface-3); color: var(--text, #fafafa); }
.ag-card-btn:focus-visible {
- outline: 2px solid var(--focus-ring-color, #fff);
+ outline: 2px solid var(--focus-ring-color, currentColor);
outline-offset: 2px;
}
.ag-card-btn--primary {
- background: rgba(255,255,255,0.12);
+ background: var(--ag-surface-3);
color: var(--text, #fafafa);
- border-color: rgba(255,255,255,0.15);
+ border-color: var(--ag-border-strong);
}
- .ag-card-btn--primary:hover { background: rgba(255,255,255,0.2); }
- .ag-card-btn--primary:active { background: rgba(255,255,255,0.28); }
- /* ── Skeleton loading ──────────────────────────────────────────── */
+ /* ── Skeleton loading ─────────────────────────────────────────── */
.ag-skeleton-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--ag-card-w), 1fr));
- gap: 20px;
+ gap: 16px;
}
.ag-skeleton {
- border-radius: 14px;
+ border-radius: var(--ag-radius);
aspect-ratio: 3/5;
- background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
+ background: linear-gradient(90deg, var(--ag-surface) 25%, var(--ag-surface-2) 50%, var(--ag-surface) 75%);
background-size: 400% 100%;
animation: ag-shimmer 1.3s linear infinite;
}
@@ -389,38 +477,243 @@
100% { background-position: -100% 0; }
}
- /* ── Empty / error states ──────────────────────────────────────── */
- .ag-state {
- text-align: center;
- padding: 80px 24px;
- }
+ /* ── Empty / error states ─────────────────────────────────────── */
+ .ag-state { text-align: center; padding: 80px 24px; }
.ag-state-icon { font-size: 48px; margin-bottom: 16px; }
.ag-state h2 { font-size: 20px; font-weight: 600; margin: 0 0 8px; }
.ag-state p { color: var(--text-2, #a1a1aa); font-size: 14px; margin: 0 0 24px; }
- /* ── Load more ─────────────────────────────────────────────────── */
- .ag-load-more {
+ .ag-load-more { display: flex; justify-content: center; padding: 32px 0 0; }
+ .ag-sentinel { height: 1px; }
+
+ /* ── Detail modal ─────────────────────────────────────────────── */
+ .ag-modal {
+ position: fixed;
+ inset: 0;
+ z-index: 100;
+ background: rgba(0, 0, 0, 0.72);
+ backdrop-filter: blur(8px);
+ -webkit-backdrop-filter: blur(8px);
display: flex;
+ align-items: center;
justify-content: center;
- padding: 32px 0 0;
+ padding: 20px;
+ }
+ .ag-modal[hidden] { display: none; }
+ .ag-modal-card {
+ background: var(--bg, #0a0a0a);
+ border: 1px solid var(--ag-border);
+ border-radius: 18px;
+ width: min(920px, 100%);
+ max-height: calc(100vh - 40px);
+ display: grid;
+ grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
+ overflow: hidden;
+ animation: ag-modal-in 0.22s ease;
+ }
+ @keyframes ag-modal-in {
+ from { opacity: 0; transform: translateY(10px) scale(0.985); }
+ to { opacity: 1; transform: none; }
+ }
+ .ag-modal-stage-wrap {
+ position: relative;
+ background:
+ radial-gradient(90% 60% at 50% 38%, var(--ag-surface-3) 0%, transparent 70%),
+ var(--ag-surface);
+ min-height: 380px;
+ }
+ .ag-modal-stage { position: absolute; inset: 0; }
+ .ag-modal-stage canvas { width: 100%; height: 100%; display: block; }
+ .ag-modal-spinner {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .ag-modal-spinner::after {
+ content: '';
+ width: 26px;
+ height: 26px;
+ border: 2.5px solid var(--text-3, #71717a);
+ border-top-color: transparent;
+ border-radius: 50%;
+ animation: ag-spin 0.7s linear infinite;
+ }
+ .ag-modal-error {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ color: var(--text-2, #a1a1aa);
+ font-size: 13px;
+ padding: 24px;
+ text-align: center;
+ }
+
+ .ag-modal-transport {
+ position: absolute;
+ left: 12px;
+ right: 12px;
+ bottom: 12px;
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ padding: 8px 12px;
+ background: rgba(0, 0, 0, 0.55);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 10px;
+ backdrop-filter: blur(8px);
+ }
+ .ag-modal-transport button {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ border-radius: 6px;
+ border: none;
+ background: rgba(255, 255, 255, 0.12);
+ color: #fff;
+ cursor: pointer;
+ transition: background 0.15s;
+ flex: 0 0 auto;
+ }
+ .ag-modal-transport button:hover { background: rgba(255, 255, 255, 0.22); }
+ .ag-modal-transport button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
+ .ag-modal-scrub {
+ flex: 1;
+ accent-color: #fff;
+ min-width: 60px;
+ }
+ .ag-modal-time {
+ font-size: 10.5px;
+ color: rgba(255, 255, 255, 0.75);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+ }
+ .ag-modal-speed-wrap {
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ flex: 0 0 auto;
+ }
+ .ag-modal-speed { width: 64px; accent-color: #fff; }
+ .ag-modal-speed-val {
+ font-size: 10.5px;
+ color: rgba(255, 255, 255, 0.75);
+ width: 26px;
+ font-variant-numeric: tabular-nums;
}
- .ag-sentinel { height: 1px; }
- /* ── Responsive ────────────────────────────────────────────────── */
- @media (max-width: 600px) {
- :root { --ag-card-w: 260px; }
- .ag-hero { padding: 40px 16px 24px; }
- .ag-toolbar, .ag-content { padding-left: 16px; padding-right: 16px; }
- .ag-hero h1 { font-size: 28px; }
+ .ag-modal-info {
+ padding: 24px;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ overflow-y: auto;
+ }
+ .ag-modal-info h2 {
+ font-size: 20px;
+ font-weight: 700;
+ margin: 0;
+ letter-spacing: -0.01em;
+ padding-right: 36px;
+ }
+ .ag-modal-meta {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-wrap: wrap;
+ font-size: 12.5px;
+ color: var(--text-2, #a1a1aa);
+ }
+ .ag-dot { opacity: 0.4; }
+ .ag-modal-tags { display: flex; gap: 4px; flex-wrap: wrap; }
+ .ag-tag {
+ padding: 2px 7px;
+ border-radius: 4px;
+ font-size: 10.5px;
+ background: var(--ag-surface-2);
+ color: var(--text-3, #71717a);
+ }
+ .ag-modal-actions {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ margin-top: auto;
+ }
+ .ag-modal-actions .ag-btn { justify-content: center; }
+ .ag-modal-nav {
+ display: flex;
+ gap: 8px;
+ }
+ .ag-modal-nav .ag-btn { flex: 1; }
+ .ag-modal-nav .ag-btn:disabled { opacity: 0.35; cursor: default; }
+ .ag-modal-hint {
+ font-size: 11px;
+ color: var(--text-3, #71717a);
+ text-align: center;
+ }
+ .ag-modal-hint kbd {
+ font-family: inherit;
+ border: 1px solid var(--ag-border);
+ border-radius: 4px;
+ padding: 0 4px;
+ font-size: 10px;
+ }
+ .ag-modal-close {
+ position: absolute;
+ top: 14px;
+ right: 14px;
+ width: 30px;
+ height: 30px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 8px;
+ border: 1px solid var(--ag-border);
+ background: var(--ag-surface-2);
+ color: var(--text, #fafafa);
+ cursor: pointer;
+ transition: background 0.15s;
+ z-index: 2;
+ }
+ .ag-modal-close:hover { background: var(--ag-surface-3); }
+ .ag-modal-close:focus-visible { outline: 2px solid var(--focus-ring-color, currentColor); }
+
+ /* ── Responsive ───────────────────────────────────────────────── */
+ @media (max-width: 720px) {
+ :root { --ag-card-w: 46vw; }
+ .ag-hero { padding: 36px 16px 20px; }
+ .ag-toolbar-inner, .ag-content { padding-left: 16px; padding-right: 16px; }
+ .ag-count { display: none; }
+ .ag-modal { padding: 0; align-items: stretch; }
+ .ag-modal-card {
+ grid-template-columns: 1fr;
+ grid-template-rows: minmax(300px, 5fr) minmax(0, 4fr);
+ width: 100%;
+ max-height: 100vh;
+ border-radius: 0;
+ }
+ }
+ @media (max-width: 380px) {
+ :root { --ag-card-w: 100%; }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .ag-card, .ag-card-thumb, .ag-modal-card { transition: none; animation: none; }
}
</style>
-
- <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Animation Gallery","description":"Browse and preview public animations authored by the three.ws community. Apply any clip to your avatar in the Animation Studio.","url":"https://three.ws/animations","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
- <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
- <meta property="og:locale" content="en_US">
- <meta property="og:image:alt" content="Animation Gallery — three.ws">
-</head>
+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","name":"Animation Gallery","description":"Browse and preview 2,000+ motion-capture and community animations for three.ws avatars. Apply any clip to your avatar in the Animation Studio.","url":"https://three.ws/animations","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>
+
+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
+ <meta property="og:locale" content="en_US">
+ <meta property="og:image:alt" content="Animation Gallery — three.ws">
+ </head>
<body class="ag-page">
<header>
<div id="nav-container"></div>
@@ -432,38 +725,56 @@
<div>
<div class="ag-hero-chip">
<span class="ag-hero-dot" aria-hidden="true"></span>
- <span>Animation Gallery</span>
+ <span>Motion Library</span>
</div>
</div>
<h1>Animation Gallery</h1>
- <p>Browse the three.ws motion library and community-authored clips. Preview any animation on a live avatar, open it in the Studio to remix, or apply it to your own avatar.</p>
+ <p>Every clip in the three.ws motion library — mocap performances, studio presets, and community-authored animations. Hover any card for a live preview, open the details for playback controls, or send it straight to the Studio.</p>
<div class="ag-hero-actions">
<a href="/pose" class="ag-btn ag-btn--primary">Open Animation Studio</a>
<a href="/gallery" class="ag-btn ag-btn--secondary">Avatar Gallery</a>
+ <span class="ag-hero-stats" data-role="hero-stats" aria-live="polite"></span>
</div>
</section>
- <div class="ag-toolbar" role="toolbar" aria-label="Filter animations">
- <div class="ag-search-wrap">
- <svg class="ag-search-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
- <input
- type="search"
- class="ag-search"
- placeholder="Search animations…"
- aria-label="Search animations"
- autocomplete="off"
- data-role="search"
- />
- </div>
- <div class="ag-filter-chips" role="tablist" aria-label="Filter by type" data-role="chips">
- <button class="ag-chip" role="tab" aria-selected="true" data-filter="">All</button>
- <button class="ag-chip" role="tab" aria-selected="false" data-filter="loop">Loops</button>
- <button class="ag-chip" role="tab" aria-selected="false" data-filter="once">One-shot</button>
+ <div class="ag-toolbar">
+ <div class="ag-toolbar-inner">
+ <div class="ag-toolbar-row" role="toolbar" aria-label="Search and sort animations">
+ <div class="ag-search-wrap">
+ <svg class="ag-search-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
+ <input
+ type="search"
+ class="ag-search"
+ placeholder="Search animations…"
+ aria-label="Search animations"
+ autocomplete="off"
+ data-role="search"
+ />
+ <kbd class="ag-search-kbd" aria-hidden="true">/</kbd>
+ </div>
+ <div class="ag-seg" role="group" aria-label="Filter by playback type" data-role="type-filter">
+ <button data-filter="" aria-pressed="true">All</button>
+ <button data-filter="loop" aria-pressed="false">Loops</button>
+ <button data-filter="once" aria-pressed="false">One-shot</button>
+ </div>
+ <select class="ag-sort" data-role="sort" aria-label="Sort animations">
+ <option value="featured">Featured</option>
+ <option value="az">A → Z</option>
+ <option value="za">Z → A</option>
+ <option value="shortest">Shortest first</option>
+ <option value="longest">Longest first</option>
+ <option value="shuffle">Shuffle</option>
+ </select>
+ <span class="ag-count" data-role="count" aria-live="polite"></span>
+ </div>
+ <div class="ag-filter-chips" role="tablist" aria-label="Filter by category" data-role="chips"></div>
</div>
</div>
<div class="ag-content">
- <div data-role="loading" class="ag-skeleton-grid">
+ <div data-role="loading" class="ag-skeleton-grid" aria-label="Loading animations">
+ <div class="ag-skeleton"></div>
+ <div class="ag-skeleton"></div>
<div class="ag-skeleton"></div>
<div class="ag-skeleton"></div>
<div class="ag-skeleton"></div>
@@ -482,7 +793,7 @@
<div class="ag-state-icon">🔍</div>
<h2>No matches</h2>
<p data-role="empty-search-msg">No animations match your search.</p>
- <button class="ag-btn ag-btn--secondary" data-role="clear-search">Clear search</button>
+ <button class="ag-btn ag-btn--secondary" data-role="clear-search">Clear search &amp; filters</button>
</div>
<div data-role="error" class="ag-state" hidden>
<div class="ag-state-icon">⚠️</div>
@@ -497,6 +808,48 @@
</div>
</main>
+ <!-- Clip detail modal -->
+ <div class="ag-modal" data-role="modal" hidden role="dialog" aria-modal="true" aria-labelledby="ag-modal-title">
+ <div class="ag-modal-card">
+ <div class="ag-modal-stage-wrap">
+ <div class="ag-modal-stage" data-role="modal-stage"></div>
+ <div class="ag-modal-spinner" data-role="modal-spinner" aria-label="Loading preview"></div>
+ <div class="ag-modal-error" data-role="modal-error" hidden>
+ <span>⚠️ Couldn't load this clip's preview.</span>
+ <span>You can still open it in the Studio.</span>
+ </div>
+ <div class="ag-modal-transport" aria-label="Playback controls">
+ <button data-role="modal-play" aria-label="Pause"></button>
+ <input type="range" class="ag-modal-scrub" data-role="modal-scrub" min="0" max="1000" value="0" step="1" aria-label="Scrub timeline" />
+ <span class="ag-modal-time" data-role="modal-time"></span>
+ <div class="ag-modal-speed-wrap">
+ <input type="range" class="ag-modal-speed" data-role="modal-speed" min="0.25" max="2" step="0.25" value="1" aria-label="Playback speed" />
+ <span class="ag-modal-speed-val" data-role="modal-speed-val">1×</span>
+ </div>
+ </div>
+ </div>
+ <div class="ag-modal-info">
+ <button class="ag-modal-close" data-role="modal-close" aria-label="Close details">
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" aria-hidden="true"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
+ </button>
+ <h2 id="ag-modal-title" data-role="modal-title"></h2>
+ <div class="ag-modal-meta" data-role="modal-meta"></div>
+ <div class="ag-modal-tags" data-role="modal-tags"></div>
+ <div class="ag-modal-actions">
+ <a class="ag-btn ag-btn--primary" data-role="modal-studio" href="/pose"
+ title="Open this animation in the Studio to remix or apply to your avatar">Open in Studio</a>
+ <button class="ag-btn ag-btn--secondary" data-role="modal-copy-link">Copy link</button>
+ <button class="ag-btn ag-btn--secondary" data-role="modal-copy-embed">Copy embed code</button>
+ <div class="ag-modal-nav">
+ <button class="ag-btn ag-btn--secondary" data-role="modal-prev" aria-label="Previous animation">← Prev</button>
+ <button class="ag-btn ag-btn--secondary" data-role="modal-next" aria-label="Next animation">Next →</button>
+ </div>
+ <div class="ag-modal-hint"><kbd>←</kbd> <kbd>→</kbd> browse · <kbd>Space</kbd> play/pause · <kbd>Esc</kbd> close</div>
+ </div>
+ </div>
+ </div>
+ </div>
+
<div id="footer-container"></div>
<script src="/footer.js" defer></script>
diff --git a/pages/pricing.html b/pages/pricing.html
index 7a19cbb51..4498084c2 100644
--- a/pages/pricing.html
+++ b/pages/pricing.html
@@ -116,7 +116,17 @@
<li>Advanced analytics dashboard</li>
<li>Priority email support &amp; SLA</li>
</ul>
- <a href="/login?plan=pro" class="pricing-cta primary" id="pro-cta">Choose Pro</a>
+ <!-- data-no-transition: the site-wide view-transition script intercepts
+ internal links at capture phase and navigates programmatically,
+ which would defeat this CTA's signed-in click handler (it opens
+ the checkout modal instead of navigating). -->
+ <a
+ href="/login?plan=pro"
+ class="pricing-cta primary"
+ id="pro-cta"
+ data-no-transition="1"
+ >Choose Pro</a
+ >
<div class="pricing-pay-assets" aria-label="Accepted payment assets">
Pay in <strong>USDC</strong>, <strong>SOL</strong>, or
<strong>$THREE</strong>
diff --git a/public/pricing.css b/public/pricing.css
index 7b4cade06..3d7ac05bc 100644
--- a/public/pricing.css
+++ b/public/pricing.css
@@ -1482,6 +1482,10 @@
.pc-sig-row { display: flex; gap: 8px; }
+/* .pricing-cta is width:100% by default — inside the signature row that
+ starves the input, so size the button to its label instead. */
+.pc-sig-row .pricing-cta { width: auto; flex-shrink: 0; }
+
.pc-sig-row input {
flex: 1;
min-width: 0;
diff --git a/scripts/mixamo-all.mjs b/scripts/mixamo-all.mjs
index 6c95834d8..ee223115f 100644
--- a/scripts/mixamo-all.mjs
+++ b/scripts/mixamo-all.mjs
@@ -132,6 +132,9 @@ const SOURCES_DIR = join(ROOT, 'animation-sources');
const LIBRARY_CONFIG_PATH = join(__dirname, 'mixamo-library.config.json');
const LIBRARY_STAGE_DIR = join(ROOT, 'animation-sources/.library-clips');
const LIBRARY_MANIFEST_PATH = join(LIBRARY_STAGE_DIR, 'manifest.json');
+// Poster thumbnails rendered by scripts/build-animation-thumbnails.mjs; each
+// uploads beside its clip and is published as the manifest entry's `thumb`.
+const LIBRARY_THUMBS_DIR = join(ROOT, 'animation-sources/.library-thumbs');
const UPLOAD_STATE_PATH = join(__dirname, 'mixamo-upload-state.json');
const LIBRARY_R2_PREFIX = 'animations/library';
@@ -653,6 +656,33 @@ async function uploadLibrary() {
const sha = createHash('sha1').update(body).digest('hex');
const key = `${LIBRARY_R2_PREFIX}/clips/${entry.name}.json`;
+ // Poster thumbnail (optional — clips without one simply publish no
+ // `thumb` and the gallery falls back to its icon placeholder).
+ const thumbFile = join(LIBRARY_THUMBS_DIR, `${entry.name}.webp`);
+ const thumbKey = `${LIBRARY_R2_PREFIX}/thumbs/${entry.name}.webp`;
+ let thumbUrl = null;
+ if (existsSync(thumbFile)) {
+ const thumbBody = readFileSync(thumbFile);
+ const thumbSha = createHash('sha1').update(thumbBody).digest('hex');
+ if (state[`thumb:${entry.name}`] === thumbSha) {
+ thumbUrl = `${publicDomain}/${thumbKey}`;
+ } else {
+ try {
+ await client.send(new PutObjectCommand({
+ Bucket: bucket,
+ Key: thumbKey,
+ Body: thumbBody,
+ ContentType: 'image/webp',
+ CacheControl: 'public, max-age=604800',
+ }));
+ state[`thumb:${entry.name}`] = thumbSha;
+ thumbUrl = `${publicDomain}/${thumbKey}`;
+ } catch (err) {
+ console.warn(`\n ⚠️ thumb ${entry.name}: ${err.message}`);
+ }
+ }
+ }
+
const clipMeta = {
name: entry.name,
label: entry.label,
@@ -662,6 +692,7 @@ async function uploadLibrary() {
...(entry.duration ? { duration: entry.duration } : {}),
bytes: body.length,
url: `${publicDomain}/${key}`,
+ ...(thumbUrl ? { thumb: thumbUrl } : {}),
};
if (state[entry.name] === sha) {
diff --git a/src/animation-categories.js b/src/animation-categories.js
index 47130a1cb..941008d4b 100644
--- a/src/animation-categories.js
+++ b/src/animation-categories.js
@@ -89,7 +89,7 @@ const RULES = [
],
[
'interaction',
- /\bcarry|lift(?:ing)?|pick(?:ing)? ?up|put(?:ting)? ?down|push(?:ing)?\b|pull(?:ing)?\b|open(?:ing)?\b|clos(?:e|ing)\b|door|button|lever|drink|eat(?:ing)?|phone|type|typing|keyboard|search(?:ing)?|inspect|grab(?:bing)?|throw(?:ing)?|toss(?:ing)?|catch(?:ing)?\b|hold(?:ing)?\b|torch|box(?:es)?\b|object|crate|drag(?:ging)?|hand ?off|give|take|steal|pay(?:ing)?|swipe|cpr|carried|carrying|picked up|placed|hostage|dice\b/,
+ /\bcarry|lift(?:ing)?|pick(?:ing)? ?up|put(?:ting)? ?down|push(?:ing)?\b|pull(?:ing)?\b|open(?:ing)?\b|clos(?:e|ing)\b|door|button|lever|drink|eat(?:ing)?|\bphone\b|\btyp(?:e|ing)\b|keyboard|search(?:ing)?|inspect|grab(?:bing)?|throw(?:ing)?|toss(?:ing)?|catch(?:ing)?\b|hold(?:ing)?\b|torch|box(?:es)?\b|object|crate|drag(?:ging)?|hand ?off|give|take|steal|pay(?:ing)?|swipe|cpr|carried|carrying|picked up|placed|hostage|dice\b/,
],
[
'locomotion',
diff --git a/src/animations-gallery.js b/src/animations-gallery.js
index 77e700ee8..1ea3954cd 100644
--- a/src/animations-gallery.js
+++ b/src/animations-gallery.js
@@ -6,74 +6,105 @@
// • The built-in three.ws motion library (/animations/manifest.json) — the
// same curated clips the /pose studio ships with. Always present.
// • The full motion library (GET /api/animations/library) — the complete
-// Mixamo-sourced catalog (~2,400 clips) hosted on the R2 CDN. Appears
-// only once populated; the endpoint returns an empty list until the
-// library pipeline (scripts/mixamo-all.mjs) has uploaded it.
+// Mixamo-sourced catalog (~2,000 clips) hosted on the R2 CDN.
//
-// All are normalized to one card shape, then filtered (search + loop/once) and
-// paginated entirely client-side — even the full catalog is just a few hundred
-// KB of metadata, so there's no need to round-trip the server on every keystroke.
+// All are normalized to one card shape — poster thumbnail, derived category
+// (src/animation-categories.js), duration, loop mode — then filtered (search +
+// category + loop/once), sorted, and paginated client-side; even the full
+// catalog is a few hundred KB of metadata.
//
-// Card actions:
-// • Preview (hover/click) — inline <iframe> of the embed viewer playing the
-// clip on a live avatar (/embed/avatar).
-// • Open in Studio — /pose?anim=<id>. A community UUID opens the saved
-// clip in the editor; a library name opens the matching preset.
+// Previews run through ONE shared WebGL engine (src/animations-live-preview.js):
+// hovering a card (or opening the detail modal) moves the singleton canvas into
+// that card and plays the retargeted clip on the preview avatar. No iframes,
+// no per-card GL contexts, nothing 3D loaded until the first preview.
+//
+// Deep links: ?clip=<id> opens the detail modal; q/cat/filter/sort round-trip
+// through the URL so filtered views are shareable.
+
+import { GALLERY_CATEGORIES, galleryCategoryOf } from './animation-categories.js';
+import { getLivePreview } from './animations-live-preview.js';
-const PREVIEW_MODEL = '/avatars/cz.glb';
const API_BASE = '/api/animations/clips';
const MANIFEST_URL = '/animations/manifest.json';
const LIBRARY_API = '/api/animations/library';
-const PAGE_SIZE = 24;
+const PAGE_SIZE = 36;
// Cap community pagination so a large catalog can't stall first paint.
const COMMUNITY_MAX = 300;
+const HOVER_DELAY_MS = 130;
+const REDUCED_MOTION = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
+const TOUCH_ONLY = window.matchMedia?.('(hover: none)').matches;
+
+const $ = (role) => document.querySelector(`[data-role="${role}"]`);
const els = {
- loading: document.querySelector('[data-role="loading"]'),
- grid: document.querySelector('[data-role="grid"]'),
- empty: document.querySelector('[data-role="empty"]'),
- emptySearch: document.querySelector('[data-role="empty-search"]'),
- emptySearchMsg: document.querySelector('[data-role="empty-search-msg"]'),
- clearSearch: document.querySelector('[data-role="clear-search"]'),
- error: document.querySelector('[data-role="error"]'),
- retry: document.querySelector('[data-role="retry"]'),
- search: document.querySelector('[data-role="search"]'),
- chips: document.querySelector('[data-role="chips"]'),
- loadMore: document.querySelector('[data-role="load-more"]'),
- loadMoreBtn: document.querySelector('[data-role="load-more-btn"]'),
- sentinel: document.querySelector('[data-role="sentinel"]'),
+ loading: $('loading'),
+ grid: $('grid'),
+ empty: $('empty'),
+ emptySearch: $('empty-search'),
+ emptySearchMsg: $('empty-search-msg'),
+ clearSearch: $('clear-search'),
+ error: $('error'),
+ retry: $('retry'),
+ search: $('search'),
+ chips: $('chips'),
+ typeFilter: $('type-filter'),
+ sort: $('sort'),
+ count: $('count'),
+ heroStats: $('hero-stats'),
+ loadMore: $('load-more'),
+ loadMoreBtn: $('load-more-btn'),
+ sentinel: $('sentinel'),
+ // Detail modal
+ modal: $('modal'),
+ modalStage: $('modal-stage'),
+ modalSpinner: $('modal-spinner'),
+ modalTitle: $('modal-title'),
+ modalMeta: $('modal-meta'),
+ modalTags: $('modal-tags'),
+ modalStudio: $('modal-studio'),
+ modalCopyLink: $('modal-copy-link'),
+ modalCopyEmbed: $('modal-copy-embed'),
+ modalPlay: $('modal-play'),
+ modalSpeed: $('modal-speed'),
+ modalSpeedVal: $('modal-speed-val'),
+ modalScrub: $('modal-scrub'),
+ modalTime: $('modal-time'),
+ modalClose: $('modal-close'),
+ modalPrev: $('modal-prev'),
+ modalNext: $('modal-next'),
+ modalError: $('modal-error'),
};
+const params = new URLSearchParams(location.search);
const state = {
- query: new URLSearchParams(location.search).get('q') || '',
- filter: new URLSearchParams(location.search).get('filter') || '',
- all: [], // normalized items from both sources (community first)
- filtered: [], // after search + loop/once filter
- shown: 0, // count currently rendered
+ query: params.get('q') || '',
+ filter: params.get('filter') || '', // '' | loop | once
+ category: params.get('cat') || '', // '' | GALLERY_CATEGORIES key
+ sort: params.get('sort') || 'featured',
+ all: [],
+ filtered: [],
+ shown: 0,
loaded: false,
+ modalIndex: -1, // index into state.filtered while the modal is open
};
+const live = getLivePreview();
+
if (state.query) els.search.value = state.query;
-syncChips();
+if (els.sort) els.sort.value = state.sort;
// ── URL state ──────────────────────────────────────────────────────────────
-function syncUrl() {
+function syncUrl(clipId) {
const p = new URLSearchParams();
if (state.query) p.set('q', state.query);
+ if (state.category) p.set('cat', state.category);
if (state.filter) p.set('filter', state.filter);
+ if (state.sort !== 'featured') p.set('sort', state.sort);
+ if (clipId) p.set('clip', clipId);
const qs = p.toString();
const next = qs ? `${location.pathname}?${qs}` : location.pathname;
- if (next !== location.pathname + location.search) {
- history.replaceState(null, '', next);
- }
-}
-
-function syncChips() {
- els.chips?.querySelectorAll('[data-filter]').forEach((btn) => {
- const active = btn.dataset.filter === state.filter;
- btn.setAttribute('aria-selected', String(active));
- });
+ if (next !== location.pathname + location.search) history.replaceState(null, '', next);
}
// ── Fetch + normalize ───────────────────────────────────────────────────────
@@ -89,11 +120,10 @@ async function fetchLibrary() {
async function fetchCommunity() {
const out = [];
let cursor = null;
- // Bounded cursor walk — at most COMMUNITY_MAX items.
while (out.length < COMMUNITY_MAX) {
- const params = new URLSearchParams({ include_public: 'true', visibility: 'public', limit: '50' });
- if (cursor) params.set('cursor', cursor);
- const res = await fetch(`${API_BASE}?${params}`, { credentials: 'include' });
+ const p = new URLSearchParams({ include_public: 'true', visibility: 'public', limit: '50' });
+ if (cursor) p.set('cursor', cursor);
+ const res = await fetch(`${API_BASE}?${p}`, { credentials: 'include' });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
const incoming = Array.isArray(data.items) ? data.items : [];
@@ -104,6 +134,13 @@ async function fetchCommunity() {
return out.slice(0, COMMUNITY_MAX).map(normalizeCommunityClip);
}
+async function fetchFullLibrary() {
+ const res = await fetch(LIBRARY_API);
+ if (!res.ok) throw new Error(`HTTP ${res.status}`);
+ const data = await res.json();
+ return (Array.isArray(data.clips) ? data.clips : []).map(normalizeFullLibraryClip);
+}
+
function normalizeLibraryClip(clip) {
return {
id: clip.name,
@@ -112,21 +149,14 @@ function normalizeLibraryClip(clip) {
loop: clip.loop !== false,
icon: clip.icon || '🎬',
tags: [],
- duration_ms: null,
- thumbnail_url: null,
+ category: galleryCategoryOf(clip.name, clip.label),
+ duration_ms: clip.duration ? Math.round(clip.duration * 1000) : null,
+ url: clip.url, // site-relative clip JSON — playable by the live preview
+ thumbnail_url: `/animations/thumbs/${encodeURIComponent(clip.name)}.webp`,
price: null,
};
}
-// The full R2-hosted catalog. Empty (and therefore absent from the grid)
-// until the library pipeline has uploaded it.
-async function fetchFullLibrary() {
- const res = await fetch(LIBRARY_API);
- if (!res.ok) throw new Error(`HTTP ${res.status}`);
- const data = await res.json();
- return (Array.isArray(data.clips) ? data.clips : []).map(normalizeFullLibraryClip);
-}
-
function normalizeFullLibraryClip(clip) {
return {
id: clip.name,
@@ -135,8 +165,15 @@ function normalizeFullLibraryClip(clip) {
loop: clip.loop !== false,
icon: clip.icon || '🎬',
tags: clip.category ? [clip.category] : [],
+ category: galleryCategoryOf(clip.name, clip.label),
duration_ms: clip.duration ? Math.round(clip.duration * 1000) : null,
- thumbnail_url: null,
+ url: clip.url, // absolute CDN url
+ // The library manifest publishes a `thumb` url per clip; older manifests
+ // predate thumbnails, so fall back to the CDN convention (thumbs live
+ // beside clips) and let the card's onerror show the icon placeholder.
+ thumbnail_url:
+ clip.thumb ||
+ (clip.url ? clip.url.replace('/clips/', '/thumbs/').replace(/\.json$/, '.webp') : null),
price: null,
};
}
@@ -149,7 +186,9 @@ function normalizeCommunityClip(clip) {
loop: clip.loop !== false,
icon: '🎬',
tags: Array.isArray(clip.tags) ? clip.tags : [],
+ category: galleryCategoryOf(clip.id, clip.name),
duration_ms: clip.duration_ms || null,
+ url: null, // fetched through /api/animations/clips/:id by the preview engine
thumbnail_url: clip.thumbnail_url || null,
price: clip.price || null,
};
@@ -176,26 +215,134 @@ async function loadAll() {
const curatedNames = new Set(library.map((c) => c.id));
state.all = [...community, ...library, ...full.filter((c) => !curatedNames.has(c.id))];
state.loaded = true;
+
+ renderHeroStats();
+ renderChips();
applyFilters();
+
+ // ?clip= deep link → open the modal once data exists.
+ const wanted = new URLSearchParams(location.search).get('clip');
+ if (wanted) {
+ const idx = state.filtered.findIndex((c) => c.id === wanted);
+ if (idx >= 0) openModal(idx);
+ else {
+ const item = state.all.find((c) => c.id === wanted);
+ if (item) {
+ // Visible under different filters — clear them so the link works.
+ state.query = '';
+ state.category = '';
+ state.filter = '';
+ els.search.value = '';
+ renderChips();
+ applyFilters();
+ openModal(state.filtered.findIndex((c) => c.id === wanted));
+ }
+ }
+ }
+}
+
+// ── Hero stats + chips ───────────────────────────────────────────────────────
+
+function renderHeroStats() {
+ if (!els.heroStats) return;
+ const total = state.all.length;
+ const community = state.all.filter((c) => c.source === 'community').length;
+ const cats = new Set(state.all.map((c) => c.category)).size;
+ els.heroStats.textContent = `${total.toLocaleString()} clips · ${cats} categories${
+ community ? ` · ${community} community-authored` : ''
+ }`;
+}
+
+function renderChips() {
+ if (!els.chips) return;
+ const counts = new Map();
+ for (const item of state.all) counts.set(item.category, (counts.get(item.category) || 0) + 1);
+ els.chips.innerHTML = '';
+ const mk = (key, label, icon, count) => {
+ const btn = document.createElement('button');
+ btn.className = 'ag-chip';
+ btn.setAttribute('role', 'tab');
+ btn.dataset.cat = key;
+ btn.setAttribute('aria-selected', String(state.category === key));
+ btn.innerHTML = `${icon ? `<span aria-hidden="true">${icon}</span> ` : ''}${escHtml(label)}${
+ count != null ? ` <span class="ag-chip-count">${count.toLocaleString()}</span>` : ''
+ }`;
+ els.chips.appendChild(btn);
+ };
+ mk('', 'All', '', state.all.length);
+ for (const cat of GALLERY_CATEGORIES) {
+ const n = counts.get(cat.key);
+ if (n) mk(cat.key, cat.label, cat.icon, n);
+ }
}
-// ── Filter + render ──────────────────────────────────────────────────────────
+function syncChips() {
+ els.chips?.querySelectorAll('[data-cat]').forEach((btn) => {
+ btn.setAttribute('aria-selected', String(btn.dataset.cat === state.category));
+ });
+}
+
+// ── Filter + sort + render ───────────────────────────────────────────────────
function applyFilters() {
const q = state.query.toLowerCase();
state.filtered = state.all.filter((item) => {
if (state.filter === 'loop' && !item.loop) return false;
if (state.filter === 'once' && item.loop) return false;
+ if (state.category && item.category !== state.category) return false;
if (q) {
- const hay = `${item.name} ${item.tags.join(' ')}`.toLowerCase();
+ const hay = `${item.name} ${item.tags.join(' ')} ${item.category}`.toLowerCase();
if (!hay.includes(q)) return false;
}
return true;
});
+ sortFiltered();
state.shown = 0;
+ renderCount();
renderGrid();
}
+function sortFiltered() {
+ const arr = state.filtered;
+ switch (state.sort) {
+ case 'az':
+ arr.sort((a, b) => a.name.localeCompare(b.name));
+ break;
+ case 'za':
+ arr.sort((a, b) => b.name.localeCompare(a.name));
+ break;
+ case 'shortest':
+ arr.sort((a, b) => (a.duration_ms ?? 1e9) - (b.duration_ms ?? 1e9));
+ break;
+ case 'longest':
+ arr.sort((a, b) => (b.duration_ms ?? -1) - (a.duration_ms ?? -1));
+ break;
+ case 'shuffle': {
+ // Deterministic per page load, reshuffled when re-selected.
+ for (let i = arr.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [arr[i], arr[j]] = [arr[j], arr[i]];
+ }
+ break;
+ }
+ default:
+ // 'featured' — the assembled source order (community → curated → catalog).
+ break;
+ }
+}
+
+function renderCount() {
+ if (!els.count) return;
+ if (!state.loaded) {
+ els.count.textContent = '';
+ return;
+ }
+ const n = state.filtered.length;
+ els.count.textContent = n === state.all.length
+ ? `${n.toLocaleString()} animations`
+ : `${n.toLocaleString()} of ${state.all.length.toLocaleString()}`;
+}
+
function renderGrid() {
if (state.filtered.length === 0) {
if (state.all.length === 0) {
@@ -204,8 +351,8 @@ function renderGrid() {
showState('empty-search');
if (els.emptySearchMsg) {
els.emptySearchMsg.textContent = state.query
- ? `No animations match "${state.query}".`
- : 'No animations match this filter.';
+ ? `No animations match “${state.query}”.`
+ : 'No animations match these filters.';
}
}
return;
@@ -215,11 +362,14 @@ function renderGrid() {
const start = state.shown;
const end = Math.min(start + PAGE_SIZE, state.filtered.length);
- if (start === 0) els.grid.innerHTML = '';
+ if (start === 0) {
+ live.stop();
+ els.grid.innerHTML = '';
+ }
const fragment = document.createDocumentFragment();
for (let i = start; i < end; i++) {
- fragment.appendChild(buildCard(state.filtered[i]));
+ fragment.appendChild(buildCard(state.filtered[i], i));
}
els.grid.appendChild(fragment);
state.shown = end;
@@ -232,103 +382,250 @@ function showMore() {
}
function fmtDuration(ms) {
+ if (ms == null) return '';
const s = ms / 1000;
if (s < 60) return `${s.toFixed(1)}s`;
const m = Math.floor(s / 60);
return `${m}m ${Math.round(s % 60)}s`;
}
-function buildCard(clip) {
+const CATEGORY_BY_KEY = new Map(GALLERY_CATEGORIES.map((c) => [c.key, c]));
+
+function sourceLabel(source) {
+ return source === 'community' ? 'Community' : source === 'mixamo' ? 'Mocap' : 'Studio';
+}
+
+// ── Card ────────────────────────────────────────────────────────────────────
+
+function buildCard(clip, index) {
const card = document.createElement('article');
card.className = 'ag-card';
- card.setAttribute('aria-label', clip.name || 'Animation');
+ card.dataset.index = String(index);
- const previewId = `ag-preview-${clip.source}-${clip.id}`;
+ const cat = CATEGORY_BY_KEY.get(clip.category);
const studioUrl = `/pose?anim=${encodeURIComponent(clip.id)}`;
- const loopBadge = clip.loop;
- const hasThumb = !!clip.thumbnail_url;
- const sourceLabel =
- clip.source === 'community' ? 'Community' : clip.source === 'mixamo' ? 'Library' : 'Built-in';
card.innerHTML = `
<div class="ag-card-preview" role="button" tabindex="0"
- aria-label="Preview ${escHtml(clip.name || 'animation')}"
- data-clip-id="${escHtml(clip.id)}">
- ${hasThumb
- ? `<img class="ag-card-thumb" src="${escHtml(clip.thumbnail_url)}" alt="" loading="lazy" />`
- : `<div class="ag-card-thumb-placeholder" aria-hidden="true">${escHtml(clip.icon || '🎬')}</div>`
- }
- <div class="ag-card-preview-overlay" id="${escHtml(previewId)}"></div>
- <div class="ag-play-hint" aria-hidden="true">
- <div class="ag-play-icon">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
- </div>
- </div>
+ aria-label="${escHtml(clip.name)} — open details">
+ ${clip.thumbnail_url
+ ? `<img class="ag-card-thumb" src="${escHtml(clip.thumbnail_url)}" alt="" loading="lazy" decoding="async" />`
+ : ''}
+ <div class="ag-card-thumb-fallback" aria-hidden="true" ${clip.thumbnail_url ? 'hidden' : ''}>${escHtml(clip.icon || '🎬')}</div>
+ <div class="ag-card-live" aria-hidden="true"></div>
+ <span class="ag-card-duration">${fmtDuration(clip.duration_ms)}</span>
+ ${clip.loop ? '' : '<span class="ag-card-once" title="Plays once">once</span>'}
+ ${clip.price ? `<span class="ag-card-price">$${(Number(clip.price.amount) / 1_000_000).toFixed(2)}</span>` : ''}
</div>
<div class="ag-card-meta">
- <h3 class="ag-card-title" title="${escHtml(clip.name || '')}">${escHtml(clip.name || 'Untitled')}</h3>
- <div class="ag-card-badges">
- <span class="ag-badge ${loopBadge ? 'ag-badge--loop' : 'ag-badge--once'}">${loopBadge ? 'loop' : 'once'}</span>
- <span class="ag-badge ag-badge--source">${sourceLabel}</span>
- ${clip.duration_ms ? `<span class="ag-badge">${fmtDuration(clip.duration_ms)}</span>` : ''}
- ${clip.price ? `<span class="ag-badge ag-badge--price">$${(Number(clip.price.amount) / 1_000_000).toFixed(2)}</span>` : ''}
+ <h3 class="ag-card-title" title="${escHtml(clip.name)}">${escHtml(clip.name)}</h3>
+ <div class="ag-card-sub">
+ <button class="ag-card-cat" data-cat-jump="${escHtml(clip.category)}"
+ title="Show all ${escHtml(cat?.label || 'More')} animations">${cat?.icon || ''} ${escHtml(cat?.label || 'More')}</button>
+ <span class="ag-card-source">${sourceLabel(clip.source)}</span>
</div>
- ${clip.tags?.length ? `<div class="ag-card-tags">${clip.tags.slice(0, 5).map((t) => `<span class="ag-tag">${escHtml(t)}</span>`).join('')}</div>` : ''}
<div class="ag-card-actions">
<a href="${escHtml(studioUrl)}" class="ag-card-btn ag-card-btn--primary"
- title="Open this animation in the Studio to remix or apply to your avatar">
- Open in Studio
- </a>
- <button class="ag-card-btn" data-preview="${escHtml(clip.id)}"
- title="Preview this animation on a live avatar"
- aria-label="Preview ${escHtml(clip.name || 'animation')}">
- Preview
- </button>
+ title="Open this animation in the Studio to remix or apply to your avatar">Open in Studio</a>
+ <button class="ag-card-btn" data-details
+ aria-label="Details and preview for ${escHtml(clip.name)}">Details</button>
</div>
</div>
`;
- // Preview on hover (desktop) — lazy-load the embed iframe once.
const previewZone = card.querySelector('.ag-card-preview');
- const overlay = card.querySelector('.ag-card-preview-overlay');
- let iframeLoaded = false;
-
- const launchPreview = () => {
- if (!iframeLoaded) {
- iframeLoaded = true;
- const iframe = document.createElement('iframe');
- iframe.src = `/embed/avatar?model=${encodeURIComponent(PREVIEW_MODEL)}&anim=${encodeURIComponent(clip.id)}&hide-chrome=1&idle=off&bg=transparent`;
- iframe.title = `Preview: ${clip.name || 'animation'}`;
- iframe.setAttribute('loading', 'lazy');
- iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
- overlay.appendChild(iframe);
- }
- overlay.classList.add('is-active');
- };
+ const liveHost = card.querySelector('.ag-card-live');
+ const img = card.querySelector('.ag-card-thumb');
+ const fallback = card.querySelector('.ag-card-thumb-fallback');
+ if (img && fallback) {
+ img.addEventListener('error', () => {
+ img.remove();
+ fallback.hidden = false;
+ });
+ }
- previewZone.addEventListener('mouseenter', launchPreview);
- previewZone.addEventListener('click', launchPreview);
+ // Hover → live preview through the shared engine (skipped for touch and
+ // reduced-motion users; both get the full preview in the details modal).
+ if (!TOUCH_ONLY && !REDUCED_MOTION) {
+ let hoverTimer = 0;
+ previewZone.addEventListener('mouseenter', () => {
+ hoverTimer = setTimeout(() => {
+ card.classList.add('is-loading-preview');
+ live
+ .play(liveHost, clip)
+ .then(() => {
+ if (live.active === clip) card.classList.add('is-live');
+ })
+ .catch(() => {})
+ .finally(() => card.classList.remove('is-loading-preview'));
+ }, HOVER_DELAY_MS);
+ });
+ previewZone.addEventListener('mouseleave', () => {
+ clearTimeout(hoverTimer);
+ card.classList.remove('is-live', 'is-loading-preview');
+ if (live.active === clip) live.stop();
+ });
+ }
+
+ const open = () => openModal(index);
+ previewZone.addEventListener('click', open);
previewZone.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
- launchPreview();
+ open();
}
});
- previewZone.addEventListener('mouseleave', () => {
- overlay.classList.remove('is-active');
- });
-
- // "Preview" button — same behavior as hover.
- card.querySelector('[data-preview]')?.addEventListener('click', (e) => {
- e.preventDefault();
- launchPreview();
+ card.querySelector('[data-details]').addEventListener('click', open);
+ card.querySelector('[data-cat-jump]').addEventListener('click', (e) => {
+ state.category = e.currentTarget.dataset.catJump || '';
+ syncChips();
+ syncUrl();
+ applyFilters();
+ window.scrollTo({ top: 0, behavior: 'smooth' });
});
return card;
}
function escHtml(s) {
- return String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+ return String(s ?? '')
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}
+
+// ── Detail modal ─────────────────────────────────────────────────────────────
+
+function openModal(index) {
+ const clip = state.filtered[index];
+ if (!clip || !els.modal) return;
+ state.modalIndex = index;
+
+ els.modalTitle.textContent = clip.name;
+ const cat = CATEGORY_BY_KEY.get(clip.category);
+ els.modalMeta.innerHTML = [
+ cat ? `${cat.icon} ${escHtml(cat.label)}` : null,
+ clip.duration_ms ? escHtml(fmtDuration(clip.duration_ms)) : null,
+ clip.loop ? 'loops' : 'plays once',
+ escHtml(sourceLabel(clip.source)),
+ ]
+ .filter(Boolean)
+ .map((x) => `<span>${x}</span>`)
+ .join('<span class="ag-dot" aria-hidden="true">·</span>');
+ els.modalTags.innerHTML = clip.tags?.length
+ ? clip.tags.slice(0, 8).map((t) => `<span class="ag-tag">${escHtml(t)}</span>`).join('')
+ : '';
+ els.modalStudio.href = `/pose?anim=${encodeURIComponent(clip.id)}`;
+ els.modalError.hidden = true;
+ els.modalSpinner.hidden = false;
+ els.modalPrev.disabled = index <= 0;
+ els.modalNext.disabled = index >= state.filtered.length - 1;
+
+ // Transport defaults.
+ els.modalSpeed.value = '1';
+ els.modalSpeedVal.textContent = '1×';
+ els.modalScrub.value = '0';
+ setPlayIcon(false);
+
+ els.modal.hidden = false;
+ document.body.style.overflow = 'hidden';
+ els.modalClose.focus();
+ syncUrl(clip.id);
+
+ let scrubbing = false;
+ els.modalScrub.oninput = () => {
+ scrubbing = true;
+ live.seek(Number(els.modalScrub.value) / 1000);
+ };
+ els.modalScrub.onchange = () => {
+ scrubbing = false;
+ };
+
+ live
+ .play(els.modalStage, clip, {
+ onFrame: (t, d) => {
+ if (!scrubbing && d > 0) {
+ els.modalScrub.value = String(Math.round(((t % d) / d) * 1000));
+ els.modalTime.textContent = `${(t % d).toFixed(1)}s / ${d.toFixed(1)}s`;
+ }
+ },
+ })
+ .then(() => {
+ els.modalSpinner.hidden = true;
+ live.refit();
+ })
+ .catch(() => {
+ els.modalSpinner.hidden = true;
+ els.modalError.hidden = false;
+ });
+}
+
+function closeModal() {
+ if (els.modal.hidden) return;
+ els.modal.hidden = true;
+ document.body.style.overflow = '';
+ live.stop();
+ state.modalIndex = -1;
+ syncUrl();
+}
+
+function stepModal(delta) {
+ const next = state.modalIndex + delta;
+ if (next < 0 || next >= state.filtered.length) return;
+ // Ensure the card list has rendered far enough that "next" stays in sync
+ // with what the user returns to after closing.
+ while (state.shown <= next && state.shown < state.filtered.length) showMore();
+ openModal(next);
+}
+
+function setPlayIcon(paused) {
+ els.modalPlay.innerHTML = paused
+ ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><polygon points="5 3 19 12 5 21 5 3"/></svg>'
+ : '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="4" width="5" height="16"/><rect x="14" y="4" width="5" height="16"/></svg>';
+ els.modalPlay.setAttribute('aria-label', paused ? 'Play' : 'Pause');
+}
+
+els.modalPlay?.addEventListener('click', () => {
+ const paused = !live.isPaused();
+ live.setPaused(paused);
+ setPlayIcon(paused);
+});
+els.modalSpeed?.addEventListener('input', () => {
+ const f = Number(els.modalSpeed.value);
+ live.setSpeed(f);
+ els.modalSpeedVal.textContent = `${f}×`;
+});
+els.modalClose?.addEventListener('click', closeModal);
+els.modalPrev?.addEventListener('click', () => stepModal(-1));
+els.modalNext?.addEventListener('click', () => stepModal(1));
+els.modal?.addEventListener('click', (e) => {
+ if (e.target === els.modal) closeModal();
+});
+els.modalCopyLink?.addEventListener('click', async () => {
+ const clip = state.filtered[state.modalIndex];
+ if (!clip) return;
+ const url = `${location.origin}/animations?clip=${encodeURIComponent(clip.id)}`;
+ await navigator.clipboard.writeText(url).catch(() => {});
+ flashButton(els.modalCopyLink, 'Copied!');
+});
+els.modalCopyEmbed?.addEventListener('click', async () => {
+ const clip = state.filtered[state.modalIndex];
+ if (!clip) return;
+ const src = `${location.origin}/embed/avatar?anim=${encodeURIComponent(clip.id)}`;
+ const snippet = `<iframe src="${src}" width="360" height="480" style="border:0;border-radius:12px" allow="autoplay" title="${clip.name} — three.ws"></iframe>`;
+ await navigator.clipboard.writeText(snippet).catch(() => {});
+ flashButton(els.modalCopyEmbed, 'Copied!');
+});
+
+function flashButton(btn, msg) {
+ const prev = btn.textContent;
+ btn.textContent = msg;
+ btn.disabled = true;
+ setTimeout(() => {
+ btn.textContent = prev;
+ btn.disabled = false;
+ }, 1200);
}
// ── State display ──────────────────────────────────────────────────────────
@@ -351,29 +648,49 @@ els.search?.addEventListener('input', () => {
state.query = els.search.value.trim();
syncUrl();
if (state.loaded) applyFilters();
- }, 200);
+ }, 180);
});
els.chips?.addEventListener('click', (e) => {
+ const btn = e.target.closest('[data-cat]');
+ if (!btn) return;
+ state.category = btn.dataset.cat;
+ syncChips();
+ syncUrl();
+ if (state.loaded) applyFilters();
+});
+
+els.typeFilter?.addEventListener('click', (e) => {
const btn = e.target.closest('[data-filter]');
if (!btn) return;
state.filter = btn.dataset.filter;
+ els.typeFilter.querySelectorAll('[data-filter]').forEach((b) => {
+ b.setAttribute('aria-pressed', String(b === btn));
+ });
+ syncUrl();
+ if (state.loaded) applyFilters();
+});
+
+els.sort?.addEventListener('change', () => {
+ state.sort = els.sort.value;
syncUrl();
- syncChips();
if (state.loaded) applyFilters();
});
els.clearSearch?.addEventListener('click', () => {
state.query = '';
state.filter = '';
+ state.category = '';
els.search.value = '';
- syncUrl();
+ els.typeFilter?.querySelectorAll('[data-filter]').forEach((b) => {
+ b.setAttribute('aria-pressed', String(b.dataset.filter === ''));
+ });
syncChips();
+ syncUrl();
if (state.loaded) applyFilters();
});
els.retry?.addEventListener('click', () => loadAll());
-
els.loadMoreBtn?.addEventListener('click', showMore);
// Infinite scroll sentinel.
@@ -382,11 +699,33 @@ if ('IntersectionObserver' in window && els.sentinel) {
(entries) => {
if (entries[0].isIntersecting) showMore();
},
- { rootMargin: '300px' },
+ { rootMargin: '600px' },
);
observer.observe(els.sentinel);
}
+// ── Keyboard ────────────────────────────────────────────────────────────────
+
+document.addEventListener('keydown', (e) => {
+ if (!els.modal.hidden) {
+ if (e.key === 'Escape') closeModal();
+ else if (e.key === 'ArrowLeft') stepModal(-1);
+ else if (e.key === 'ArrowRight') stepModal(1);
+ else if (e.key === ' ' && e.target === document.body) {
+ e.preventDefault();
+ els.modalPlay.click();
+ }
+ return;
+ }
+ const typing = /^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName || '');
+ if (e.key === '/' && !typing) {
+ e.preventDefault();
+ els.search.focus();
+ } else if (e.key === 'Escape' && typing && document.activeElement === els.search) {
+ els.search.blur();
+ }
+});
+
// ── Boot ───────────────────────────────────────────────────────────────────
loadAll();
diff --git a/tests/animation-categories.test.js b/tests/animation-categories.test.js
new file mode 100644
index 000000000..4bff9d136
--- /dev/null
+++ b/tests/animation-categories.test.js
@@ -0,0 +1,83 @@
+/**
+ * Gallery category classifier — unit tests.
+ *
+ * The /animations gallery derives a category for every clip from its label
+ * (the Mixamo catalog ships none). These tests pin the rule ordering that
+ * makes labels file where a human would put them — "Zombie Walk" is creature,
+ * not locomotion; "Rifle Run" is weapons — plus the curated-name passthrough
+ * and full-coverage guarantees over the real staged library manifest when it
+ * is present on disk.
+ */
+
+import { existsSync, readFileSync } from 'node:fs';
+import { describe, it, expect } from 'vitest';
+import { GALLERY_CATEGORIES, galleryCategoryOf } from '../src/animation-categories.js';
+
+const KEYS = new Set(GALLERY_CATEGORIES.map((c) => c.key));
+
+describe('galleryCategoryOf', () => {
+ it('classifies representative labels where a human would file them', () => {
+ expect(galleryCategoryOf('mx-x', 'Hip Hop Dancing')).toBe('dance');
+ expect(galleryCategoryOf('mx-x', 'Walking')).toBe('locomotion');
+ expect(galleryCategoryOf('mx-x', '135 Degree Left Turn')).toBe('locomotion');
+ expect(galleryCategoryOf('mx-x', 'Idle')).toBe('idle');
+ expect(galleryCategoryOf('mx-x', 'Boxing Jab Cross')).toBe('combat');
+ expect(galleryCategoryOf('mx-x', 'Rifle Aiming Idle')).toBe('weapons');
+ expect(galleryCategoryOf('mx-x', 'Great Sword Slash')).toBe('weapons');
+ expect(galleryCategoryOf('mx-x', 'Soccer Penalty Kick')).toBe('sport');
+ expect(galleryCategoryOf('mx-x', 'Back Flip To Uppercut')).toBe('acrobatics');
+ expect(galleryCategoryOf('mx-x', 'Dying Backwards')).toBe('death');
+ expect(galleryCategoryOf('mx-x', 'Sitting Idle')).toBe('sit');
+ expect(galleryCategoryOf('mx-x', 'Push Up')).toBe('fitness');
+ expect(galleryCategoryOf('mx-x', 'Waving Hello')).toBe('gesture');
+ expect(galleryCategoryOf('mx-x', 'Reaction To Getting Clipped While Walking Unaware')).toBe(
+ 'reaction',
+ );
+ });
+
+ it('orders rules so compound labels land in the dominant concept', () => {
+ // creature beats locomotion
+ expect(galleryCategoryOf('mx-x', 'Zombie Walking')).toBe('creature');
+ // weapons beats locomotion
+ expect(galleryCategoryOf('mx-x', 'Running With Rifle Down')).toBe('weapons');
+ // dance beats locomotion
+ expect(galleryCategoryOf('mx-x', 'Swing Dancing')).toBe('dance');
+ });
+
+ it('passes curated studio names through their hand-assigned category', () => {
+ // From animation-presets.js CLIP_CATEGORIES — no keyword guessing.
+ expect(galleryCategoryOf('av-boxer-dance', 'Boxer Dance')).toBe('dance');
+ expect(galleryCategoryOf('idle', 'Idle')).toBe('idle');
+ // Curated 'action' key maps onto the gallery's 'combat'.
+ expect(galleryCategoryOf('av-muay-thai', 'Muay Thai')).toBe('combat');
+ });
+
+ it('falls back to "more" for labels no rule matches', () => {
+ expect(galleryCategoryOf('mx-x', 'Xylophone Solo Nonsense')).toBe('more');
+ expect(galleryCategoryOf('mx-x', '')).toBe('more');
+ expect(galleryCategoryOf(undefined, undefined)).toBe('more');
+ });
+
+ it('always returns a declared category key', () => {
+ const labels = ['Walk', 'Rifle Run', 'Salsa', '???', 'Casting A Spell', 'Zombie Scream'];
+ for (const label of labels) {
+ expect(KEYS.has(galleryCategoryOf('mx-x', label))).toBe(true);
+ }
+ });
+
+ // Full-coverage guarantee over the real library, when the gitignored staged
+ // manifest exists locally (CI checkouts without it skip this block).
+ const STAGED = 'animation-sources/.library-clips/manifest.json';
+ it.skipIf(!existsSync(STAGED))('covers the full staged library sanely', () => {
+ const manifest = JSON.parse(readFileSync(STAGED, 'utf8'));
+ const counts = new Map();
+ for (const clip of manifest) {
+ const key = galleryCategoryOf(clip.name, clip.label);
+ expect(KEYS.has(key)).toBe(true);
+ counts.set(key, (counts.get(key) || 0) + 1);
+ }
+ // The catch-all must stay a tail, not a dumping ground.
+ const more = counts.get('more') || 0;
+ expect(more / manifest.length).toBeLessThan(0.1);
+ });
+});