Here's the wip of the triangulation. It works with the the polygon defined by sprite instances in a CW order.
Using a mesh to display the triangles didn't quite pan out because it gives thin transparent slivers due to math rounding. So it also lets you draw the triangles with the canvas as well since it doesn't have the slivers. It doesn't look worthwhile to extend it to generate convex polygons or triangle strips at this point. It will need reworking if you want to define the polygon in another way other than sprite instances. Doesn't work with self intersecting or CCW polygons, but the CCW case can be solved by detecting the order and reversing the list.
dropbox.com/scl/fi/png6jg6a1qresctjq5ra6/triangulate_ear_clip_mesh_wip.c3p
Alternately, if you want to use js for this you could look into this one:
github.com/mapbox/earcut
Or you could take the triangulation function out the old c2 chipmunk plugin. That one generates convex polygons.
Edit:
Just noticed that points ordered in CCW order could be used for a convex hull.