Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (points.length >= 6)
{
const holeArray = [];
// Process holes..
for (let i = 0; i < holes.length; i++)
{
const hole = holes[i];
holeArray.push(points.length / 2);
points = points.concat(hole.points);
}
// sort color
const triangles = earcut(points, holeArray, 2);
if (!triangles)
{
return;
}
const vertPos = verts.length / 2;
for (let i = 0; i < triangles.length; i += 3)
{
indices.push(triangles[i] + vertPos);
indices.push(triangles[i + 1] + vertPos);
indices.push(triangles[i + 2] + vertPos);
}
for (let i = 0; i < points.length; i++)
triangulate(graphicsData, graphicsGeometry)
{
const points = graphicsData.points;
const verts = graphicsGeometry.points;
const indices = graphicsGeometry.indices;
const vecPos = verts.length / 2;
const triangles = earcut(points, null, 2);
for (let i = 0, j = triangles.length; i < j; i += 3)
{
indices.push(triangles[i] + vecPos);
// indices.push(triangles[i] + vecPos);
indices.push(triangles[i + 1] + vecPos);
// indices.push(triangles[i + 2] + vecPos);
indices.push(triangles[i + 2] + vecPos);
}
for (let i = 0, j = points.length; i < j; i++)
{
verts.push(points[i], points[++i]);
}
},
};
}
// get first and last point.. figure out the middle!
const verts = webGLData.points;
const indices = webGLData.indices;
const length = points.length / 2;
// sort color
const color = hex2rgb(graphicsData.fillColor);
const alpha = graphicsData.fillAlpha;
const r = color[0] * alpha;
const g = color[1] * alpha;
const b = color[2] * alpha;
const triangles = earcut(points, holeArray, 2);
if (!triangles)
{
return;
}
const vertPos = verts.length / 6;
for (let i = 0; i < triangles.length; i += 3)
{
indices.push(triangles[i] + vertPos);
indices.push(triangles[i] + vertPos);
indices.push(triangles[i + 1] + vertPos);
indices.push(triangles[i + 2] + vertPos);
indices.push(triangles[i + 2] + vertPos);
}
if (graphicsData.fill)
{
const color = hex2rgb(graphicsData.fillColor);
const alpha = graphicsData.fillAlpha;
const r = color[0] * alpha;
const g = color[1] * alpha;
const b = color[2] * alpha;
const verts = webGLData.points;
const indices = webGLData.indices;
const vecPos = verts.length / 6;
const triangles = earcut(recPoints, null, 2);
for (let i = 0, j = triangles.length; i < j; i += 3)
{
indices.push(triangles[i] + vecPos);
indices.push(triangles[i] + vecPos);
indices.push(triangles[i + 1] + vecPos);
indices.push(triangles[i + 2] + vecPos);
indices.push(triangles[i + 2] + vecPos);
}
for (let i = 0, j = recPoints.length; i < j; i++)
{
verts.push(recPoints[i], recPoints[++i], r, g, b, alpha);
}
}