In C/C++, OpenGL has a nice library for tessellating complex polygonal shapes into triangle strips and fans. That library is "GLUtesselator".
Is there any library with the equivalent functionality for WebGL(HTML)?
GLUtesselator has been ported to javascript by Brendan Kenny at Google Maps. Here's a link to libtess.js on github.
Vladimir Agafonkin (leaflet.js, Mapbox) recently developed earcut.js which is currently "The fastest and smallest JavaScript polygon triangulation library for your WebGL apps" Here's the github link for earcut.js.
Three.JS uses a triangulation function to render text to polygons. It isn't exposed publicly but it looks like it should be fairly easy to extract. Actually it is exposed as THREE.Shape.Utils.triangulateShape.
I had the same issue (in HTML Canvas with Box2D shapes) and tried to use the triangulation function of Three.js, but it was far easier for me to use this really good library : https://code.google.com/p/poly2tri/
The JS Implementation is there and worked perfectly for me : https://code.google.com/p/poly2tri/source/browse/?repo=javascript#hg%2Fsrc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With