Overview
The 3MF export module converts Manifold CSG geometry to the 3MF file format, optimized for BambuStudio and other modern slicers. It uses JSZip to package the 3MF archive structure.Import
Types
TriangleMesh
Intermediate mesh format for 3MF export.Float32Array
required
Flat array of vertex positions (3 floats per vertex: x, y, z)
Uint32Array
required
Flat array of triangle vertex indices (3 indices per triangle)
Functions
manifoldToTriangleMesh
Converts a Manifold object to TriangleMesh format.Manifold
required
Manifold geometry object
TriangleMesh with vertices and triangles.
Source: src/gridfinity/export3mf.ts:9-25
Example:
exportTo3MF
Packages triangle meshes into a 3MF file (ZIP archive).Array<{mesh: TriangleMesh, name: string}>
required
Array of meshes to include in the 3MF file. Each mesh has:
mesh: The triangle mesh dataname: Display name for the object in the slicer
downloadBlob
Triggers browser download of a Blob.Blob
required
File data to download
string
required
Suggested filename for download
3MF File Structure
The exported 3MF file follows the OPC (Open Packaging Conventions) ZIP structure:Key Files
[Content_Types].xml Defines MIME types for 3MF components:Multi-Object Export
The exporter supports multiple objects in a single 3MF file:Object ID Scheme
Each mesh generates two objects:- Volume object (odd ID): Contains mesh geometry
- Parent object (even ID): References volume as component, carries name
Build Items
Only parent objects appear in the build plate:Usage Pattern
Complete workflow from Manifold geometry to downloaded 3MF:BambuStudio Compatibility
The exporter includes specific metadata for BambuStudio:Required Metadata
Namespace Declarations
UUID Generation
Each build item receives a unique UUID:Coordinate System
The 3MF format uses millimeters with right-handed coordinates:- Units:
millimeter(explicitly declared) - Origin: Bottom-left-front corner
- Axes:
- +X: Right
- +Y: Back
- +Z: Up
XML Escaping
Object names are XML-escaped to prevent parsing errors:Compression
The 3MF ZIP archive uses DEFLATE compression:Error Handling
The export functions do not throw errors for invalid geometry. Ensure:- Manifold objects are valid (no self-intersections)
- Meshes are watertight (closed surfaces)
- Vertex and triangle arrays are properly formed
Performance
Mesh Conversion
Manifold mesh extraction is fast (< 10ms for typical bins):3MF Generation
JSZip operations are asynchronous and depend on mesh complexity:- Small bins (< 10k triangles): ~50ms
- Large bins (> 50k triangles): ~200ms
- Multiple objects: Linear scaling
