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 lines58596061626364164 unmodified lines22923023123223323423513 unmodified lines24925025125225325425525625725825926026126226326426526626736 unmodified lines304305306307308309310311312313314315316317318319320321322323324325326327328329102 unmodified lines43243343443543643743829 unmodified lines46846947047147247347457 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 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"));viewer = createViewer();viewer.setTheme(theme());} catch (e) {13 unmodified linesreturn b;}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)) };}function jointRows(a) {36 unmodified linesdocument.querySelector(".layout").classList.toggle("has-detail", !!a);pane.hidden = !a;if (!a) { loadedId = null; return; }const mode = a.preview && !viewerFailed ? state.view : "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);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"));}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 linesrefresh();}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 linestry { localStorage.setItem("theme", next); } catch (e) { /* private mode: theme lasts this visit */ }applyTheme();renderGrid();if (state.view === "image") renderDetail();});systemLight.addEventListener("change", () => { applyTheme(); renderGrid(); });document.addEventListener("keydown", (e) => {57 unmodified lines58596061626364164 unmodified lines22923023123223323423513 unmodified lines24925025125225325425525625725836 unmodified lines295296297298299300301302303304305306307308309310311312313314315102 unmodified lines41841942042142242329 unmodified lines45345445545645745845957 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() };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=7"));viewer = createViewer();viewer.setTheme(theme());} catch (e) {13 unmodified linesreturn b;}// 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` }));}function jointRows(a) {36 unmodified linesdocument.querySelector(".layout").classList.toggle("has-detail", !!a);pane.hidden = !a;if (!a) { loadedId = null; return; }const mode = a.preview && !viewerFailed ? "3d" : "image";const box = el("div", { class: "viewer" });const bar = el("div", { class: "viewer-bar" });const { list: jointList, rows } = jointRows(a);const jointActions = el("div", { class: "joint-actions" });if (mode === "image") {box.append(imageView(a));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 empty space to orbit 路 scroll to zoom 路 right-drag to pan": "Drag to orbit 路 scroll to zoom 路 right-drag to pan"));}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 linesrefresh();}function openAsset(id) {state.asset = id;renderDetail();document.querySelectorAll(".card").forEach((c) => c.setAttribute("aria-current", c.dataset.id === id ? "true" : "false"));29 unmodified linestry { localStorage.setItem("theme", next); } catch (e) { /* private mode: theme lasts this visit */ }applyTheme();renderGrid();if (viewerFailed) renderDetail();});systemLight.addEventListener("change", () => { applyTheme(); renderGrid(); });document.addEventListener("keydown", (e) => {
7 unmodified lines89101112131468 unmodified lines8384858687887 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"><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></body></html>7 unmodified lines89101112131468 unmodified lines8384858687887 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=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=7"></script></body></html>
app.js+12-27
index.html+2-2