Files
Igor AherneandClaude Opus 5.5 56d85f6eeb Spellcast3D 0.1.0
A free, open-source Windows app that takes an artist from an idea to game-ready 3D props on their own PC: pictures with Qwen-Image 2.1, 3D models with Pixal3D, an optional repaint of their textures, retopology with TriFlow, LATO.2 or Instant Meshes, and a baker for the final textures. See README.md, and DEVELOPERS.md for building from source.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 02:38:33 +01:00

67 lines
3.0 KiB
JavaScript

// The workbench, right of the props column: the stage view of the selected prop (or the one the stage
// follows). It has all the height: the call to action
// lives in the props column. Going to another stage, the whole page swipes: a still copy of the page
// being left (the props column and the workbench) swipes out while the page drawn for the new stage
// swipes in (anim.js swipe).
import { h } from '../dom.js';
/** Pairs each element matching `sel` in `a` with its counterpart in `b`, a copy of `a`. */
function counterparts(a, b, sel) {
const copies = b.querySelectorAll(sel);
return [...a.querySelectorAll(sel)].map((el, i) => [el, copies[i]]);
}
export function createBench() {
const view = h('div', { class: 'centre-view' });
const el = h('section', { class: 'bench', 'aria-label': 'Workbench' }, view);
/**
* A still copy of the whole page as it is now (the shell the workbench is in: the props column and the
* workbench), laid over it: the page that leaves during a move, so the heavy view is not live
* meanwhile. A copy loses what is typed into its fields, what its canvases show (a 3D preview) and
* where its panels are scrolled (the props list): those are carried over. An iframe (Instant Meshes'
* viewer) is left blank, never loaded a second time. The copy is only a picture: inert, hidden from
* screen readers, without ids or live regions. null when there is nothing to copy.
*/
async function freeze() {
const page = el.parentElement;
if (!page || !view.firstElementChild) return null;
const copy = page.cloneNode(true);
copy.classList.add('shell-frozen');
copy.inert = true;
copy.setAttribute('aria-hidden', 'true');
for (const b of copy.querySelectorAll('[id]')) b.removeAttribute('id'); // never two of one id in the page
for (const b of copy.querySelectorAll('[data-stage]')) b.removeAttribute('data-stage');
for (const b of copy.querySelectorAll('[role="alert"], [role="status"], [aria-live]')) {
b.removeAttribute('role');
b.removeAttribute('aria-live');
}
for (const [a, b] of counterparts(page, copy, 'input, textarea, select')) {
b.value = a.value;
b.checked = a.checked;
}
for (const [, b] of counterparts(page, copy, 'iframe')) b.replaceWith(h('div', { class: b.className }));
const canvases = counterparts(page, copy, 'canvas');
if (canvases.length) {
const { viewer } = await import('../viewer3d.js');
for (const [a, b] of canvases) b.replaceWith(viewer.still(a));
}
// Scrolled panels keep their place in the copy.
for (const [a, b] of counterparts(page, copy, '*')) {
if (a.scrollTop || a.scrollLeft) {
b.dataset.scrollTop = a.scrollTop;
b.dataset.scrollLeft = a.scrollLeft;
}
}
page.after(copy);
for (const b of copy.querySelectorAll('[data-scroll-top]')) {
b.scrollTop = +b.dataset.scrollTop;
b.scrollLeft = +b.dataset.scrollLeft;
}
return copy;
}
return { el, view, freeze };
}