Repository navigation
Multi-head 1/7: 3MF export and combined-mask meshing - #96
Conversation
Teach the 3MF exporter to write a multi-extruder project: an extruder count, per-layer pause (M600) markers for head swaps, and per-nozzle voxel meshes (voxelMesh) so each head's material is a separate object. Add a combinedMask option to the smooth mesher so adjacent color groups move shared boundary vertices identically instead of peeling apart. Independent of the analysis code; nothing calls it yet. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Unit test results for this branch ( |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review
Verdict: Needs changes · Findings: 4 (4 inline)
Scope: this PR's changes against develop; the earlier PRs in this stack are reviewed in their own threads.
The 65 focused export and meshing tests pass, and all three TypeScript configurations pass with incremental caching disabled. Direct checks nevertheless reproduced non-manifold voxel geometry, gaps between smoothed color groups, and loss of transforms and physical filament colors during voxel conversion. These issues need correction before the new paths are wired into the UI.
Reviewed by GPT 6.1 Sol
| const vmap = new Map<string, number>(); | ||
|
|
||
| const addV = (x: number, y: number, z: number): number => { | ||
| const key = `${Math.round(x * SNAP)},${Math.round(y * SNAP)},${Math.round(z * SNAP)}`; |
There was a problem hiding this comment.
[high] Diagonal voxel contacts create non-manifold edges
For a layer mask 10/01, the two voxels touch along a vertical edge. This coordinate map welds that edge into one with four incident triangles; inspectMeshIntegrity reports one non-manifold edge. Edge-only contacts across successive Z layers fail similarly. Resolve these contacts jointly across materials, or preserve independently closed shells through export, and add occupancy-based diagonal topology tests. The new BoxGeometry export fixtures bypass this voxel path.
Reviewed by GPT 6.1 Sol
| // adjacent groups stay welded instead of each group smoothing them differently. | ||
| // Seam vertices interior to the combined solid never enter the graph and map to | ||
| // their original grid position in every group. | ||
| const solidPixels = combinedMask ?? meshingPixels; |
There was a problem hiding this comment.
[high] Combined-mask smoothing still leaves gaps at seam junctions
Sharing the coordinate mapper does not share the cap/wall subdivisions. For color rows AB, AB, A., using the same combined mask and skipRepair: true, A emits one right edge from grid (1,0) to (1,3), while B's seam ends at (1,2). Smoothing moves B's endpoint, but A never emits that vertex, leaving a reproduced gap of about 0.36 pixels. Include shared seam junctions in both groups' tessellation before smoothing.
Reviewed by GPT 6.1 Sol
| const geom = new THREE.BufferGeometry(); | ||
| geom.userData.kromacutExportGeometry = { positions, indices, itemSize: 3 }; | ||
| const mat = new THREE.MeshStandardMaterial({ color: '#' + hex }); | ||
| const syntheticMesh = new THREE.Mesh(geom, mat); |
There was a problem hiding this comment.
[medium] Voxel conversion discards scene transforms
The synthetic mesh has an identity matrixWorld, while its vertices are rebuilt from untransformed mask coordinates. A tagged one-pixel mesh translated to (7,8,0) exports at (7,8) normally but at (0,0) with extruderCount: 2; rotations and scales are also lost. Preserve the source transform when rebuilding, or fall back to the original meshes when transforms cannot be represented safely, as the STL compaction path does.
Reviewed by GPT 6.1 Sol
| const mat = Array.isArray(mesh.material) ? mesh.material[0] : mesh.material; | ||
| let hex = 'FFFFFF'; | ||
| if ('color' in mat) { | ||
| hex = (mat as THREE.MeshStandardMaterial).color.getHexString().toUpperCase(); |
There was a problem hiding this comment.
[medium] Voxel conversion loses physical filament-color overrides
This reads the live preview material and discards the source mesh's physical filament metadata. A blue preview mesh tagged with kromacutFilamentHex: '#FF0000' exports red normally but blue with extruderCount: 2. The original layerFilamentColors indices can also become misaligned after meshes are collapsed and sorted by nozzle. Resolve physical colors on the original meshes before merging, then carry the representative filament color onto each synthetic mesh.
Reviewed by GPT 6.1 Sol
- Preserve indexed voxel surface fans at diagonal contacts and real Z gaps - Share cap and wall subdivisions before combined-mask smoothing - Retain transforms and unsupported geometry through safe conversion fallback - Resolve physical filament colors before nozzle collapse and sorting - Add occupancy and export regressions; update the unreleased changelog
Fixes for the automated reviewPushed Findings
Also fixed
Verification: 162 meshing/export/voxel tests pass, run outside the sandbox. Fixed by GPT 6.1 Sol |
vycdev
left a comment
There was a problem hiding this comment.
Automated code review: second pass
Verdict: Needs changes · New or remaining findings: 3 (3 inline)
Reviewed head 0d1bfb6, which includes the fixes for the first review. Scope: this PR's changes against develop; the other PRs in this stack are reviewed in their own threads.
All four first-pass findings are resolved. The 162 focused tests, TypeScript check, and targeted ESLint check pass. Additional probes found three remaining defects: non-manifold diagonal color groups, discarded smoothing during multi-head export, and synchronous voxel reconstruction that blocks the UI.
First-pass findings
- ✅ Resolved: Diagonal voxel contacts create non-manifold edges. Voxel faces now retain separate indexed surface fans, and export preserves those indices. The exhaustive 2×2×2 occupancy checks and serialized diagonal fixtures pass.
- ✅ Resolved: Combined-mask smoothing still leaves gaps at seam junctions. Cap and wall boundaries now include shared unit-grid subdivisions before smoothing. The reported junction fixture passes for every smoothing strength.
- ✅ Resolved: Voxel conversion discards scene transforms. Nonidentity world transforms trigger fallback to original geometry. Translation, rotation, scale, and parent-transform export comparisons pass.
- ✅ Resolved: Voxel conversion loses physical filament-color overrides. Representative colors are resolved from original mesh metadata and original positional overrides before nozzle sorting and collapse. The physical-color regression passes.
Reviewed by GPT 6.1 Sol
| const startedAt = performance.now(); | ||
| const meshingPixels = repairBinaryCornerContacts(activePixels, width, height); | ||
| const skipBottomCap = options.skipBottomCap ?? false; | ||
| const meshingPixels = options.skipRepair |
There was a problem hiding this comment.
[high] Preserve separate diagonal shells when skipping repair
For color rows AB/BA, generate A with skipRepair: true and a filled combinedMask. Both meshers still weld the diagonal pixels through their coordinate-based vertex maps, producing a vertical edge with four incident triangles; this reproduces at every smoothing strength. The voxel fix does not protect this meshing path. Preserve independent surface fans here, and assert indexed topology rather than only triangle counts in the skipRepair regression.
Reviewed by GPT 6.1 Sol
| return { mask: data.mask, baseZ: gl.baseZ_world, topZ: data.topZ_world }; | ||
| }); | ||
|
|
||
| const { positions, indices } = buildNozzleVoxelMesh(layerRecords, width, height, pixelSize); |
There was a problem hiding this comment.
[medium] Preserve smoothing when rebuilding nozzle geometry
This reconstruction ignores the source's smoothed positions and rebuilds square voxels from activePixels. A tagged one-pixel Medium mesh at pixel size 1 exports XY bounds approximately 0.34648–0.65352 normally, but 0–1 with extruderCount: 2, while still recording Medium metadata. Multi-head export therefore changes the physical shape and ignores the selected smoothing. Fall back for smoothed sources or preserve their shared smoothing map during reconstruction.
Reviewed by GPT 6.1 Sol
| // eliminates coincident faces at color- and layer-boundaries that cause | ||
| // non-manifold geometry in slicers. | ||
| if ((options?.extruderCount ?? 0) >= 2) { | ||
| const manifoldMeshes = buildNozzleManifoldMeshes(meshes, options?.layerFilamentColors); |
There was a problem hiding this comment.
[medium] Yield during per-nozzle voxel reconstruction
Mask merging, voxel generation, face pairing, and triangulation all run synchronously before the exporter's existing yields or progress reporting. Exporting one filled 256×256 layer blocked the first timer callback for about 0.7 seconds in a focused probe; larger images increase this UI freeze. Make reconstruction asynchronous with periodic yields and progress updates, or move it into a worker.
Reviewed by GPT 6.1 Sol
- Keep diagonal surface fans separately indexed through meshing and export - Preserve original smoothed geometry during multi-head export - Yield and report progress throughout nozzle reconstruction - Add topology, smoothing, and responsiveness regressions; update changelog
# Conflicts: # CHANGELOG.md
Fixes for the second automated reviewPushed Findings
Verification: Full unit suite 890/890, Fixed by GPT 6.1 Sol |
First of seven stacked PRs splitting up #38 (Multi Print Head Capability) into smaller reviews. This one is independent of the others and targets
developdirectly.What
M600) markers for head swaps, and per-nozzle voxel meshes (voxelMesh.ts) so each head's material is its own object.combinedMaskso adjacent color groups move shared boundary vertices identically instead of peeling apart at shared edges.Nothing calls the new export options yet; the UI wiring arrives in part 5.
Review focus
Slicer-safe topology (no T-junctions, open boundaries, inverted winding, non-manifold edges) in the voxel meshes and the
combinedMaskpath.Tests
tests/export3mf.test.tsand the newtests/meshingOptions.test.ts.tscis clean, and the export and meshing tests pass (152).Stack
mph-split-2-analysis-core)mph-split-3-color-runs)mph-split-4-schedule-plan)mph-split-5-ui-wiring)mph-split-6-docs)mph-split-7-color-grouping)🤖 Generated with Claude Code