tess2-rust
A pure Rust port of libtess2 — the SGI tessellation library refactored by Mikko Mononen. This is an exact mathematical 1-to-1 port of the C library, preserving all algorithmic behavior including edge cases. Zero external dependencies. No unsafe code. WASM-compatible.
Try the Interactive Demo — 6 interactive pages running entirely in your browser via WebAssembly.
Crate listing: tess2-rust on crates.io.

Features
- Polygon Tessellation — tessellate complex polygons into triangles, quads, or boundary contours
- Winding Rules — five rules (Odd, NonZero, Positive, Negative, AbsGeqTwo) for flexible fill control
- Multiple Output Types — triangles, connected polygons of configurable size, and boundary contours
- Self-Intersecting Polygons — handles self-intersections, overlapping contours, and degenerate geometry
- No Unsafe Code — zero
unsafeblocks in the entire codebase - Zero Dependencies — no external runtime dependencies
- WASM-Compatible — compiles to WebAssembly for browser-based usage
Interactive Demo
All 6 demo pages run in-browser via WebAssembly with no server-side processing:
| Page | Description |
|---|---|
| Basic Shapes | Triangles, quads, pentagons, and concave shapes — the building blocks of tessellation |
| Polygon with Hole | Outer/inner contour reversal and hole detection |
| Winding Rules | All five rules compared on stars, bowties, nested shapes, and overlapping polygons |
| Output Modes | Triangles, quads, connected polygons, and boundary contours |
| Shape Gallery | Real-world datasets — dude, tank, spaceship, and more from poly2tri and GLU test suites |
| Interactive Editor | Draw your own polygons and watch them tessellate in real time |
Quick Start
Add this to your Cargo.toml:
[]
= "1.0"
use ;
let mut tess = new;
tess.add_contour;
tess.tessellate;
let vertices = tess.vertices;
let elements = tess.elements;
Winding Rules
Odd— Fill regions with odd winding number (like even-odd fill)NonZero— Fill regions with non-zero winding numberPositive— Fill regions with positive winding numberNegative— Fill regions with negative winding numberAbsGeqTwo— Fill regions with winding number >= 2 in absolute value
Development
Building & Testing
Running the Demo Locally
Then open http://localhost:3000 in your browser.
License
SGI Free Software License B (functionally equivalent to MIT). See LICENSE.
Acknowledgments
- Mikko Mononen — Author of the libtess2 refactoring of the SGI code
- SGI — Original tessellation library from the OpenGL Sample Implementation
- Ported by Lars Brubaker, sponsored by MatterHackers
- Ported using Claude by Anthropic