Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(gallery): wire forge section JS and CSS
nirholas2a4b203c4ec7
diff --git a/public/gallery/gallery.css b/public/gallery/gallery.cssindex 86f4753bb..e96abff63 100644--- a/public/gallery/gallery.css+++ b/public/gallery/gallery.css@@ -778,3 +778,149 @@ body.gallery-page {padding: 5px 8px;}}++/* ─── From the Forge section ─────────────────────────────────────────────── */+.gallery-forge-section {+ max-width: 1200px;+ margin: 0 auto 4rem;+ padding: 0 1.5rem;+}+.gallery-forge-head {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 1rem;+ margin-bottom: 1.25rem;+ flex-wrap: wrap;+}+.gallery-forge-title {+ font-size: 1.2rem;+ font-weight: 600;+ color: var(--ink, #f0f0f0);+ margin: 0 0 0.3rem;+}+.gallery-forge-sub {+ font-size: 0.85rem;+ color: var(--ink-dim, #888);+ margin: 0;+ max-width: 48ch;+}+.gallery-forge-cta {+ flex: none;+ font-size: 0.8rem;+ color: var(--accent, #5b8af0);+ text-decoration: none;+ white-space: nowrap;+ margin-top: 0.25rem;+ transition: opacity 0.15s;+}+.gallery-forge-cta:hover { opacity: 0.75; }++.gallery-forge-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));+ gap: 0.75rem;+}++/* Individual forge cards */+.forge-gallery-card {+ background: var(--surface-2, #111);+ border: 1px solid var(--stroke, #222);+ border-radius: 10px;+ overflow: hidden;+ display: flex;+ flex-direction: column;+ cursor: pointer;+ transition: border-color 0.15s, transform 0.15s;+}+.forge-gallery-card:hover {+ border-color: var(--accent, #5b8af0);+ transform: translateY(-2px);+}+.forge-gallery-card:focus-visible {+ outline: 2px solid var(--accent, #5b8af0);+ outline-offset: 2px;+}+.forge-gallery-thumb {+ aspect-ratio: 1 / 1;+ background: var(--surface-3, #1a1a1a);+ position: relative;+ overflow: hidden;+}+.forge-gallery-thumb img {+ width: 100%;+ height: 100%;+ object-fit: cover;+ display: block;+}+.forge-gallery-thumb-placeholder {+ width: 100%;+ height: 100%;+ display: flex;+ align-items: center;+ justify-content: center;+ font-size: 2rem;+ color: var(--ink-dim, #555);+ user-select: none;+}+.forge-gallery-body {+ padding: 0.6rem 0.75rem 0.5rem;+ flex: 1;+ display: flex;+ flex-direction: column;+ gap: 0.4rem;+ min-width: 0;+}+.forge-gallery-prompt {+ font-size: 0.72rem;+ color: var(--ink-dim, #aaa);+ overflow: hidden;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ -webkit-box-orient: vertical;+ line-height: 1.4;+}+.forge-gallery-foot {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 0.4rem;+ padding: 0 0.75rem 0.6rem;+}+.forge-gallery-when {+ font-size: 0.62rem;+ color: var(--ink-dim, #666);+ font-variant-numeric: tabular-nums;+}+.forge-gallery-remix {+ font-size: 0.62rem;+ padding: 2px 8px;+ border-radius: 999px;+ border: 1px solid var(--stroke, #333);+ background: transparent;+ color: var(--ink-dim, #aaa);+ cursor: pointer;+ transition: color 0.15s, border-color 0.15s, background 0.15s;+ white-space: nowrap;+}+.forge-gallery-remix:hover {+ color: var(--ink, #f0f0f0);+ border-color: var(--accent, #5b8af0);+ background: var(--accent-soft, rgba(91,138,240,0.12));+}++/* Skeleton cards for loading state */+.forge-gallery-card--skel .forge-gallery-thumb {+ animation: forge-skel-pulse 1.4s ease-in-out infinite;+}+.forge-gallery-card--skel .forge-gallery-prompt,+.forge-gallery-card--skel .forge-gallery-when {+ background: var(--surface-3, #1a1a1a);+ border-radius: 4px;+ color: transparent;+ animation: forge-skel-pulse 1.4s ease-in-out infinite;+}+@keyframes forge-skel-pulse {+ 0%, 100% { opacity: 0.5; }+ 50% { opacity: 1; }+}diff --git a/public/gallery/gallery.js b/public/gallery/gallery.jsindex e26fe07a5..e48381127 100644--- a/public/gallery/gallery.js+++ b/public/gallery/gallery.js@@ -530,3 +530,139 @@ function openAvatarEmbedModal({ avatarId, glbUrl, name }) {}resetAndLoad();++// ─── From the Forge section ────────────────────────────────────────────────+// Loads community forge models from /api/forge-gallery?scope=community and+// renders them below the avatar grid as a separate "From the Forge" strip.++const forgeEls = {+ section: document.getElementById('forge-section'),+ grid: document.getElementById('forge-grid'),+};++function forgeTimeAgo(iso) {+ const t = Date.parse(iso);+ if (!Number.isFinite(t)) return '';+ const m = Math.floor((Date.now() - t) / 60000);+ if (m < 1) return 'just now';+ if (m < 60) return `${m}m ago`;+ const h = Math.floor(m / 60);+ if (h < 24) return `${h}h ago`;+ const d = Math.floor(h / 24);+ if (d < 7) return `${d}d ago`;+ const w = Math.floor(d / 7);+ if (w < 5) return `${w}w ago`;+ return `${Math.floor(d / 30)}mo ago`;+}++function renderForgeCard(c) {+ const card = document.createElement('div');+ card.className = 'forge-gallery-card';+ card.tabIndex = 0;+ card.setAttribute('role', 'button');+ const label = c.prompt || 'Forged model';+ card.setAttribute('aria-label', `Open in Forge: ${escapeAttr(label)}`);++ const thumb = document.createElement('div');+ thumb.className = 'forge-gallery-thumb';+ if (c.preview_image_url) {+ const img = document.createElement('img');+ img.src = c.preview_image_url;+ img.alt = '';+ img.loading = 'lazy';+ thumb.appendChild(img);+ } else {+ const ph = document.createElement('div');+ ph.className = 'forge-gallery-thumb-placeholder';+ ph.setAttribute('aria-hidden', 'true');+ ph.textContent = '◳';+ thumb.appendChild(ph);+ }+ card.appendChild(thumb);++ const body = document.createElement('div');+ body.className = 'forge-gallery-body';+ const prompt = document.createElement('p');+ prompt.className = 'forge-gallery-prompt';+ prompt.textContent = label;+ body.appendChild(prompt);+ card.appendChild(body);++ const foot = document.createElement('div');+ foot.className = 'forge-gallery-foot';+ const when = document.createElement('span');+ when.className = 'forge-gallery-when';+ when.textContent = forgeTimeAgo(c.created_at);+ foot.appendChild(when);++ if (c.prompt) {+ const remixBtn = document.createElement('button');+ remixBtn.type = 'button';+ remixBtn.className = 'forge-gallery-remix';+ remixBtn.textContent = 'Remix';+ remixBtn.title = 'Open in the Forge with this prompt pre-loaded';+ remixBtn.addEventListener('click', (e) => {+ e.stopPropagation();+ window.location.href = `/forge?prompt=${encodeURIComponent(c.prompt)}`;+ });+ foot.appendChild(remixBtn);+ }+ card.appendChild(foot);++ const openForge = () => {+ if (c.id) {+ window.location.href = `/forge?share=${encodeURIComponent(c.id)}`;+ } else if (c.glb_url) {+ window.location.href = `/app#model=${encodeURIComponent(c.glb_url)}`;+ }+ };+ card.addEventListener('click', openForge);+ card.addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openForge(); }+ });+ return card;+}++function renderForgeSkeleton(n) {+ for (let i = 0; i < n; i++) {+ const card = document.createElement('div');+ card.className = 'forge-gallery-card forge-gallery-card--skel';+ const thumb = document.createElement('div');+ thumb.className = 'forge-gallery-thumb';+ card.appendChild(thumb);+ const body = document.createElement('div');+ body.className = 'forge-gallery-body';+ const p = document.createElement('p');+ p.className = 'forge-gallery-prompt';+ p.textContent = ' ';+ body.appendChild(p);+ card.appendChild(body);+ const foot = document.createElement('div');+ foot.className = 'forge-gallery-foot';+ const w = document.createElement('span');+ w.className = 'forge-gallery-when';+ w.textContent = ' ';+ foot.appendChild(w);+ card.appendChild(foot);+ forgeEls.grid.appendChild(card);+ }+}++async function loadForgeSection() {+ if (!forgeEls.section || !forgeEls.grid) return;+ renderForgeSkeleton(8);+ try {+ const res = await fetch('/api/forge-gallery?scope=community&limit=16');+ if (!res.ok) return;+ const data = await res.json().catch(() => ({}));+ forgeEls.grid.innerHTML = '';+ const creations = Array.isArray(data?.creations) ? data.creations : [];+ if (!data?.enabled || creations.length === 0) return;+ for (const c of creations) forgeEls.grid.appendChild(renderForgeCard(c));+ forgeEls.section.hidden = false;+ } catch {+ forgeEls.grid.innerHTML = '';+ }+}++loadForgeSection();