Skip to content

Commit 7184a65

Browse files
authored
Fixed direction bug (#136)
1 parent b0a37af commit 7184a65

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

src/extras/BuildingShapeUtils.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ class BuildingShapeUtils extends ShapeUtils {
287287
*/
288288
static combineCoordinates(shape) {
289289
const points = shape.extractPoints().shape;
290-
points.pop();
291290
var x = [];
292291
var y = [];
293292
var vec;
@@ -337,7 +336,6 @@ class BuildingShapeUtils extends ShapeUtils {
337336
*/
338337
static edgeLength(shape) {
339338
const points = shape.extractPoints().shape;
340-
points.pop();
341339
const lengths = [];
342340
var p1;
343341
var p2;
@@ -359,7 +357,6 @@ class BuildingShapeUtils extends ShapeUtils {
359357
*/
360358
static vertexAngle(shape) {
361359
const points = shape.extractPoints().shape;
362-
points.pop();
363360
const angles = [];
364361
var p0;
365362
var p1;
@@ -394,7 +391,6 @@ class BuildingShapeUtils extends ShapeUtils {
394391
*/
395392
static edgeDirection(shape) {
396393
const points = shape.extractPoints().shape;
397-
points.pop();
398394
const angles = [];
399395
var p1;
400396
var p2;
@@ -418,7 +414,6 @@ class BuildingShapeUtils extends ShapeUtils {
418414
static surrounds(shape, point) {
419415
var count = 0;
420416
const vecs = shape.extractPoints().shape;
421-
vecs.pop();
422417
var vec;
423418
var nextvec;
424419
for (let i = 0; i < vecs.length; i++) {
@@ -468,7 +463,7 @@ class BuildingShapeUtils extends ShapeUtils {
468463
* Return the angle of the longest side of a shape with 90° vertices.
469464
*
470465
* @param {THREE.Shape} shape - the shape
471-
* @return {number}
466+
* @return {number} in radians from Pi > x > -Pi
472467
*/
473468
static longestSideAngle(shape) {
474469
const lengths = BuildingShapeUtils.edgeLength(shape);

test/buildingpart.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ test('Constructor', () => {
6161
expect(part.options.roof.orientation).toBe('along');
6262

6363
// toDo: Mock BuildingShapeUtils and test options
64+
expect(BuildingShapeUtils.edgeDirection(part.shape)).toStrictEqual([1.5707963267948966, 0, -1.5707963267948966, 3.141592653589793]);
65+
expect(BuildingShapeUtils.longestSideAngle(part.shape)).toBe(1.5707963267948966);
6466
expect(part.options.roof.direction).toBe(90);
6567
expect(errors.length).toBe(0);
6668
});

test/utils.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,17 @@ const rightTriangle = new Shape();
115115
rightTriangle.moveTo(1, 1);
116116
rightTriangle.lineTo(1, -1);
117117
rightTriangle.lineTo(-1, 1);
118-
rightTriangle.lineTo(1, 1);
119118

120119
const rightTriangle2 = new Shape();
121120
rightTriangle2.moveTo(1, 1);
122121
rightTriangle2.lineTo(-1, 1);
123122
rightTriangle2.lineTo(1, -1);
124-
rightTriangle2.lineTo(1, 1);
125123

126124
const rectangle = new Shape();
127125
rectangle.moveTo(-4.332738077015795, -5.882209888874915);
128126
rectangle.lineTo(-4.332738077015795, 5.88221335051411);
129127
rectangle.lineTo(4.332747472106493, 5.88221335051411);
130128
rectangle.lineTo(4.332747472106493, -5.882209888874915);
131-
rectangle.lineTo(-4.332738077015795, -5.882209888874915);
132129

133130
test('Extents no Rotation', () => {
134131
expect(BuildingShapeUtils.extents(rightTriangle)).toStrictEqual([-1, -1, 1, 1]);

0 commit comments

Comments
 (0)