mapbox / earcut

The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
ISC License
2.21k stars 207 forks source link

Failure with simple case in 3D #153

Closed PieroV closed 2 years ago

PieroV commented 2 years ago

Hi, this library seems very interesting! However I was trying it out with some simple cases to get started, but I encountered an unexpected result:

> earcut([0, 0, 0,  1, 0, 0,  1, 1, 0,  0, 1, 0], null, 3)
[ 2, 3, 0, 0, 1, 2 ]
> earcut([0, 0, 0,  0, 1, 0,  0, 1, 1,  0, 0, 1], null, 3)
[]

As you can see, I performed a simple permutation: X -> Y, Y -> Z, Z -> X, so I expected the same result.

For my use case, I am sure all my vertices are planar, so I can project them and run the tessellation in 2D instead, but I thought of reporting this problem anyway.

Thanks 🌝 !

mourner commented 2 years ago

This is by design. See #21 for discussion along with many linked issues.

PieroV commented 2 years ago

I see. Thanks for your answer. Could you please consider adding this in the readme, with the 3D example?