I am doing a triangulation by using the library Poly2Tri.
My code:
var swctx = new poly2tri.SweepContext(contour);
swctx.triangulate();
var triangles = swctx.getTriangles();
for (var w = 0; w < triangles.length; w++) {
pts_tri = triangles[w].points_;
index1 = pts2.findIndex(x => x[0] == pts_tri[0].x && x[1] == pts_tri[0].y)
}
for (var k = 0; k < result.length; k++) {
geometry.faces.push(
new THREE.Face3(result[k][0].id, result[k][1].id, result[k][2].id)
);
}
It doesn't raise an error while loading the libraries!
Result:
1.) Mozzila Firefox: works (no error occurs)!
2.) Google Chrome: it does not work! (error message: cannot handle collinear points)
My Question is:
1.)How can it be that the same code including the same library works for Firefox but not for Chrome? Does it depend on the Javascript engine of the Browser?
So I read that Chrome uses V8 engine and Firefox uses Rhino/SpiderMonkey. But I thought it depends only on the library which I am using for the triangulation!
2.) How can I run the code in Chrome (by using the same library?) Is there a possibility to avoid this error?
3.) Does the library support collinear points? Because in Firefox it works!!!