Spaces:
Running
Running
Keep the page dark; the header switch now picks grey (default) or dark thumbnails
Browse filesFiles changed (4)
- README.md+3-3
- app.js+22-28
- index.html+6-7
- style.css+9-20
55 unmodified lines56575859606159606162636455 unmodified lines lighting and reflections only, the background stays grey). See-through shells render as clear glass and whatever sits inside them draws first, so liquids show from every angle.- Thumbnails are Isaac Sim (RTX path-traced) renders of the real USD packages, made by `tools/isaac_thumbs.py` on a GPU machine, one per theme: `previews/thumbs/<asset>.webp` (dark, on the card colour #1a1a1a) and `previews/thumbs-light/<asset>.webp` (grey studio floor with a grid). Lighting is the same HDRI as the 3D viewer; settings and look are `tools/isaac_thumbs.py` on a GPU machine, two per asset: `previews/thumbs-light/<asset>.webp` (grey studio floor with a grid, shown by default) and `previews/thumbs/<asset>.webp` (dark, on #1a1a1a). The page itself is always dark; the header switch only swaps the thumbnails. Lighting is the same HDRI as the 3D viewer; settings and look are described in the script. `tools/render_thumbs.py` (Blender, from the preview GLBs, transparent background) is the fallback for a new asset when no GPU machine is at hand.
65 unmodified lines6667686969707118 unmodified lines90919294959697989910010110210393949596979899100101102103108109104105106111107108113109110115111112113114104 unmodified lines2192202212262222232242252262272322282292302318 unmodified lines240241242247243244245172 unmodified lines418419420426427421422423424180 unmodified lines60560660761460860961061112 unmodified lines62462562663363463563663762762862963063163263363463564163663763865 unmodified lines
let DATA = null;const state = { q: "", group: null, category: null, facets: {}, sort: "name", asset: null, open: new Set() };const systemLight = window.matchMedia("(prefers-color-scheme: light)");
// ---- formatting ---------------------------------------------------------------function maxDim(a) { return a.extents ? Math.max(...a.extents) : 0; }18 unmodified linesconst partsLabel = (a) => a.joints.length ? `${a.joints.length} moving part${a.joints.length > 1 ? "s" : ""}` : "Rigid";const cap = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
// ---- theme --------------------------------------------------------------------function theme() { const t = document.documentElement.dataset.theme; return t === "light" || t === "dark" ? t : systemLight.matches ? "light" : "dark";}function applyTheme() { const t = theme(); document.documentElement.classList.toggle("is-light", t === "light"); $("theme").setAttribute("aria-label", t === "light" ? "Switch to dark theme" : "Switch to light theme"); if (viewer) viewer.setTheme(t);// ---- thumbnail background ---------------------------------------------------------// The page is always dark. The header switch only picks which Isaac renders the cards// show: the grey studio (default) or the dark floor. Saved per browser as "thumbs".function thumbMode() { return document.documentElement.dataset.thumbs === "dark" ? "dark" : "grey"; }function applyThumbMode() { const m = thumbMode(); $("thumbs-toggle").setAttribute("aria-label", `Thumbnail background: ${m}. Switch to ${m === "dark" ? "grey" : "dark"}`);}
// ---- urls ---------------------------------------------------------------------function fileUrl(a, path) { return `${HF}/datasets/${DATA.dataset}/resolve/${DATA.commit}/${a.id}/${path}`; }// 640 px Isaac Sim renders from this Space (tools/isaac_thumbs.py), one per theme:// previews/thumbs/ on the dark card colour, previews/thumbs-light/ on a grey studio floor.// 640 px Isaac Sim renders from this Space (tools/isaac_thumbs.py), one per thumbnail mode:// previews/thumbs-light/ on the grey studio floor, previews/thumbs/ on the dark card colour.// The dataset's 256 px package thumbnail is the fallback.function thumbUrl(a, variant) {function thumbUrl(a, mode) { const rev = `?v=${encodeURIComponent((a.version || "") + "-" + (DATA.thumbs_rev || ""))}`; if (variant === "light" && a.thumb_light) return signed(`previews/thumbs-light/${a.id}.webp${rev}`); if (mode === "grey" && a.thumb_light) return signed(`previews/thumbs-light/${a.id}.webp${rev}`); if (a.thumb) return signed(`previews/thumbs/${a.id}.webp${rev}`); const suffix = variant === "light" ? "_light" : variant === "transparent" ? "_transparent" : ""; const suffix = mode === "grey" ? "_light" : ""; return fileUrl(a, `simready_usd/.thumbs/256x256/${a.id}.usd${suffix}.png`);}
104 unmodified lines const n = DATA.assets.length; $("count").replaceChildren(el("strong", {}, list.length), list.length === n ? " assets" : ` of ${n} assets`); $("empty").hidden = list.length > 0; const variant = theme(); const mode = thumbMode(); $("grid").replaceChildren(...list.map((a) => el("li", {}, el("button", { class: "card", type: "button", "aria-current": state.asset === a.id ? "true" : "false", onclick: () => openAsset(a.id), "data-id": a.id, }, el("div", { class: "thumb" }, el("img", { src: thumbUrl(a, variant), alt: "", loading: "lazy", decoding: "async", width: 640, height: 640, class: a.kind === "scene" ? "cover" : null }), el("img", { src: thumbUrl(a, mode), alt: "", loading: "lazy", decoding: "async", width: 640, height: 640, class: a.kind === "scene" ? "cover" : null }), el("div", { class: "badges" }, el("span", { class: "badge" }, a.kind === "scene" ? "scene" : a.joints.length ? `${a.joints.length} moving part${a.joints.length > 1 ? "s" : ""}` : "rigid"))), el("div", { class: "card-text" },8 unmodified lines try { const { createViewer } = await import(signed("./viewer.js?v=29")); viewer = createViewer(); viewer.setTheme(theme()); } catch (e) { console.error("3D viewer failed to start", e); viewerFailed = String((e && e.message) || e).slice(0, 160);172 unmodified lines
// Fallback when the 3D view can't run: the package thumbnail.function imageView(a) { const variant = theme(); return el("div", { class: `thumb ${variant}` }, el("img", { src: thumbUrl(a, variant), alt: `${a.name} preview` })); return el("div", { class: "thumb" }, el("img", { src: thumbUrl(a, thumbMode()), alt: `${a.name} preview` }));}
function jointRows(a) {180 unmodified lines}
async function start() { applyTheme(); applyThumbMode(); try { DATA = await (await fetch("data/catalog.json", { cache: "no-cache" })).json(); } catch {12 unmodified lines const open = $("side").classList.toggle("open"); $("filters-toggle").setAttribute("aria-expanded", open ? "true" : "false"); }); $("theme").addEventListener("click", () => { const next = theme() === "light" ? "dark" : "light"; document.documentElement.dataset.theme = next; try { localStorage.setItem("theme", next); } catch (e) { /* private mode: theme lasts this visit */ } applyTheme(); $("thumbs-toggle").addEventListener("click", () => { const next = thumbMode() === "dark" ? "grey" : "dark"; if (next === "dark") document.documentElement.dataset.thumbs = "dark"; else delete document.documentElement.dataset.thumbs; try { localStorage.setItem("thumbs", next); } catch (e) { /* private mode: lasts this visit */ } applyThumbMode(); renderGrid(); if (viewerFailed) renderDetail(); }); systemLight.addEventListener("change", () => { applyTheme(); renderGrid(); }); document.addEventListener("keydown", (e) => { if (e.key === "Escape") { if (expanded) collapseViewer(); else if (state.asset) openAsset(null); else closeSideOnPhone(); } if (e.key === "/" && document.activeElement !== $("q")) { e.preventDefault(); $("q").focus(); }7 unmodified lines891011111213141516171819181920212211 unmodified lines343536373839373839404141 unmodified lines838485878687887 unmodified lines <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Fira+Code:wght@400;500&display=swap"> <link rel="stylesheet" href="style.css?v=29"> <link rel="stylesheet" href="style.css?v=30"> <script type="importmap"> { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/" } } </script> <script> // Apply a saved theme before first paint, so the page doesn't flash the other theme. try { const t = localStorage.getItem("theme"); if (t === "light" || t === "dark") document.documentElement.dataset.theme = t; } catch (e) {} // Apply the saved thumbnail background before first paint (grey studio unless "dark" was picked). try { if (localStorage.getItem("thumbs") === "dark") document.documentElement.dataset.thumbs = "dark"; } catch (e) {} </script></head><body>11 unmodified lines <nav class="top-links"> <a id="link-dataset" href="https://huggingface.co/datasets/projectsim/simready-assets" target="_blank" rel="noopener">Dataset</a> <a class="cta" href="https://docs.projectsim.ai/getting-started/quickstart?utm_source=hf_space&utm_medium=header&utm_content=simready-library" target="_blank" rel="noopener">Generate your own</a> <button id="theme" class="icon-button theme-toggle" type="button" aria-label="Switch to light theme"> <svg class="i-sun" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.5v2.2M12 19.3v2.2M2.5 12h2.2M19.3 12h2.2M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6"/></svg> <svg class="i-moon" viewBox="0 0 24 24" aria-hidden="true"><path d="M20.2 14.6A8.3 8.3 0 0 1 9.4 3.8a8.3 8.3 0 1 0 10.8 10.8Z"/></svg> <button id="thumbs-toggle" class="icon-button thumbs-toggle" type="button" aria-label="Thumbnail background: grey. Switch to dark" title="Thumbnail background"> <svg viewBox="0 0 24 24" aria-hidden="true"><path class="swatch swatch-grey" d="M12 4a8 8 0 0 0 0 16Z"/><path class="swatch swatch-dark" d="M12 4a8 8 0 0 1 0 16Z"/><circle class="ring" cx="12" cy="12" r="8"/></svg> </button> </nav> <button id="filters-toggle" class="filters-toggle" type="button" aria-controls="side" aria-expanded="false">Filters</button>41 unmodified lines </aside> </div>
<script src="app.js?v=29"></script> <script src="app.js?v=30"></script></body></html>1232345676 unmodified lines14151616171819202122232324252627282930313233342425262722 unmodified lines5051526364655354555657585964 unmodified lines124125126136137127128129/* Layout: header, then three panes like a catalog explorer: library + filters (left), asset grid (centre), asset details with the 3D viewer (right). Dark by default to match the #1A1A1A thumbnails; light follows the system or the header switch (data-theme). asset grid (centre), asset details with the 3D viewer (right). The page is always dark; the header switch only picks the thumbnail background (data-thumbs: grey studio by default, or dark), and --thumb matches the edge of those renders. Brand: projectsim warm red accent, Plus Jakarta Sans + Fira Code. */:root { --bg: #121110;6 unmodified lines --accent: #e2624d; --accent-ink: #ffffff; --accent-soft: rgba(226, 98, 77, 0.16); --thumb: #1a1a1a; --thumb: #9e9fa1; --scrim: rgba(0, 0, 0, 0.62); --sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace; --radius: 10px; color-scheme: dark;}@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --bg: #f5f0eb; --panel: #fbf9f4; --raised: #ffffff; --line: #e6ded4; --ink: #2c1a1d; --muted: #6b5d55; --faint: #9a8d84; --accent: #c4473a; --accent-soft: rgba(196, 71, 58, 0.12); --thumb: #f0f0f0; --scrim: rgba(44, 26, 29, 0.72); color-scheme: light; }}:root[data-theme="light"] { --bg: #f5f0eb; --panel: #fbf9f4; --raised: #ffffff; --line: #e6ded4; --ink: #2c1a1d; --muted: #6b5d55; --faint: #9a8d84; --accent: #c4473a; --accent-soft: rgba(196, 71, 58, 0.12); --thumb: #f0f0f0; --scrim: rgba(44, 26, 29, 0.72); color-scheme: light;}:root[data-thumbs="dark"] { --thumb: #1a1a1a; }
* { box-sizing: border-box; }html, body { height: 100%; }22 unmodified lines.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); background: var(--raised); border-radius: 8px; cursor: pointer; color: var(--muted); }.icon-button:hover { color: var(--ink); border-color: var(--faint); }.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }.theme-toggle .i-moon { display: none; }:root.is-light .theme-toggle .i-sun { display: none; }:root.is-light .theme-toggle .i-moon { display: block; }.thumbs-toggle .swatch { stroke: none; }.thumbs-toggle .swatch-grey { fill: #9e9fa1; }.thumbs-toggle .swatch-dark { fill: #1a1a1a; }.thumbs-toggle .ring { fill: none; stroke: currentColor; stroke-width: 1.4; }.filters-toggle { display: none; align-items: center; height: 36px; border: 1px solid var(--line); background: var(--raised); border-radius: 8px; padding: 0 12px; cursor: pointer; }
/* Panes */64 unmodified lines.detail-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }.viewer { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--thumb); }.viewer .thumb { aspect-ratio: 4 / 3; }.viewer .thumb.light { background: #f0f0f0; }.viewer .thumb.dark { background: #1a1a1a; }.viewer .thumb.checker { background: repeating-conic-gradient(#d9d9d9 0 25%, #f4f4f4 0 50%) 0 0 / 18px 18px; }.viewer-bar { display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--raised); border-top: 1px solid var(--line); flex-wrap: wrap; }.viewer-bar .opt { height: 26px; font-size: 12px; }README.md+3-3
app.js+22-28
index.html+6-7
style.css+9-20