Skip to content

Commit

Permalink
PathLayer: fix rightDeltas attribute generation when using flat verti…
Browse files Browse the repository at this point in the history
…ces (visgl#2694)
  • Loading branch information
Pessimistress authored and Xiaoji Chen committed Feb 20, 2019
1 parent 51b6bb9 commit 21e14e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/layers/src/path-layer/path-tesselator.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ export default class PathTesselator extends Tesselator {
let nextPoint;

for (let i = context.vertexStart, ptIndex = 1; ptIndex < numPoints; i++, ptIndex++) {
nextPoint = this.getPointOnPath(path, ptIndex + 1);
if (!nextPoint) {
if (ptIndex + 1 < numPoints) {
nextPoint = this.getPointOnPath(path, ptIndex + 1);
} else {
nextPoint = isPathClosed ? this.getPointOnPath(path, 1) : endPoint;
}

Expand Down
2 changes: 2 additions & 0 deletions test/modules/layers/path-tesselator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ test('PathTesselator#constructor', t => {
);

t.ok(ArrayBuffer.isView(tesselator.get('leftDeltas')), 'PathTesselator.get leftDeltas');
t.ok(tesselator.get('leftDeltas').every(Number.isFinite), 'Valid leftDeltas attribute');
t.deepEquals(
tesselator.get('leftDeltas').slice(0, 6),
[0, 0, 0, 1, 1, 0],
Expand All @@ -116,6 +117,7 @@ test('PathTesselator#constructor', t => {
[1, 1, 0, 0, 0, 0],
'rightDeltas are filled'
);
t.ok(tesselator.get('rightDeltas').every(Number.isFinite), 'Valid rightDeltas attribute');
t.deepEquals(
tesselator.get('rightDeltas').slice(-3),
[1, 1, 0],
Expand Down

0 comments on commit 21e14e2

Please sign in to comment.