Skip to content

feat(model): 3MF export + experimental 3D-print options - #43

Merged
NyleGarcia merged 19 commits into
mainfrom
feat/model-3mf
Nov 20, 2026
Merged

NyleGarcia merged 19 commits into
mainfrom
feat/model-3mf

Conversation

@NyleGarcia

Copy link
Copy Markdown
Contributor

Summary

  • 3MF export beside GLB/STL (Separate or Assembly layout); "Save as…" button + hint.
  • EXPERIMENTAL print options, each own toggle: scale (fit mm / 1:N ratio), sit on bed, bed check + shrink, drop tiny parts, make solid (voxel), thicken, hollow + drain holes, stand peg hole, split for bed with pins, multicolour 3MF, simplify, no weapons.
  • CLI flags mirror UI (--3mf, --fit-mm, --scale-ratio, --bed, --solid, --hollow, --split, …) + dev print-glb.
  • Cache-hit print runs in capped asset worker; memory estimate counts solid steps.
  • Spec: docs/plans/specs/model-print.md.

Real runs

  • Skylark, all options except split: 25.5 s, 2.31 GB peak; hull/engine/glass watertight, 150 mm, ~200k tris.
  • Gladius 1:100, 120 mm bed, split: 4 watertight parts fit bed, 5.6 s, 1.58 GB.

Known limits

  • Not yet opened in PrusaSlicer/Bambu Studio.
  • Simplify ~20 s; split w/o simplify heavy (~4.2M tris).
  • Glass classified per node; solid ~half voxel oversize.

Test plan

  • cargo test (1046), clippy, deny
  • npm test (163), check
  • Open 3MF in a slicer

- assets::threemf: GLB triangles (stl::glb_mesh, transforms baked, Z-up)
  as a core-spec 3MF in metres; vertices shared by exact f32 equality,
  degenerate triangles left out; XML streamed into a deflated zip.
- assets::print: write_meshes writes the STL and/or 3MF next to the GLB
  from one triangle read; ModelDone reports them as `meshes`.
- three_mf in ModelOptions (not part of the cache key) and
  AssetExportModelRequest (serde default) in the real/mock backends and
  TS mirror/mock; samples regenerated.
- CLI `dev export-model --3mf` (experimental), refused with --preset full.
- Export dialog: "Also write a 3MF (experimental)" switch with badge,
  "Save as…" button, a line saying where the STL/3MF go.
- zip 9 (deflate via flate2/zlib-rs only) in starorg-data.
- Docs: user guide and addendum.
…/3MF

- assets::print is a module: PrintOptions (scale none|fit-mm|ratio, bed,
  shrink to bed, drop small, solid + resolution, thicken, hollow + drain,
  pegs, split, multicolor, simplify, no weapons; all off by default, serde
  defaults, validate with needs-solid/needs-split checks) and the fixed
  pipeline apply() -> PrintOutput (parts with group labels, unit, layout,
  notes); write_meshes keeps working and always sits the model on the bed.
- Shared Mesh (shared vertices, optional per-triangle group from the GLB
  node path), stl::glb_labeled_triangles, VoxelGrid API, Cut/Part types.
- One file per feature with final signatures: scale.rs (factor, scale,
  sit_on_bed done; drop_tiny, bed_check stubs), voxel.rs, split.rs,
  color.rs (layout done), simplify.rs; model::strip_weapons stub.
- threemf writes several objects as build items or one assembly, with
  display colours, in millimetre or metre units.
- no_weapons is in ModelOptions::key (-noweapons); ModelDone carries notes.
- Contract: one nested `print` object (serde default) on
  AssetExportModelRequest in the real and mock backends, TS mirror and
  mock; print notes in the export note; samples regenerated.
- CLI: print flags on dev export-model (experimental, exit 2 when they do
  not go together or need --preset print / --stl / --3mf) and
  `dev print-glb <GLB> --out DIR` to run the pipeline on a GLB.
