Skip to content

Commit

Permalink
fix for vertical faces
Browse files Browse the repository at this point in the history
  • Loading branch information
ign-packo committed Oct 28, 2021
1 parent 121ebfc commit f9325d9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Converter/Feature2Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,17 @@ function featureToPolygon(feature, options) {
(geomVertices[3 * (i - 1) + 1] + geomVertices[3 * i + 1]);
}
normal.normalize();
const pt0 = new THREE.Vector3(geomVertices[0], geomVertices[1], geomVertices[2]);
for (let i = 1; i < count; i++) {
const ptIn = new THREE.Vector3(geomVertices[3 * i],
const quaternion = new THREE.Quaternion();
quaternion.setFromUnitVectors(normal, new THREE.Vector3(0, 0, 1));
// const pt0 = new THREE.Vector3(geomVertices[0], geomVertices[1], geomVertices[2]);
for (let i = 0; i < count; i++) {
const pt = new THREE.Vector3(geomVertices[3 * i],
geomVertices[3 * i + 1],
geomVertices[3 * i + 2]);
let v = ptIn - pt0;
v -= normal.dot(v) * normal;
const ptOut = ptIn + v;
geomVertices[3 * i] = ptOut.x;
geomVertices[3 * i + 1] = ptOut.y;
geomVertices[3 * i + 2] = ptOut.z;
pt.applyQuaternion(quaternion);
geomVertices[3 * i] = pt.x;
geomVertices[3 * i + 1] = pt.y;
geomVertices[3 * i + 2] = pt.z;
}
const triangles = Earcut(geomVertices, holesOffsets, 3);
const startIndice = indices.length;
Expand Down

0 comments on commit f9325d9

Please sign in to comment.