diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index 6587103..97a1178 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -63,9 +63,9 @@ super(); /** - * An array of points to draw + * An array of points to draw, 2 numbers per point * - * @member {PIXI.Point[]} + * @member {number[]} * @protected */ this.points = []; diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index 6587103..97a1178 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -63,9 +63,9 @@ super(); /** - * An array of points to draw + * An array of points to draw, 2 numbers per point * - * @member {PIXI.Point[]} + * @member {number[]} * @protected */ this.points = []; diff --git a/packages/graphics/src/utils/buildLine.js b/packages/graphics/src/utils/buildLine.js index ebddf05..f194a39 100644 --- a/packages/graphics/src/utils/buildLine.js +++ b/packages/graphics/src/utils/buildLine.js @@ -250,7 +250,9 @@ { let i = 0; - const points = graphicsData.points || graphicsData.shape.points; + const shape = graphicsData.shape; + const points = graphicsData.points || shape.points; + const closedShape = shape.type !== SHAPES.POLY || shape.closeStroke; if (points.length === 0) return; @@ -258,21 +260,21 @@ const indices = graphicsGeometry.indices; const length = points.length / 2; - let indexStart = verts.length / 2; - // sort color + const startIndex = verts.length / 2; + let currentIndex = startIndex; + + verts.push(points[0], points[1]); for (i = 1; i < length; i++) { - const p1x = points[(i - 1) * 2]; - const p1y = points[((i - 1) * 2) + 1]; + verts.push(points[i * 2], points[(i * 2) + 1]); + indices.push(currentIndex - 1, currentIndex); - const p2x = points[i * 2]; - const p2y = points[(i * 2) + 1]; + currentIndex++; + } - verts.push(p1x, p1y); - - verts.push(p2x, p2y); - - indices.push(indexStart++, indexStart++); + if (closedShape) + { + indices.push(currentIndex - 1, startIndex); } }