Skip to content

Commit

Permalink
Cope with no slice while closing holes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdhooper committed Nov 5, 2017
1 parent 8114cbc commit b3fcd2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ module.exports = function(THREE) {
};

GeometryBuilder.prototype.closeHoles = function() {
if ( ! this.newEdges[0].length) {
return;
}
facesFromEdges(this.newEdges)
.forEach(function(faceIndices) {
var normal = this.faceNormal(faceIndices);
Expand Down
11 changes: 11 additions & 0 deletions src/test/slice.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,17 @@ describe("three.js slice geometry", function() {
expect(sliced.faces).toEqual(geometry.faces);
expect(sliced.faceVertexUvs).toEqual(geometry.faceVertexUvs);
});

it("sliced with whole geometry in front of plane, with closing holes", function() {
var plane = new THREE.Plane(
new THREE.Vector3(1, 0, 0),
2
);
var sliced = sliceGeometry(geometry, plane, true);
expect(sliced.vertices).toEqual(geometry.vertices);
expect(sliced.faces).toEqual(geometry.faces);
expect(sliced.faceVertexUvs).toEqual(geometry.faceVertexUvs);
});
});

describe("closed geometry", function() {
Expand Down

0 comments on commit b3fcd2a

Please sign in to comment.