A browser-based 3D print slicer that turns STL meshes into layer contours and Prusa MK4 G-code. Load a model, tune print settings, slice in a background worker, preview layers in 2D and 3D, then download the generated G-code.
- STL import — Upload ASCII or binary STL files with mesh validation (bounds, degenerate geometry, size limits).
- Z-plane slicing — Intersect the mesh with horizontal planes from the bed upward, connect segments into closed perimeters, and build a layer stack.
- Variable layer height — Set a default layer height plus optional Z ranges where height is computed from a mathjs expression in
z(e.g.0.1 + z * 0.01). - Prusa MK4 G-code — Perimeter-only toolpaths with temperatures, speeds, relative extrusion, first-layer slowdown, and optional
M600pause at a chosen Z height. - 3D preview — Three.js viewer with orbit controls, orthographic-style view presets (keyboard shortcuts H/T/B/F/K/L/R), build plate grid, and live slice contours with Z clipping while slicing or scrubbing layers.
- 2D layer preview — Canvas view of the active layer’s contours with a layer slider.
- Background slicing — Slicing and G-code generation run in a Web Worker so the UI stays responsive; progress updates stream back during the slice.
- Inspect output — Tabs for 3D preview, raw STL source, and generated G-code; download
.gcodewhen ready.
| Setting | Description |
|---|---|
| Layer height | Default slice step (mm) |
| Nozzle / bed temperature | M104 / M140 and wait commands |
| Pause at Z | Insert M600 when a layer is near this height (0 = off) |
| Line width / filament diameter | Used for extrusion (E) on print moves |
| Print / travel / first-layer speed | F feed rates on G1 moves |
Requirements: Node.js 24+
npm install
npm run devOpen the URL shown in the terminal (typically http://localhost:5173).
- Upload STL — Choose a
.stlfile. - Adjust parameters — Set layer height, temperatures, speeds, and optional Z-based layer height ranges.
- Slice — Run the slicer; watch progress in the status bar and 3D clip plane.
- Review — Scrub layers in the bottom panel or use the G-code tab.
- Download G-code — Save the file for your printer.
npm run build # Typecheck and production build
npm run preview # Serve the production build locally
npm run lint # ESLintSTL file → mesh data → plane intersections → 2D contours per layer → G-code
- Load — STL is parsed into indexed triangle soup (
MeshData). - Slice — For each Z height, edges crossing the plane become 2D segments; segments are chained into contours (
connectContours). - G-code — Each layer’s contours are emitted as travel + extruding
G1moves with Prusa-style start/end gcode.
Slicing runs in src/workers/sliceWorker.ts; the main thread only receives progress ticks and the final result.
| Path | Role |
|---|---|
src/components/ |
React UI (SlicerApp, viewer, parameters, code panel) |
src/geometry/ |
STL loading, mesh bounds, plane intersection, contour wiring |
src/slicing/ |
Slice loop, layer height resolution, worker bridge |
src/gcode/ |
G-code generators (default: Prusa MK4) |
src/view/ |
Three.js contour overlay and camera presets |
src/workers/ |
Web Worker entry for slice + generate |
src/types/ |
Shared TypeScript types |
- React 19 + TypeScript
- Vite 8
- Three.js for 3D preview
- mathjs for variable layer height expressions
This is a learning / prototype slicer, not a full replacement for PrusaSlicer or Cura:
- Perimeters only — No infill, supports, skirts, or multiple extruders.
- Single G-code profile — Prusa MK4 FDM output; additional generators can be registered via
registerGCodeGenerator. - Browser constraints — Very large STLs may hit memory or worker limits; validation warns on extreme mesh sizes.
No license file is included yet. Add one before distributing or publishing the project.