I have the outline of a building in lat,lngs and if the buildings have holes inside of it I also have those. I am trying to find a way to make these latlngs, MultiPolygons i geojson into meshes in unity. How could I easily do this? I used three js before and they had something called ShapeGeometry but there is nothing like that for unity.
We use Clipper and Triangle.net and similar polygonization/triangulation solutions to obtain what ShapeGeometry seems to be doing.
Maybe someone else can point you to a useful direction, I’ve rolled my own libraries to deal with Bezier, convex polygons and 2D Delaunay triangulation. It’s a lot of work, and you really want something off-the-shelf to help you with that. Asset store or github perhaps, and there might be something already among the Unity’s own packages, but I personally wouldn’t know to tell you where to look.
Earclipping is relatively easy to understand but is not actually that trivial to implement, nor it scales well. I’ve done it, mostly for my own “academic” purposes, and abandoned it immediately. The greatest obstacle when working with meshes and triangles in general is properly setting up the actual data structures, because Unity’s mesh is really just the final container, it’s not really useful for interrogating the topology in an optimal way. You want either a winged-edged setup or a half-edge setup, but it’s a lot of work to get everything right.
There are several Delaunay triangulation algorithms all of which are much more potent than the earclipping (even the most basic one), however, you will probably have a hard time understanding and implementing any of them. Especially the ones with fixed edges.
If you want to learn more about them just try searching Delaunay, Voronoi sweep line, or Fortune’s algorithm on github and elsewhere. I can’t really come up with any resources other than again pointing you to looking up clipper and triangle.net. These are good starting points which will open up a lot of ground for you to start investigating deeper into the topic, but sadly, as far as I can tell there is nothing you can grab like ShapeGeometry that simply works. Maybe I’m wrong.