/** * ComfyUI GeomPack - Self Intersections Dynamic Display * Shows self-intersecting faces in the node after execution */ import { app } from "../../../scripts/app.js"; app.registerExtension({ name: "geompack.self_intersections", async beforeRegisterNodeDef(nodeType, nodeData, app) { if (nodeData.name === "GeomPackDetectSelfIntersections") { const onNodeCreated = nodeType.prototype.onNodeCreated; nodeType.prototype.onNodeCreated = function() { const r = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined; // Create info panel container const infoPanel = document.createElement("div"); infoPanel.style.backgroundColor = "#1a1a1a"; infoPanel.style.padding = "8px"; infoPanel.style.fontSize = "10px"; infoPanel.style.fontFamily = "monospace"; infoPanel.style.color = "#ccc"; infoPanel.style.lineHeight = "1.4"; infoPanel.style.maxHeight = "200px"; infoPanel.style.overflowY = "auto"; infoPanel.style.borderRadius = "4px"; infoPanel.innerHTML = 'Run workflow to detect self-intersections'; // Add widget const widget = this.addDOMWidget("intersection_info", "INTERSECTION_INFO", infoPanel, { getValue() { return ""; }, setValue(v) { } }); widget.computeSize = () => [this.size[0] - 20, 120]; this.intersectionInfoPanel = infoPanel; // Handle execution results const onExecuted = this.onExecuted; this.onExecuted = function(message) { onExecuted?.apply(this, arguments); if (message?.intersection_data && message.intersection_data.length > 0) { let html = ''; for (const data of message.intersection_data) { const { mesh_name, num_intersecting_faces, num_intersection_pairs, total_faces, total_vertices, has_cgal, faces } = data; // Header with mesh name and status html += `
| Face | `; html += `Vertices | `; html += `
|---|---|
| ${face.id} | `; html += `[${face.vertices.join(', ')}] | `; html += `
| `; html += `... and ${faces.length - 20} more faces`; html += ` | |