Fix save-mesh 405 (missing route) + Multi grid dims not matching inputs
Save mesh: the VTK viewer's Save button POSTed to /geometrypack/save_preview,
a route that was never ported into GeometryPack (inherited caller from
comfy-3d-viewers; only /gpack/getpath existed). ComfyUI's GET catch-all
matched the path, hence 405 instead of 404. Added POST /gpack/save_preview in
__init__.py next to getpath: basename()-sanitized lookup of the temp preview
export in ComfyUI output/ (tempdir fallback), copied to output/saved_<name>;
returns {success, saved_filename}. Viewer fetch updated to the new path.
Multi cols/rows: entering dims whose product was smaller than the mesh count
(e.g. 1x1 for 2 meshes) overflowed viewports into IMPLICIT CSS grid rows
(auto height), so the rendered layout stopped matching the inputs. Now the
edited field is authoritative and the other dimension auto-raises to fit
(ceil(n/edited)); both inputs are updated to show the grid actually in
effect. Oversized grids (empty cells) remain allowed.
This commit is contained in:
@@ -181,13 +181,27 @@ app.registerExtension({
|
||||
iframe.src = `/extensions/${EXTENSION_FOLDER}/${viewerUrl()}?v=` + Date.now();
|
||||
});
|
||||
|
||||
const onDim = () => {
|
||||
viewerState.grid_cols = colsInput.value ? Math.max(1, parseInt(colsInput.value, 10)) : null;
|
||||
viewerState.grid_rows = rowsInput.value ? Math.max(1, parseInt(rowsInput.value, 10)) : null;
|
||||
// The edited field is authoritative; the OTHER dimension auto-raises
|
||||
// so cols*rows always fits every mesh. Without this, a grid smaller
|
||||
// than the mesh count overflows into implicit CSS rows (auto height)
|
||||
// and the layout stops matching the inputs. Both inputs are updated
|
||||
// so the UI always shows the grid actually in effect.
|
||||
const onDim = (edited) => () => {
|
||||
const n = lastLoad?.numMeshes || 1;
|
||||
let cols = Math.max(1, parseInt(colsInput.value, 10) || 0) || (lastLoad?.autoCols ?? 1);
|
||||
let rows = Math.max(1, parseInt(rowsInput.value, 10) || 0) || (lastLoad?.autoRows ?? 1);
|
||||
if (cols * rows < n) {
|
||||
if (edited === "cols") rows = Math.ceil(n / cols);
|
||||
else cols = Math.ceil(n / rows);
|
||||
}
|
||||
colsInput.value = cols;
|
||||
rowsInput.value = rows;
|
||||
viewerState.grid_cols = cols;
|
||||
viewerState.grid_rows = rows;
|
||||
buildAndSend(); // same iframe -> viewer re-tiles, no reload
|
||||
};
|
||||
colsInput.addEventListener('change', onDim);
|
||||
rowsInput.addEventListener('change', onDim);
|
||||
colsInput.addEventListener('change', onDim("cols"));
|
||||
rowsInput.addEventListener('change', onDim("rows"));
|
||||
|
||||
syncLayoutUI();
|
||||
applyCollapsed();
|
||||
|
||||
@@ -1031,7 +1031,7 @@
|
||||
saveButton.disabled = true;
|
||||
saveButton.textContent = 'Saving...';
|
||||
|
||||
const response = await fetch('/geometrypack/save_preview', {
|
||||
const response = await fetch('/gpack/save_preview', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ temp_filename: currentFilename })
|
||||
|
||||
Reference in New Issue
Block a user