Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebGL and Tessellation library?

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)?

like image 743
CRasterImage Avatar asked Oct 15 '12 17:10

CRasterImage


3 Answers

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.

like image 150
GrantE Avatar answered Sep 28 '22 12:09

GrantE


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.

like image 34
Elisée Avatar answered Sep 28 '22 12:09

Elisée


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

like image 35
Michaël Hoste Avatar answered Sep 28 '22 13:09

Michaël Hoste