From 722e8cb3518a52b47c58d563c99f1eb7eb5af627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Gonz=C3=A1lez=20Viegas?= Date: Thu, 4 Jul 2024 14:01:39 +0200 Subject: [PATCH] fix: add support for decimeters and centimeters --- packages/core/package.json | 2 +- packages/core/src/core/Components/index.ts | 2 +- packages/core/src/fragments/IfcLoader/src/units.ts | 8 +++++++- packages/core/src/ifc/Utils/properties-utils.ts | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index a87ee031b..c7659b6e9 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@thatopen/components", "description": "Collection of core functionalities to author BIM apps.", - "version": "2.0.22", + "version": "2.0.23", "author": "That Open Company", "contributors": [ "Antonio Gonzalez Viegas (https://github.com/agviegas)", diff --git a/packages/core/src/core/Components/index.ts b/packages/core/src/core/Components/index.ts index 1e7f64645..cde8cac2b 100644 --- a/packages/core/src/core/Components/index.ts +++ b/packages/core/src/core/Components/index.ts @@ -14,7 +14,7 @@ export class Components implements Disposable { /** * The version of the @thatopen/components library. */ - static readonly release = "2.0.22"; + static readonly release = "2.0.23"; /** {@link Disposable.onDisposed} */ readonly onDisposed = new Event(); diff --git a/packages/core/src/fragments/IfcLoader/src/units.ts b/packages/core/src/fragments/IfcLoader/src/units.ts index 779a18d9b..3158257bb 100644 --- a/packages/core/src/fragments/IfcLoader/src/units.ts +++ b/packages/core/src/fragments/IfcLoader/src/units.ts @@ -24,8 +24,14 @@ export class Units { } if (length.Name.value === "FOOT") { this.factor = 0.3048; - } else if (length.Prefix?.value === "MILLI") { + } + + if (length.Prefix?.value === "MILLI") { this.complement = 0.001; + } else if (length.Prefix?.value === "CENTI") { + this.complement = 0.01; + } else if (length.Prefix?.value === "DECI") { + this.complement = 0.01; } } diff --git a/packages/core/src/ifc/Utils/properties-utils.ts b/packages/core/src/ifc/Utils/properties-utils.ts index 411ce188d..ba3bdf648 100644 --- a/packages/core/src/ifc/Utils/properties-utils.ts +++ b/packages/core/src/ifc/Utils/properties-utils.ts @@ -29,8 +29,13 @@ export class IfcPropertiesUtils { if (unit.Name.value === "FOOT") { unitValue = 0.3048; } + if (unit.Prefix?.value === "MILLI") { factor = 0.001; + } else if (unit.Prefix?.value === "CENTI") { + factor = 0.01; + } else if (unit.Prefix?.value === "DECI") { + factor = 0.01; } return unitValue * factor; }