WebGL and Tessellation library?
Asked Answered
K

4

8

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

Kinglet answered 15/10, 2012 at 17:57 Comment(0)
L
3

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.

Liquate answered 16/10, 2012 at 6:31 Comment(1)
This looks promising. Thanks! I will check it out.Kinglet
H
4

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.

Hannie answered 1/4, 2015 at 14:14 Comment(0)
L
3

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.

Liquate answered 16/10, 2012 at 6:31 Comment(1)
This looks promising. Thanks! I will check it out.Kinglet
M
3

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

Muster answered 10/10, 2013 at 12:37 Comment(0)
I
2

There are several libraries for that. What you use depends also on the quality of your data. Some libraries crash on duplicate points, self intersecting polygons or other inconsistencies in the data.

Ivon answered 5/2, 2016 at 8:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.