Crate earclip

Source
Expand description

The earclip module is a tool to convert 2D and 3D polygons into a triangle mesh designed to be fast, efficient, and sphere capable.

Basic usage:

use earclip::earclip_float;

let polygon = vec![vec![vec![0.0, 0.0, 0.0], vec![1.0, 0.0, 0.0], vec![0.0, 1.0, 0.0]]];
let (vertices, indices) = earclip_float(&polygon, None, None);
assert_eq!(vertices, vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]);
assert_eq!(indices, vec![1, 2, 0]);

Re-exports§

pub use earcut::earcut;
pub use earcut::signed_area;

Modules§

earcut
The earcut module

Traits§

GetXY
Trait to extract the x and y values
GetZ
Trait to extract the z value

Functions§

deviation
Returns a percentage difference between the polygon area and its triangulation area; used to verify correctness of triangulation
earclip
An earcut polygon generator with tesselation support
earclip_float
An earcut polygon generator with tesselation support
flatten
Flattens a 2D or 3D array whether its a flat point ([x, y, z]) or object ({ x, y, z })
flatten_float
Flattens a 2D or 3D array whether its a flat point ([x, y, z]) or object ({ x, y, z })
tesselate
Tesselates the flattened polygon