Nodes/ComfyUI_Antonioilev_Lightpack/🧹 Mesh Cleaner (Pre-op)
ComfyUI Node

🧹 Mesh Cleaner (Pre-op)

Weld, then kill the confetti

By AntonioilevΒ·Created 2 days agoΒ·Updated a day agoΒ· 0
🧹 Mesh Cleaner (Pre-op)
  • mesh
  • mesh
  • info
β—„merge_distance0.0010β–Ί
β—„min_island_size0.03β–Ί
β—„remove_islands_ratio0.01β–Ί
β—„fix_normalstrueβ–Ί

"Pre-op" is the right name. This is the twenty-second pass before the real surgery: the mesh is welded, and the loose debris floating around it is swept up so that the next node - a capper, a hole filler, a boolean - is looking at one asset instead of an asset plus forty shards.

That debris is ordinary in generated meshes. "All the frontier models produce the same mesh soup" is the community's line, and a big part of the soup is disconnected islands: a speck of surface behind the ear, a few dozen triangles that survived a cleanup pass nobody knows about.

How it works

Two operations, then a courtesy.

  1. Weld. merge_vertices runs on the copy. One caveat worth knowing, because it's the kind of thing the UI encourages you to misread: the merge_distance value is handed to trimesh positionally, and trimesh's first argument there is merge_tex, a flag - not a distance. So treat that slider as an on/off switch for UV-aware welding, not a weld radius. It will happily weld exact duplicates either way; it will not close micro-gaps at a radius you specify. If you have real cracks to close, the pack's Mesh Fixer Fast or Mesh One Surface are the tools, and the reliable general answer is still "weld in Blender and re-import".
  2. Island filtering. It splits the mesh into connected components and keeps a component if either condition holds: its area is more than remove_islands_ratio Γ— the biggest component's area, or its bounding-box diagonal is at least min_island_size in world units. Those two are deliberately different tests - one is relative, one is absolute - so a big-but-thin shard survives the area test while a compact but tiny part survives the size test. Anything failing both is deleted. Then everything gets concatenated and welded again.
  3. Normals, if fix_normals is on: fix_normals() plus a winding repair. Leave it on.

The parameters that matter

  • mesh - in, TRIMESH.
  • remove_islands_ratio (default 0.01) - a component needs 1% of the main part's area to survive on the area test. Push it to 0.05 for aggressive pruning, and toward 0 if you're deleting legitimate small parts.
  • min_island_size (default 0.03) - the absolute escape hatch, in mesh units. This is the one to set deliberately: 0.03 on a 2-metre character keeps anything bigger than 3cm, which is a sensible "is this a real detail or a speck?" line. On a 100-unit scene it protects literally everything.
  • merge_distance (default 0.001) - see above; behaves as a switch.
  • fix_normals (default on).

Outputs, in this order: mesh (TRIMESH) then info (STRING) - the opposite of most nodes in this pack's Fix category, which is a nice way to feel silly after you've wired Hole Surgeon twice. The info string is a one-liner: Cleaner: Kept 48211 verts. (Min Island: 0.03m).

Where it belongs in a chain, and one warning

Put it early: raw generator output β†’ Mesh Cleaner β†’ Clean Mesh (skirt/inner shell) β†’ Mesh Fixer Fast β†’ Refine Mesh β†’ cap β†’ export. Notice what it does not do: it doesn't fill holes, doesn't cap, doesn't smooth, doesn't think about inside-out geometry. It's the least opinionated node in the pack, which is exactly why it's a good first step - it can't ruin a mesh, it can only delete small things.

That's also the warning. "Deleted small things" includes parts you might have wanted: a detached earring, a floating prop, a separate building element. Always look at the result in a 3D preview before you run the rest of the pipeline, because everything downstream inherits the deletion and none of it will tell you.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Antonioilev/ComfyUI_Antonioilev_Lightpack.git
python -m pip install trimesh

Restart ComfyUI and check the console. Two things to expect: the pack prints [Antonioilev_Light_pack] Loaded N nodes (M failed) on startup, and if trimesh isn't in ComfyUI's own Python environment, MeshCleaner simply won't exist in the node menu - with !!! MeshCleaner: No module named 'trimesh' printed right there. This is the single most common way people conclude a ComfyUI node pack "doesn't work": the pack is installed, the dependency isn't, and the failure is one console line at startup.

ComfyUI Manager can install the pack by name (Antonioilev Light Pack), but it cannot resolve the pack's dependencies, because the repo has no requirements.txt and no install.py. That's a deliberate-looking omission in a big pack and it means pip is always your job.

CategoryAntonioilev/Mesh/Fix

Inputs (5)

NameTypeDefaultDescription
meshTRIMESHβ€”
merge_distanceFLOAT0.00100–0.1β€”
min_island_sizeFLOAT0.030–1β€”
remove_islands_ratioFLOAT0.010–1β€”
fix_normalsBOOLEANtrueβ€”

Outputs (2)

NameTypeDescription
meshTRIMESHβ€”
infoSTRINGβ€”