From 444e81a99a9f68690abe89a3ecfc3715e39e9093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Gonz=C3=A1lez=20Viegas?= Date: Wed, 1 May 2024 22:48:49 +0200 Subject: [PATCH] fix: improve measurement face detection --- package.json | 2 +- resources/openbim-components.js | 5 +---- src/measurement/FaceMeasurement/index.ts | 1 - src/measurement/MeasurementUtils/index.ts | 5 +---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 471d2b90c..e2408e2f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openbim-components", - "version": "1.5.0", + "version": "1.5.1", "main": "src/index.js", "author": "harry collin, antonio gonzalez viegas", "license": "MIT", diff --git a/resources/openbim-components.js b/resources/openbim-components.js index 6a35a3317..042599163 100644 --- a/resources/openbim-components.js +++ b/resources/openbim-components.js @@ -117103,6 +117103,7 @@ class MeasurementUtils { ]; const plane = new THREE$1.Plane(); plane.setFromNormalAndCoplanarPoint(faceNormal, p1); + plane.constant = Math.round(plane.constant * 10) / 10; return { plane, edges }; } static getVerticesAndNormal(mesh, faceIndex, instance) { @@ -117125,9 +117126,6 @@ class MeasurementUtils { const averageNy = (n1.y + n2.y + n3.y) / 3; const averageNz = (n1.z + n2.z + n3.z) / 3; const faceNormal = new THREE$1.Vector3(averageNx, averageNy, averageNz); - if (!faceNormal.x && !faceNormal.y && !faceNormal.z) { - console.log("hey"); - } // Apply instance transformation to vertex and normal if (instance !== undefined && mesh instanceof THREE$1.InstancedMesh) { const transform = new THREE$1.Matrix4(); @@ -117355,7 +117353,6 @@ class FaceMeasurement extends Component { scene.add(this.preview); const result = MeasurementUtils.getFace(mesh, faceIndex, instance); if (result === null) { - console.log("Hey!"); return; } const area = this.regenerateHighlight(mesh, result.indices, instance); diff --git a/src/measurement/FaceMeasurement/index.ts b/src/measurement/FaceMeasurement/index.ts index 6d5db0f53..3d4174fd2 100644 --- a/src/measurement/FaceMeasurement/index.ts +++ b/src/measurement/FaceMeasurement/index.ts @@ -273,7 +273,6 @@ export class FaceMeasurement const result = MeasurementUtils.getFace(mesh, faceIndex, instance); if (result === null) { - console.log("Hey!"); return; } diff --git a/src/measurement/MeasurementUtils/index.ts b/src/measurement/MeasurementUtils/index.ts index 7a87fe46d..a3197cabf 100644 --- a/src/measurement/MeasurementUtils/index.ts +++ b/src/measurement/MeasurementUtils/index.ts @@ -229,6 +229,7 @@ export class MeasurementUtils { const plane = new THREE.Plane(); plane.setFromNormalAndCoplanarPoint(faceNormal, p1); + plane.constant = Math.round(plane.constant * 10) / 10; return { plane, edges }; } @@ -263,10 +264,6 @@ export class MeasurementUtils { const averageNz = (n1.z + n2.z + n3.z) / 3; const faceNormal = new THREE.Vector3(averageNx, averageNy, averageNz); - if (!faceNormal.x && !faceNormal.y && !faceNormal.z) { - console.log("hey"); - } - // Apply instance transformation to vertex and normal if (instance !== undefined && mesh instanceof THREE.InstancedMesh) {