diff --git a/src/extras/BuildingShapeUtils.js b/src/extras/BuildingShapeUtils.js index 6dedcf8..091f533 100644 --- a/src/extras/BuildingShapeUtils.js +++ b/src/extras/BuildingShapeUtils.js @@ -287,7 +287,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static combineCoordinates(shape) { const points = shape.extractPoints().shape; - points.pop(); var x = []; var y = []; var vec; @@ -337,7 +336,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static edgeLength(shape) { const points = shape.extractPoints().shape; - points.pop(); const lengths = []; var p1; var p2; @@ -359,7 +357,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static vertexAngle(shape) { const points = shape.extractPoints().shape; - points.pop(); const angles = []; var p0; var p1; @@ -394,7 +391,6 @@ class BuildingShapeUtils extends ShapeUtils { */ static edgeDirection(shape) { const points = shape.extractPoints().shape; - points.pop(); const angles = []; var p1; var p2; @@ -418,7 +414,6 @@ class BuildingShapeUtils extends ShapeUtils { static surrounds(shape, point) { var count = 0; const vecs = shape.extractPoints().shape; - vecs.pop(); var vec; var nextvec; for (let i = 0; i < vecs.length; i++) { @@ -468,7 +463,7 @@ class BuildingShapeUtils extends ShapeUtils { * Return the angle of the longest side of a shape with 90° vertices. * * @param {THREE.Shape} shape - the shape - * @return {number} + * @return {number} in radians from Pi > x > -Pi */ static longestSideAngle(shape) { const lengths = BuildingShapeUtils.edgeLength(shape); diff --git a/test/buildingpart.test.js b/test/buildingpart.test.js index f368452..16f6c55 100644 --- a/test/buildingpart.test.js +++ b/test/buildingpart.test.js @@ -61,6 +61,8 @@ test('Constructor', () => { expect(part.options.roof.orientation).toBe('along'); // toDo: Mock BuildingShapeUtils and test options + expect(BuildingShapeUtils.edgeDirection(part.shape)).toStrictEqual([1.5707963267948966, 0, -1.5707963267948966, 3.141592653589793]); + expect(BuildingShapeUtils.longestSideAngle(part.shape)).toBe(1.5707963267948966); expect(part.options.roof.direction).toBe(90); expect(errors.length).toBe(0); }); diff --git a/test/utils.test.js b/test/utils.test.js index b673c85..b71d8c5 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -115,20 +115,17 @@ const rightTriangle = new Shape(); rightTriangle.moveTo(1, 1); rightTriangle.lineTo(1, -1); rightTriangle.lineTo(-1, 1); -rightTriangle.lineTo(1, 1); const rightTriangle2 = new Shape(); rightTriangle2.moveTo(1, 1); rightTriangle2.lineTo(-1, 1); rightTriangle2.lineTo(1, -1); -rightTriangle2.lineTo(1, 1); const rectangle = new Shape(); rectangle.moveTo(-4.332738077015795, -5.882209888874915); rectangle.lineTo(-4.332738077015795, 5.88221335051411); rectangle.lineTo(4.332747472106493, 5.88221335051411); rectangle.lineTo(4.332747472106493, -5.882209888874915); -rectangle.lineTo(-4.332738077015795, -5.882209888874915); test('Extents no Rotation', () => { expect(BuildingShapeUtils.extents(rightTriangle)).toStrictEqual([-1, -1, 1, 1]);