Skip to content

Commit 434996a

Browse files
authored
fix: Area Measurement units and MeasureMark visibility (#673)
* fix: remove exponentiation in unit conversion * fix(measure-mark): update label visibility status based on area rawvalue
1 parent f5b318f commit 434996a

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

packages/core/src/measurement/MeasurementUtils/index.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class MeasurementUtils extends Component {
5050
point: THREE.Vector3,
5151
lineStart: THREE.Vector3,
5252
lineEnd: THREE.Vector3,
53-
clamp = false,
53+
clamp = false
5454
) {
5555
const tempLine = new THREE.Line3();
5656
const tempPoint = new THREE.Vector3();
@@ -294,7 +294,7 @@ export class MeasurementUtils extends Component {
294294
*/
295295
async getVolumeFromFragments(modelIdMap: ModelIdMap) {
296296
console.warn(
297-
"getVolumeFromFragments is deprecated. Use getItemsVolume instead.",
297+
"getVolumeFromFragments is deprecated. Use getItemsVolume instead."
298298
);
299299
return this.getItemsVolume(modelIdMap);
300300
}
@@ -395,7 +395,7 @@ export class MeasurementUtils extends Component {
395395
value: number,
396396
fromUnit: string,
397397
toUnit: string,
398-
precision = 2,
398+
precision = 2
399399
): number {
400400
const unitFactors: Record<string, number> = {
401401
// Length
@@ -425,13 +425,6 @@ export class MeasurementUtils extends Component {
425425

426426
let factor = unitFactors[fromUnit] / unitFactors[toUnit];
427427

428-
// Adjust factor for area or volume conversions
429-
if (fromUnit.endsWith("2") && toUnit.endsWith("2")) {
430-
factor **= 2;
431-
} else if (fromUnit.endsWith("3") && toUnit.endsWith("3")) {
432-
factor **= 3;
433-
}
434-
435428
const convertedValue = value * factor;
436429
const roundingFactor = 10 ** precision;
437430
return Math.round(convertedValue * roundingFactor) / roundingFactor;

packages/front/src/utils/measure-fill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class MeasureFill {
151151

152152
update() {
153153
this.updateMesh();
154-
if (this.area.value === 0) {
154+
if (this.area.rawValue === 0) {
155155
this.label.visible = false;
156156
} else {
157157
this.label.value = this.area.rawValue;

0 commit comments

Comments
 (0)