Files
PozzettiAndrea-ComfyUI-Geom…/javascript/js/preview_mesh_batch_render.js
T
PozzettiAndrea 414f759791 Vendor frontend JS into javascript/; drop the prestartup copy dance
The viewer JS/HTML/bundles are now committed in javascript/ (declared via
pyproject [tool.comfy] web = "javascript") instead of being copied from the
shared comfy-3d-viewers pip package at prestartup. Consequences:

- requirements.txt is now just comfy-env (host env installs nothing else,
  per the never-touch-the-host-env principle)
- prestartup_script.py no longer copies viewers or web_src; it keeps only
  setup_env() and the input-asset copies
- WEB_DIRECTORY attribute removed; the pyproject declaration is the single
  source (served at /extensions/comfyui-geometrypack/, keyed by project name)
- web_src/ deleted; its 6 widgets now live in javascript/js/ as the tracked
  source, edited directly
- viewer_pbr.html hardcoded-fallback URL updated to the new mount name

Iframe URLs auto-detect the mount from import.meta.url, so the folder rename
and mount-name change are transparent at runtime.
2026-08-12 17:37:09 +02:00

54 lines
1.9 KiB
JavaScript

// Preview Mesh Batch Render: show the edge_opacity widget only when show_edges
// is enabled (collapse it otherwise).
import { app } from "../../../scripts/app.js";
const TAG = "[PreviewMeshBatchRender]";
console.log(`${TAG} script loaded`);
const findW = (node, name) => (node.widgets || []).find((w) => w.name === name);
function toggleWidget(w, show) {
if (!w) return;
if (!w.__gpOrig) w.__gpOrig = { type: w.type, computeSize: w.computeSize };
if (show) {
w.type = w.__gpOrig.type;
w.computeSize = w.__gpOrig.computeSize;
} else {
w.type = "geompack_hidden"; // unknown type -> not drawn
w.computeSize = () => [0, -4]; // collapse (cancels the 4px row gap)
}
}
app.registerExtension({
name: "geompack.previewmeshbatchrender.ui",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name !== "GeomPackPreviewMeshBatchRender") return;
console.log(`${TAG} registering for GeomPackPreviewMeshBatchRender`);
const onCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
const r = onCreated?.apply(this, arguments);
const node = this;
const showEdges = findW(node, "show_edges");
const edgeOpacity = findW(node, "edge_opacity");
const update = () => {
toggleWidget(edgeOpacity, !!(showEdges && showEdges.value));
node.setSize(node.computeSize());
node.setDirtyCanvas(true, true);
};
if (showEdges) {
const cb = showEdges.callback;
showEdges.callback = function () {
const ret = cb?.apply(this, arguments);
update();
return ret;
};
}
setTimeout(update, 0); // apply initial state (edges off -> hidden)
return r;
};
},
});