Spaces:
Running
Running
Always 3D, grey studio lighting with shadow, faster zoom
Browse filesFiles changed (2)
- app.js+12-27
- index.html+2-2
57 unmodified lines5859606161626364164 unmodified lines22923023123223223323423513 unmodified lines24925025125225325325425525625725825926026126226326425425525625725836 unmodified lines295296297307298299300310311312313314301302303304319320305321306307324308309310311326312313314315102 unmodified lines41841942043542142242329 unmodified lines45345445547145645745845957 unmodified linesconst CROSS = "M6 6l12 12M18 6L6 18";
let DATA = null;const state = { q: "", group: null, category: null, facets: {}, sort: "name", asset: null, open: new Set(), view: "3d", bg: 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 ---------------------------------------------------------------164 unmodified linesasync function getViewer() { if (viewer || viewerFailed) return viewer; try { const { createViewer } = await import(signed("./viewer.js?v=5")); const { createViewer } = await import(signed("./viewer.js?v=7")); viewer = createViewer(); viewer.setTheme(theme()); } catch (e) {13 unmodified lines return b;}
// Fallback when the 3D view can't run: the package thumbnail.function imageView(a) { let variant = state.bg || theme(); const img = el("img", { src: thumbUrl(a, variant), alt: `${a.name} preview` }); const frame = el("div", { class: `thumb ${variant === "transparent" ? "checker" : variant}` }, img); const pick = (v, label) => el("button", { class: "opt", type: "button", "aria-pressed": v === variant ? "true" : "false", onclick: (e) => { variant = state.bg = v; img.src = thumbUrl(a, v); frame.className = `thumb ${v === "transparent" ? "checker" : v}`; e.currentTarget.parentNode.querySelectorAll(".bg").forEach((b) => b.setAttribute("aria-pressed", b === e.currentTarget ? "true" : "false")); }, }, label); return { frame, controls: [pick("dark", "Dark"), pick("light", "Light"), pick("transparent", "Transparent")].map((b) => (b.classList.add("bg"), b)) }; const variant = theme(); return el("div", { class: `thumb ${variant}` }, el("img", { src: thumbUrl(a, variant), alt: `${a.name} preview` }));}
function jointRows(a) {36 unmodified lines document.querySelector(".layout").classList.toggle("has-detail", !!a); pane.hidden = !a; if (!a) { loadedId = null; return; } const mode = a.preview && !viewerFailed ? state.view : "image"; const mode = a.preview && !viewerFailed ? "3d" : "image"; const box = el("div", { class: "viewer" }); const bar = el("div", { class: "viewer-bar" }); const tab = (v, label) => el("button", { class: "opt", type: "button", "aria-pressed": mode === v ? "true" : "false", onclick: () => { if (state.view !== v) { state.view = v; renderDetail(); } }, }, label); if (a.preview && !viewerFailed) bar.append(tab("3d", "3D"), tab("image", "Image")); const { list: jointList, rows } = jointRows(a); const jointActions = el("div", { class: "joint-actions" });
if (mode === "image") { const img = imageView(a); box.append(img.frame); box.append(imageView(a)); bar.append(...img.controls); if (a.preview && viewerFailed) bar.append(el("span", { class: "hint" }, `3D view unavailable: ${viewerFailed}`)); } else { bar.append(el("span", { class: "hint" }, a.joints.length ? "Drag a part to move it 路 drag to orbit 路 scroll to zoom" : "Drag to orbit 路 scroll to zoom")); bar.append(el("span", { class: "hint" }, a.joints.length ? "Drag a part to move it 路 drag empty space to orbit 路 scroll to zoom 路 right-drag to pan" : "Drag to orbit 路 scroll to zoom 路 right-drag to pan")); } box.append(bar); if (bar.childNodes.length) box.append(bar);
const cmd = `hf download ${DATA.dataset} --repo-type dataset --include "${a.id}/*" --local-dir simready-assets`; const folder = `${HF}/datasets/${DATA.dataset}/tree/main/${a.id}`;102 unmodified lines refresh();}function openAsset(id) { if (id !== state.asset) { state.view = "3d"; state.bg = null; } state.asset = id; renderDetail(); document.querySelectorAll(".card").forEach((c) => c.setAttribute("aria-current", c.dataset.id === id ? "true" : "false"));29 unmodified lines try { localStorage.setItem("theme", next); } catch (e) { /* private mode: theme lasts this visit */ } applyTheme(); renderGrid(); if (state.view === "image") renderDetail(); if (viewerFailed) renderDetail(); }); systemLight.addEventListener("change", () => { applyTheme(); renderGrid(); }); document.addEventListener("keydown", (e) => {7 unmodified lines8910111112131468 unmodified lines838485868687887 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=5"> <link rel="stylesheet" href="style.css?v=7"> <script type="importmap"> { "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",68 unmodified lines </aside> </div>
<script src="app.js?v=5"></script> <script src="app.js?v=7"></script></body></html>app.js+12-27
index.html+2-2