From 03e3780a6fcfbbc549f1c23efbf6a20902f21150 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Mon, 11 Dec 2017 11:46:15 +0100 Subject: [PATCH] Fix holes on reversed paths --- src/d3/ShapeMesh.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/d3/ShapeMesh.js b/src/d3/ShapeMesh.js index 018c746..50bfac1 100644 --- a/src/d3/ShapeMesh.js +++ b/src/d3/ShapeMesh.js @@ -245,10 +245,20 @@ class ShapeMesh extends THREE.Object3D { return { x: point.x, y: y + this._z, z: point.y }; } + + _reversePath() { + const sx = this._transform.sx > 0; + const sy = this._transform.sy > 0; + + return sx !== sy; + } + _updateVerticesHorizontal(heightStep, paths, center, indexCounter) { for (let pathindex = 0; pathindex < paths.length; pathindex ++) { const path = applyMatrixOnPath(paths[pathindex], this._transform); + if (this._reversePath()) path.reverse(); + for (let pathIndex = 0; pathIndex < path.length; pathIndex ++) { let point = path[pathIndex]; @@ -281,8 +291,10 @@ class ShapeMesh extends THREE.Object3D { for (let pathsIndex = 0; pathsIndex < paths.length; pathsIndex ++) { const path = applyMatrixOnPath(paths[pathsIndex], this._transform); + if (this._reversePath()) path.reverse(); + for (let pathIndex = 0; pathIndex < path.length; pathIndex ++) { - let point = path[pathIndex]; + const point = path[pathIndex]; for (let heightStep = 0; heightStep < numHeightSteps; heightStep ++) { const { x, y, z } = this._getPoint(point, heightStep, center);