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.

Add a Community tab to the dashboard Avatars page; persist seed model_category

nirholas501ae1d3400e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b101ef657..8d19ca488 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Agents and items are now clearly separate — a teapot won't get a brain** — Every 3D model you create is now clearly one of two things: an Agent (a character that thinks, talks, remembers, and can go on-chain) or an Item (a 3D object or prop for scenes and trading). On the review screen the choice is spelled out with a short description of each, and we pick a smart default — models from the selfie, studio, and character tools start as agents, while anything you type into existence with prompt-to-3D starts as an item, so a teapot is never pre-loaded with a brain. Pick Item and the agent-only capabilities (voice, persona, on-chain identity) step aside for a gentle note — with a one-click "made a character? make it an agent" escape hatch if the guess was wrong. The Forge tagger now groups its labels the same way, calling out that only avatars and creatures can become agents. (`/create`) `[improvement]`
- **Agents can autonomously trade USDC-paired coins** — An agent's own wallet can now buy and sell USDC-paired coins on its own — not just SOL ones. Until now the autonomous lanes (an agent's buy/sell endpoints, scheduled buybacks, and creator-fee distributions) assumed every coin priced in SOL, so on a USDC coin they would have built a SOL trade the market refuses. Now the agent reads each coin's real pairing straight from the chain and trades in the matching currency: a USDC coin is bought and sold in USDC, with the agent's USDC account opened automatically and its balance checked up front so a trade fails clearly instead of reverting on-chain. Buybacks and fee distributions follow the same rule — they run in the coin's own currency, and if a coin's setup genuinely can't support a run, it's recorded with the reason rather than silently skipped. Every trade is now logged with the exact quote asset and amount, so prices and volumes stay correct for USDC and SOL coins alike. SOL coins behave exactly as before. (`/pump-dashboard`) `[feature]`
- **Autonomous coin buybacks and creator-fee distributions now run on schedule** — Coins launched through three.ws with autopilot enabled now have their buybacks and creator-fee distributions executed automatically on an hourly schedule, instead of waiting for a manual trigger. A new balance watchdog checks every Solana signer the platform uses to pay on-chain fees and alerts the team the moment one runs low, so autopilot never silently stalls for lack of gas. No action needed from coin owners — it just works in the background. `[improvement, infra]`
+- **Browse every community avatar from your dashboard** — The dashboard Avatars page now has a Community tab alongside My avatars. It shows every public 3D avatar the whole community has built — with live spinning previews, a running count and total views, search, tag filters, and infinite scroll. Open any one as a live page, remix it in the 3D studio, or copy its share link, embed snippet, or GLB URL in a click. (`/dashboard/avatars`) `[feature]`
- **Buy and sell USDC-paired coins straight from the trade widget** — The in-world trade widget now speaks both currencies. Open Buy on a coin and the widget reads its real pairing from the chain: a SOL coin asks for SOL exactly as before, while a USDC-paired coin denominates the amount in USDC, shows your wallet's USDC balance, and prices and settles the trade in USDC. A new Sell tab lets you sell a coin you hold back to its quote asset — pick 25%, 50%, or Max of your balance, see the live payout, and sign once; for USDC coins the payout account is opened for you automatically in the same transaction. Every state is handled: not enough USDC offers a one-tap Add-funds flow, a moved price explains your slippage, and a cancelled signature is quietly acknowledged. The whole flow is your own wallet, signed in your browser, with a Solscan link the moment it lands. (`/play`) `[feature]`
- **Chat never stalls on a down AI model — instant, quiet failover** — If you pick a specific AI model for the agent (say Claude) and our key for that provider is temporarily unavailable, chat now hands you an answer instantly from a healthy free model instead of pausing on the dead provider. Previously the app re-tried the unavailable provider on the very first attempt of every single message — adding a little delay each time and filling our logs with repeat warnings. Now a provider with a key or billing problem is set aside for a few minutes after the first failure and skipped up front, even when it was the one you explicitly chose, so the next message goes straight to a model that works. Free-first, always a working fallback. (`/chat`) `[improvement]`
- **Clearer launch & trade errors, and a graduated badge on coins** — When a token launch or an in-world trade can't go through, the app now tells you exactly why and what to do next — "Not enough SOL to cover the launch + network fees," "Price moved beyond your slippage limit," "You cancelled the signature in your wallet," or "Couldn't reach the Solana network" — instead of a single catch-all "Connection error." Coins also show their lifecycle at a glance: the trade panel carries a badge marking whether a coin is still on its bonding curve or has graduated to the PumpSwap AMM, so a graduated coin is unmistakable. Backed by new end-to-end browser tests that drive the full four-step launch flow and the buy/sell widget so this conversion path can't silently break. (`/pump-dashboard`) `[improvement]`
diff --git a/api/cron/forge-seed-cron.js b/api/cron/forge-seed-cron.js
index 6768cdb2d..34c96b6b6 100644
--- a/api/cron/forge-seed-cron.js
+++ b/api/cron/forge-seed-cron.js
@@ -86,7 +86,7 @@ async function pollPending(origin) {
insert into avatars
(owner_id, slug, name, description, storage_key, size_bytes,
content_type, source, source_meta, visibility, tags,
- created_at, updated_at)
+ model_category, created_at, updated_at)
select
${job.user_id},
${toSlug(job.prompt)},
@@ -99,6 +99,7 @@ async function pollPending(origin) {
${JSON.stringify({ forge_creation_id: creationId, prompt: job.prompt, seed: true })}::jsonb,
'public',
array[${job.model_category}]::text[],
+ ${job.model_category},
now(), now()
from forge_creations fc
where fc.id = ${creationId}
diff --git a/data/changelog.json b/data/changelog.json
index 255afa0b7..1a93a575b 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,13 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-15",
+ "title": "Browse every community avatar from your dashboard",
+ "summary": "The dashboard Avatars page now has a Community tab alongside My avatars. It shows every public 3D avatar the whole community has built — with live spinning previews, a running count and total views, search, tag filters, and infinite scroll. Open any one as a live page, remix it in the 3D studio, or copy its share link, embed snippet, or GLB URL in a click.",
+ "tags": ["feature"],
+ "link": "/dashboard/avatars"
+ },
{
"date": "2026-06-15",
"title": "The top navigation is back on every page",
diff --git a/public/changelog.json b/public/changelog.json
index 72d7a3ab6..d045e1eaa 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-15T08:30:29.407Z",
+ "generated_at": "2026-06-15T10:14:40.135Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -58,6 +58,16 @@
"infra"
]
},
+ {
+ "date": "2026-06-15",
+ "type": "update",
+ "title": "Browse every community avatar from your dashboard",
+ "summary": "The dashboard Avatars page now has a Community tab alongside My avatars. It shows every public 3D avatar the whole community has built — with live spinning previews, a running count and total views, search, tag filters, and infinite scroll. Open any one as a live page, remix it in the 3D studio, or copy its share link, embed snippet, or GLB URL in a click.",
+ "link": "/dashboard/avatars",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-06-15",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 7778dbe7d..0d5f402b6 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -46,6 +46,14 @@
<category>improvement</category>
<description>Coins launched through three.ws with autopilot enabled now have their buybacks and creator-fee distributions executed automatically on an hourly schedule, instead of waiting for a manual trigger. A new balance watchdog checks every Solana signer the platform uses to pay on-chain fees and alerts the team the moment one runs low, so autopilot never silently stalls for lack of gas. No action needed from coin owners — it just works in the background.</description>
</item>
+ <item>
+ <title>Browse every community avatar from your dashboard</title>
+ <link>https://three.ws/dashboard/avatars</link>
+ <guid isPermaLink="false">2026-06-15:Browse every community avatar from your dashboard</guid>
+ <pubDate>Mon, 15 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>The dashboard Avatars page now has a Community tab alongside My avatars. It shows every public 3D avatar the whole community has built — with live spinning previews, a running count and total views, search, tag filters, and infinite scroll. Open any one as a live page, remix it in the 3D studio, or copy its share link, embed snippet, or GLB URL in a click.</description>
+ </item>
<item>
<title>Buy and sell USDC-paired coins straight from the trade widget</title>
<link>https://three.ws/play</link>
diff --git a/public/features.json b/public/features.json
index 3494931bf..7f7576438 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-15T08:30:29.394Z",
+ "generated_at": "2026-06-15T10:14:40.116Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/dashboard-next/pages/avatars.js b/src/dashboard-next/pages/avatars.js
index a3c4f1abd..748de5c1e 100644
--- a/src/dashboard-next/pages/avatars.js
+++ b/src/dashboard-next/pages/avatars.js
@@ -10,6 +10,7 @@ import { requireUser, get, patch, del, esc, relTime, ApiError } from '../api.js'
import { openSelfieModal } from '../../selfie-modal.js';
import { openAvatarPicker } from '../../avatar-gallery-picker.js';
import { createFromTemplate } from '../../shared/template-picker.js';
+import { onchainBadgeHTML, ensureOnchainBadgeStyles } from '../../shared/onchain-badge.js';
const PAGE_SIZE = 24;
const VISIBILITIES = ['public', 'unlisted', 'private'];
@@ -19,25 +20,51 @@ const SORTS = [
{ key: 'name_asc', label: 'Name A→Z', cmp: (a, b) => (a.name || '').localeCompare(b.name || '') },
{ key: 'name_desc', label: 'Name Z→A', cmp: (a, b) => (b.name || '').localeCompare(a.name || '') },
];
+// Community sorts apply client-side over already-loaded public avatars. The
+// public feed is server-ordered newest-first, so "newest" is the natural pass.
+const COMMUNITY_SORTS = [
+ { key: 'newest', label: 'Newest', cmp: (a, b) => ts(b.created_at) - ts(a.created_at) },
+ { key: 'views', label: 'Most viewed', cmp: (a, b) => (Number(b.view_count) || 0) - (Number(a.view_count) || 0) },
+ { key: 'name_asc', label: 'Name A→Z', cmp: (a, b) => (a.name || '').localeCompare(b.name || '') },
+];
+
+const compactNum = new Intl.NumberFormat('en', { notation: 'compact', maximumFractionDigits: 1 });
+const integerNum = new Intl.NumberFormat('en');
const state = {
+ tab: /** @type {'mine'|'community'} */ ('mine'),
all: /** @type {any[]} */ ([]),
nextCursor: /** @type {string|null} */ (null),
loadingMore: false,
filter: { q: '', visibility: 'all', sort: 'newest' },
io: /** @type {IntersectionObserver|null} */ (null),
+ // Community ("all public avatars") view — independent data + filter slice so
+ // switching tabs never clobbers the user's own list state.
+ community: {
+ all: /** @type {any[]} */ ([]),
+ nextCursor: /** @type {string|null} */ (null),
+ loading: false,
+ loaded: false,
+ total: /** @type {number|null} */ (null),
+ totalViews: /** @type {number|null} */ (null),
+ loadedTags: /** @type {Set<string>} */ (new Set()),
+ filter: { q: '', tag: '', sort: 'newest' },
+ io: /** @type {IntersectionObserver|null} */ (null),
+ searchTimer: /** @type {any} */ (null),
+ },
};
(async function boot() {
const main = await mountShell();
await requireUser();
injectStyles();
+ ensureOnchainBadgeStyles();
main.innerHTML = `
<div class="dn-av-head">
<div>
<h1 class="dn-h1">Avatars</h1>
- <p class="dn-h1-sub">Your 3D models, animated and ready to embed.</p>
+ <p class="dn-h1-sub" data-subtitle>Your 3D models, animated and ready to embed.</p>
</div>
<div class="dn-av-new-wrap">
<button class="dn-btn primary" type="button" data-new>+ New avatar</button>
@@ -57,7 +84,15 @@ const state = {
</div>
</div>
- <div class="dn-av-filters" data-filters>
+ <div class="dn-av-tabs" role="tablist" aria-label="Avatar source">
+ <button type="button" class="dn-av-tab active" data-tab="mine" role="tab" aria-selected="true">My avatars</button>
+ <button type="button" class="dn-av-tab" data-tab="community" role="tab" aria-selected="false">
+ Community
+ <span class="dn-av-tab-count" data-community-count hidden></span>
+ </button>
+ </div>
+
+ <div class="dn-av-filters" data-filters-mine>
<label class="dn-av-search">
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3"/></svg>
<input type="search" placeholder="Search avatars by name…" data-q autocomplete="off" />
@@ -74,17 +109,90 @@ const state = {
</label>
</div>
+ <div class="dn-av-filters" data-filters-community hidden>
+ <label class="dn-av-search">
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3"/></svg>
+ <input type="search" placeholder="Search the community gallery…" data-cq autocomplete="off" />
+ </label>
+ <label class="dn-av-sort">
+ <select data-csort aria-label="Sort community avatars">
+ ${COMMUNITY_SORTS.map((s) => `<option value="${s.key}">${s.label}</option>`).join('')}
+ </select>
+ </label>
+ <span class="dn-av-community-stat" data-community-stat aria-live="polite"></span>
+ </div>
+
+ <div class="dn-av-tags" data-community-tags hidden aria-label="Tag filters"></div>
+
<div data-error hidden></div>
<div class="dn-av-grid" data-grid></div>
<div class="dn-av-loadmore" data-loadmore hidden></div>
<div class="dn-av-toaster" data-toaster aria-live="polite"></div>
`;
+ wireTabs(main);
wireFilters(main);
+ wireCommunityFilters(main);
wireNewMenu(main);
await loadInitial(main);
})();
+// ── Tab switching ────────────────────────────────────────────────────────
+
+function wireTabs(root) {
+ const tabs = root.querySelectorAll('[data-tab]');
+ tabs.forEach((btn) => {
+ btn.addEventListener('click', () => switchTab(root, btn.getAttribute('data-tab')));
+ });
+}
+
+function switchTab(root, tab) {
+ if (tab === state.tab) return;
+ state.tab = tab;
+
+ root.querySelectorAll('[data-tab]').forEach((b) => {
+ const on = b.getAttribute('data-tab') === tab;
+ b.classList.toggle('active', on);
+ b.setAttribute('aria-selected', on ? 'true' : 'false');
+ });
+
+ const mineFilters = root.querySelector('[data-filters-mine]');
+ const communityFilters = root.querySelector('[data-filters-community]');
+ const communityTags = root.querySelector('[data-community-tags]');
+ const newWrap = root.querySelector('.dn-av-new-wrap');
+ const subtitle = root.querySelector('[data-subtitle]');
+ const isCommunity = tab === 'community';
+
+ mineFilters.hidden = isCommunity;
+ communityFilters.hidden = !isCommunity;
+ communityTags.hidden = !isCommunity;
+ if (newWrap) newWrap.style.display = isCommunity ? 'none' : '';
+ if (subtitle) {
+ subtitle.textContent = isCommunity
+ ? 'Every public avatar the community has built — remix, embed, or open any of them.'
+ : 'Your 3D models, animated and ready to embed.';
+ }
+
+ closeOpenMenu();
+ hideError(root);
+ // Force the grid to rebuild — mine and community share the same container.
+ const grid = root.querySelector('[data-grid]');
+ grid.dataset.ids = '';
+
+ if (isCommunity) {
+ if (state.community.loaded) {
+ renderCommunityGrid(root);
+ setupCommunityLoadMore(root);
+ } else {
+ loadCommunityInitial(root);
+ }
+ } else {
+ teardownCommunityObserver();
+ renderGrid(root);
+ setupLoadMore(root);
+ }
+}
+
// ── Data loading ─────────────────────────────────────────────────────────
async function loadInitial(root) {
@@ -131,8 +239,101 @@ async function loadMore(root) {
}
}
+// ── Community data loading ────────────────────────────────────────────────
+
+async function loadCommunityInitial(root) {
+ const c = state.community;
+ const grid = root.querySelector('[data-grid]');
+ renderSkeletons(grid, 8);
+ hideError(root);
+ c.all = [];
+ c.nextCursor = null;
+ c.loaded = false;
+
+ try {
+ const params = new URLSearchParams({ limit: String(PAGE_SIZE), totals: '1' });
+ if (c.filter.q) params.set('q', c.filter.q);
+ if (c.filter.tag) params.set('tag', c.filter.tag);
+ const data = await get(`/api/avatars/public?${params.toString()}`);
+ const rows = Array.isArray(data?.avatars) ? data.avatars : [];
+ c.all = rows;
+ c.nextCursor = data?.next_cursor || null;
+ c.total = typeof data?.total === 'number' ? data.total : null;
+ c.totalViews = typeof data?.total_views === 'number' ? data.total_views : null;
+ c.loaded = true;
+ rows.forEach((a) => (a.tags || []).forEach((t) => c.loadedTags.add(t)));
+ updateCommunityCount(root);
+ renderCommunityTags(root);
+ renderCommunityGrid(root);
+ setupCommunityLoadMore(root);
+ } catch (err) {
+ showError(root, err, () => loadCommunityInitial(root));
+ grid.innerHTML = '';
+ }
+}
+
+async function loadCommunityMore(root) {
+ const c = state.community;
+ if (!c.nextCursor || c.loading) return;
+ c.loading = true;
+ const btn = root.querySelector('[data-loadmore-btn]');
+ if (btn) {
+ btn.disabled = true;
+ btn.textContent = 'Loading…';
+ }
+ try {
+ const params = new URLSearchParams({ limit: String(PAGE_SIZE), cursor: c.nextCursor });
+ if (c.filter.q) params.set('q', c.filter.q);
+ if (c.filter.tag) params.set('tag', c.filter.tag);
+ const data = await get(`/api/avatars/public?${params.toString()}`);
+ const more = Array.isArray(data?.avatars) ? data.avatars : [];
+ c.all = c.all.concat(more);
+ c.nextCursor = data?.next_cursor || null;
+ more.forEach((a) => (a.tags || []).forEach((t) => c.loadedTags.add(t)));
+ renderCommunityTags(root);
+ renderCommunityGrid(root);
+ setupCommunityLoadMore(root);
+ } catch (err) {
+ toast(root, msgOf(err) || 'Failed to load more', true);
+ if (btn) {
+ btn.disabled = false;
+ btn.textContent = 'Load more';
+ }
+ } finally {
+ c.loading = false;
+ }
+}
+
// ── Filter / sort wiring ─────────────────────────────────────────────────
+function wireCommunityFilters(root) {
+ const c = state.community;
+ const qInput = root.querySelector('[data-cq]');
+ qInput.addEventListener('input', () => {
+ clearTimeout(c.searchTimer);
+ c.searchTimer = setTimeout(() => {
+ c.filter.q = qInput.value.trim();
+ loadCommunityInitial(root);
+ }, 280);
+ });
+
+ const sortSel = root.querySelector('[data-csort]');
+ sortSel.addEventListener('change', () => {
+ c.filter.sort = sortSel.value;
+ renderCommunityGrid(root);
+ });
+
+ const tagsHost = root.querySelector('[data-community-tags]');
+ tagsHost.addEventListener('click', (e) => {
+ const btn = e.target.closest('[data-tag]');
+ if (!btn) return;
+ const tag = btn.getAttribute('data-tag');
+ c.filter.tag = c.filter.tag === tag ? '' : tag;
+ renderCommunityTags(root);
+ loadCommunityInitial(root);
+ });
+}
+
function wireFilters(root) {
const qInput = root.querySelector('[data-q]');
qInput.addEventListener('input', () => {
@@ -283,6 +484,225 @@ function setupLoadMore(root) {
state.io.observe(host);
}
+// ── Community: rendering ──────────────────────────────────────────────────
+
+function applyCommunitySort(rows) {
+ const cmp = COMMUNITY_SORTS.find((s) => s.key === state.community.filter.sort)?.cmp;
+ return cmp ? [...rows].sort(cmp) : rows;
+}
+
+function renderCommunityGrid(root) {
+ const grid = root.querySelector('[data-grid]');
+ const c = state.community;
+ const rows = applyCommunitySort(c.all);
+
+ if (!rows.length) {
+ grid.innerHTML = '';
+ const empty = document.createElement('div');
+ empty.className = 'dn-empty';
+ empty.style.gridColumn = '1 / -1';
+ if (c.filter.q || c.filter.tag) {
+ empty.innerHTML = `<h3>No matches</h3><p>No public avatars match the current search or tag. Clear them to see the whole community gallery.</p>`;
+ } else {
+ empty.innerHTML = `<h3>No public avatars yet.</h3><p>Be the first — build an avatar and set it to public so it appears here for everyone.</p>
+ <div style="display:flex;gap:8px;flex-wrap:wrap;justify-content:center">
+ <a class="dn-btn primary" href="/create/prompt">Describe it · prompt → 3D</a>
+ </div>`;
+ }
+ grid.appendChild(empty);
+ return;
+ }
+
+ const ids = rows.map((a) => a.id).join('|');
+ if (grid.dataset.ids === ids) return;
+ grid.dataset.ids = ids;
+
+ grid.innerHTML = '';
+ for (const a of rows) grid.appendChild(communityCard(root, a));
+}
+
+function communityCard(root, a) {
+ const el = document.createElement('div');
+ el.className = 'dn-avatar-card';
+ el.dataset.id = a.id;
+
+ const views = Number(a.view_count) || 0;
+ const onchain = onchainBadgeHTML(a, { link: false, size: 'sm', showChain: false });
+ const tagBits = (a.tags || []).slice(0, 2).map((t) => `<span class="dn-tag">${esc(t)}</span>`).join('');
+
+ el.innerHTML = `
+ <div class="dn-av-thumb">
+ <threews-avatar avatar-id="${esc(a.id)}" hide-chrome bg="transparent"></threews-avatar>
+ <div class="dn-av-hover-actions">
+ <a class="dn-av-hover-btn" href="/avatars/${encodeURIComponent(a.id)}" target="_blank" rel="noopener">Live page</a>
+ <a class="dn-av-hover-btn" href="/app#avatar=${encodeURIComponent(a.id)}">Remix in 3D</a>
+ </div>
+ <button type="button" class="dn-av-more" data-more aria-haspopup="menu" aria-label="More actions">
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor" aria-hidden="true"><circle cx="8" cy="3" r="1.4"/><circle cx="8" cy="8" r="1.4"/><circle cx="8" cy="13" r="1.4"/></svg>
+ </button>
+ </div>
+ <div class="dn-av-body">
+ <div class="dn-av-name-row">
+ <span class="dn-av-name" title="${esc(a.name || 'Untitled')}">${esc(a.name || 'Untitled')}</span>
+ </div>
+ <div class="dn-av-meta">
+ ${onchain}
+ ${tagBits}
+ ${views ? `<span class="dn-av-rel">${compactNum.format(views)} views</span>` : ''}
+ <span class="dn-av-rel">${esc(relTime(a.created_at))}</span>
+ </div>
+ </div>
+ `;
+
+ wireCommunityMoreMenu(root, el, a);
+ return el;
+}
+
+function wireCommunityMoreMenu(root, card, a) {
+ const btn = card.querySelector('[data-more]');
+ btn.addEventListener('click', (e) => {
+ e.stopPropagation();
+ if (_openMenu && _openMenu.dataset.for === a.id) {
+ closeOpenMenu();
+ return;
+ }
+ closeOpenMenu();
+ openCommunityMenu(root, btn, a);
+ });
+}
+
+function openCommunityMenu(root, anchor, a) {
+ const menu = document.createElement('div');
+ menu.className = 'dn-av-menu';
+ menu.dataset.for = a.id;
+ menu.setAttribute('role', 'menu');
+ const shareUrl = `${location.origin}/avatars/${encodeURIComponent(a.id)}`;
+ const items = [
+ { label: 'View live page', run: () => { window.open(`/avatars/${encodeURIComponent(a.id)}`, '_blank'); } },
+ { label: 'Remix in 3D studio', run: () => { location.href = `/app#avatar=${encodeURIComponent(a.id)}`; } },
+ { label: 'Copy share link', run: () => copyText(root, shareUrl, 'Share link copied') },
+ { label: 'Copy embed snippet', run: () => copyCommunityEmbed(root, a) },
+ { label: 'Copy GLB URL', run: () => {
+ if (!a.model_url) { toast(root, 'No GLB URL available', true); return; }
+ copyText(root, a.model_url, 'GLB URL copied');
+ } },
+ ];
+ menu.innerHTML = items.map((item, i) => `
+ <button type="button" class="dn-av-menu-item" data-i="${i}" role="menuitem">${esc(item.label)}</button>
+ `).join('');
+
+ document.body.appendChild(menu);
+ positionMenu(menu, anchor);
+ requestAnimationFrame(() => menu.classList.add('open'));
+ _openMenu = menu;
+
+ menu.querySelectorAll('[data-i]').forEach((b) => {
+ b.addEventListener('click', () => {
+ const i = Number(b.dataset.i);
+ closeOpenMenu();
+ items[i].run();
+ });
+ });
+
+ const onDocClick = (e) => {
+ if (menu.contains(e.target) || anchor.contains(e.target)) return;
+ closeOpenMenu();
+ document.removeEventListener('click', onDocClick);
+ document.removeEventListener('keydown', onKey);
+ };
+ const onKey = (e) => {
+ if (e.key === 'Escape') {
+ closeOpenMenu();
+ document.removeEventListener('click', onDocClick);
+ document.removeEventListener('keydown', onKey);
+ }
+ };
+ setTimeout(() => {
+ document.addEventListener('click', onDocClick);
+ document.addEventListener('keydown', onKey);
+ }, 0);
+}
+
+async function copyCommunityEmbed(root, a) {
+ const safeName = (a.name || 'avatar').replace(/"/g, '&quot;');
+ const u = new URL('/a-embed.html', location.origin);
+ u.searchParams.set('avatar', a.id);
+ const snippet = `<iframe src="${u.toString()}" width="360" height="540" style="border:0;border-radius:12px;max-width:100%" allow="xr-spatial-tracking" sandbox="allow-scripts allow-same-origin allow-popups" title="${safeName}" loading="lazy"></iframe>`;
+ await copyText(root, snippet, 'Embed snippet copied');
+}
+
+async function copyText(root, text, okMsg) {
+ try {
+ await navigator.clipboard.writeText(text);
+ toast(root, okMsg);
+ } catch {
+ toast(root, 'Copy failed — clipboard blocked', true);
+ }
+}
+
+function renderCommunityTags(root) {
+ const host = root.querySelector('[data-community-tags]');
+ const c = state.community;
+ const tags = [...c.loadedTags].sort((a, b) => a.localeCompare(b)).slice(0, 24);
+ const active = c.filter.tag;
+ const all = active && !tags.includes(active) ? [active, ...tags] : tags;
+ if (!all.length) {
+ host.innerHTML = '';
+ return;
+ }
+ host.innerHTML = all.map((t) =>
+ `<button type="button" class="dn-av-chip${t === active ? ' active' : ''}" data-tag="${esc(t)}">${esc(t)}</button>`
+ ).join('');
+}
+
+function updateCommunityCount(root) {
+ const c = state.community;
+ const badge = root.querySelector('[data-community-count]');
+ const stat = root.querySelector('[data-community-stat]');
+ if (badge) {
+ if (typeof c.total === 'number' && c.total > 0) {
+ badge.textContent = integerNum.format(c.total);
+ badge.hidden = false;
+ } else {
+ badge.hidden = true;
+ }
+ }
+ if (stat) {
+ const parts = [];
+ if (typeof c.total === 'number') parts.push(`${integerNum.format(c.total)} public avatars`);
+ if (c.totalViews) parts.push(`${compactNum.format(c.totalViews)} views`);
+ stat.textContent = parts.join(' · ');
+ }
+}
+
+function setupCommunityLoadMore(root) {
+ const host = root.querySelector('[data-loadmore]');
+ const c = state.community;
+ if (c.io) { c.io.disconnect(); c.io = null; }
+ if (state.io) { state.io.disconnect(); state.io = null; }
+ if (!c.nextCursor) {
+ host.hidden = true;
+ host.innerHTML = '';
+ return;
+ }
+ host.hidden = false;
+ host.innerHTML = `<button class="dn-btn ghost" type="button" data-loadmore-btn>Load more</button>`;
+ host.querySelector('[data-loadmore-btn]').addEventListener('click', () => loadCommunityMore(root));
+ c.io = new IntersectionObserver((entries) => {
+ for (const e of entries) {
+ if (e.isIntersecting) { loadCommunityMore(root); break; }
+ }
+ }, { rootMargin: '300px 0px' });
+ c.io.observe(host);
+}
+
+function teardownCommunityObserver() {
+ if (state.community.io) {
+ state.community.io.disconnect();
+ state.community.io = null;
+ }
+}
+
// ── Card ─────────────────────────────────────────────────────────────────
function avatarCard(root, a) {
@@ -788,6 +1208,60 @@ function injectStyles() {
}
.dn-av-new-grp:first-child { padding-top: 3px; }
+ .dn-av-tabs {
+ display: inline-flex;
+ gap: 2px;
+ padding: 3px;
+ margin-bottom: 16px;
+ background: rgba(255,255,255,0.04);
+ border: 1px solid var(--nxt-stroke);
+ border-radius: var(--nxt-radius-pill);
+ }
+ .dn-av-tab {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ background: transparent;
+ border: 0;
+ color: var(--nxt-ink-dim);
+ font-family: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ padding: 7px 16px;
+ border-radius: var(--nxt-radius-pill);
+ cursor: pointer;
+ transition: color 0.12s ease, background 0.12s ease;
+ }
+ .dn-av-tab:hover { color: var(--nxt-ink); }
+ .dn-av-tab.active {
+ background: rgba(255,255,255,0.1);
+ color: var(--nxt-ink);
+ }
+ .dn-av-tab-count {
+ font-size: 11px;
+ font-weight: 600;
+ padding: 1px 7px;
+ border-radius: var(--nxt-radius-pill);
+ background: rgba(255,255,255,0.1);
+ color: var(--nxt-ink-dim);
+ }
+ .dn-av-tab.active .dn-av-tab-count { background: rgba(255,255,255,0.16); color: var(--nxt-ink); }
+
+ .dn-av-community-stat {
+ font-size: 12px;
+ color: var(--nxt-ink-fade);
+ margin-left: auto;
+ white-space: nowrap;
+ }
+
+ .dn-av-tags {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: 18px;
+ }
+ .dn-av-tags:empty { display: none; }
+
.dn-av-filters {
display: flex;
align-items: center;