ComfyUI Node

Mesh_Cleanup

Drop the floating debris and non-manifold garbage from scanned meshes

By 807502278·Created 2 years ago·Updated 2 years ago· 23
Mesh_Cleanup
  • mesh
  • Mesh_Out
  • Face_Before
  • Face_After
Cleanup_block_nf0.05
Cleanup_block_sc20
Merge_vertex_threshold1
repair_facetrue

Scanned and photogrammetry meshes are almost never clean. You get floating debris islands, duplicated vertices, and non-manifold faces - the kind of junk that makes exporters and downstream tools misbehave. Mesh_Cleanup (from ComfyUI-3D-MeshTool) is the node that scrubs all of that out: it removes small disconnected components, welds near-duplicate vertices, and repairs broken faces.

Don't confuse it with Mesh_Clean_Data, the other "clean" node in this pack - that one strips data channels (normals, UVs, textures), this one fixes the actual geometry. If you only remember one of the two, remember this one for scanned models.

How it works

It runs clean_mesh from kiui.mesh_utils (the same cleanup used by TRELLIS-style pipelines) on your mesh's vertices and faces. Four knobs control it:

  • Cleanup_block_nf (FLOAT, default 0.05) - drops any connected component whose face count is below this fraction of the total mesh. At 0.05, any island with under 5% of the mesh's faces gets removed. It only kicks in if the value is between 0 and 1.
  • Cleanup_block_sc (INT, default 20) - drops components smaller than this diameter threshold.
  • Merge_vertex_threshold (INT, default 1) - welds vertices closer than this distance, killing duplicated/overlapping geometry.
  • repair_face (BOOLEAN, default true) - repairs non-manifold faces.

Geometry is processed on CPU as numpy arrays and written back to the mesh as fresh tensors, so the result is cleanly re-indexed.

Outputs

  • Mesh_Out (MESH) - the cleaned mesh
  • Face_Before (INT) - face count before cleanup
  • Face_After (INT) - heads-up: this is the debris cutoff you set (total × Cleanup_block_nf), not the true post-cleanup count. The actual number of remaining faces isn't reported, so if you need the real figure, run Mesh_Data_Statistics afterward.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt

Restart ComfyUI. Or via ComfyUI Manager, search "ComfyUI-3D-MeshTool". No model downloads; cleanup itself runs on kiui, which the pack already requires.

Common issues

The two thresholds interact, and that's where people get confused. Crank Cleanup_block_nf too high on a mesh with many small legitimate parts and you'll delete real geometry - 0.05 is a sensible default for a single-object scan, but multi-part models need it lower. Similarly, an aggressive Merge_vertex_threshold will start collapsing detail. If a cleanup eats more than the debris you expected, dial both back and re-run. And if the mesh comes out unchanged, check the console - the cleanup only runs inside the 0 < Cleanup_block_nf <= 1 guard, so a value outside that range silently does nothing.

Category3D_MeshTool/optimization

Inputs (5)

NameTypeDefaultDescription
meshMESH
Cleanup_block_nfFLOAT0.050–1
Cleanup_block_scINT200–100
Merge_vertex_thresholdINT11–1000
repair_faceBOOLEANtrue

Outputs (3)

NameTypeDescription
Mesh_OutMESH
Face_BeforeINT
Face_AfterINT