- Export dialog: collapsible "3D print (experimental)" section with every
  control badged, bed size remembered, Save as disabled on a problem.
- Spec docs/plans/specs/model-print.md (active), indexes, todo, guide.
strip_weapons drops gun mounts, guns, mining lasers, tractor beams,
missile racks, missiles and bombs from the loadout before StarBreaker
assembles the GLB; turret bodies, countermeasures, thrusters and paint
stay. The export notes how many loadout parts were left out. The types
come from the LIVE loadouts of 15 ships; real_weapons checks four.
…rimental)

sit_on_bed centres x/y as well as putting the bottom at z = 0. bed_check
turns a scaled model 90 degrees about Z when only that fits, shrinks it
with shrink-to-bed (turned when that keeps it larger) or notes that it
does not fit; real size in metres is not checked. drop_tiny welds
corners, finds loose parts and leaves out those whose bounding-box
diagonal at print size is under the limit. The pipeline now measures a
fit size after small parts are dropped.
Garland-Heckbert QEM in pure Rust: link condition, no flips or slivers, open edges and group borders held by border planes, non-manifold vertices fixed, small open pieces never erased. Closed parts stay closed; parts within budget are unchanged.
- voxelize: conservative triangle/box rasterisation per z-slab (rayon),
  outside flood fill on bitsets after a 2-voxel closing, then ray-stabbing
  votes (seen along >= 3 of 6 axis directions) so hulls with openings fill
  instead of leaking into a thin shell; per-cell group labels (closest
  triangle); grids above 2^29 cells coarsen with a note.
- extract / extract_where: well-composed fix-up (no edge/corner-only
  contacts), voxel faces on shared corners, clamped Laplacian smoothing
  that never flips a triangle: closed, outward, 2-manifold by construction.
- thicken: opening residue away from rounded edges, dilated by t/2.
- hollow: erosion by the wall, cavities under 1 mm3 kept solid, drain holes
  from each cavity's lowest point down through the bottom wall.
- peg: holes across each cut at the most solid point of the cut face and a
  stand hole in the underside near the centre of mass, clamped so they
  never break through, with notes.
- Bits helpers (dilate/erode/flood/components) for the split and colour
  steps; pipeline notes the coarsened voxel size (one line in mod.rs).
Cut the voxel solid with whole-grid axis-aligned planes into the fewest
pieces that each fit the bed (fewest pieces, then fewest slivers, then
least cut area; every plan scored when few, else per axis order), add
2 mm alignment pin holes 4 mm into each side of every cut when --peg is
not given, name the pieces part1, part2, ... and lay them out side by
side for the 3MF's separate build items.
…olour

Classify Print shell triangles into hull, engine and glass from their GLB
node paths (materials are only material_NN with MaterialMode::None). Without
Make solid each group is its own 3MF part; with it, outer-surface voxels keep
their group, glass and engine reach 1.2 mm in (glass > engine > hull) and
each group is extracted as its own closed mesh. The 3MF stays one object of
components with basematerials colours; the STL stays one mesh.
# Conflicts:
#	docs/plans/specs/model-print.md
# Conflicts:
#	docs/plans/specs/model-print.md
# Conflicts:
#	docs/plans/specs/model-print.md
- Split pieces keep their side-by-side layout: after scale's x/y centring
  each piece was centred alone (stacked at the origin). Each piece, with
  its colour parts, is now lowered on its own and the layout centred.
- --peg without --split is accepted (stand hole only), in Rust, TS, UI
  and CLI help.
- A note when simplify cannot reach its triangle budget.
- Drop-small and split wording: bounding-box diagonal, alignment pins.
- User guide model export section and spec status with real-data runs.
…f the bar; keep long job labels clear of Stop
# Conflicts:
#	app/src/lib/contract/mock-dev.gen.json
@NyleGarcia
NyleGarcia merged commit 799c383 into main Nov 20, 2026
@NyleGarcia
NyleGarcia deleted the feat/model-3mf branch November 20, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant