From b61d3a7ceea2884fb842758e652cb4a7ad35b550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Gonz=C3=A1lez=20Viegas?= Date: Wed, 30 Oct 2024 11:50:44 +0100 Subject: [PATCH] fix(core): stream remaining geometries --- packages/core/package.json | 2 +- .../src/fragments/IfcGeometryTiler/index.ts | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 02ef65497..b43eced3b 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.4.0-alpha.17", + "version": "2.4.0-alpha.18", "author": "That Open Company", "contributors": [ "Antonio Gonzalez Viegas (https://github.com/agviegas)", diff --git a/packages/core/src/fragments/IfcGeometryTiler/index.ts b/packages/core/src/fragments/IfcGeometryTiler/index.ts index 6fbe4e307..5f02ff264 100644 --- a/packages/core/src/fragments/IfcGeometryTiler/index.ts +++ b/packages/core/src/fragments/IfcGeometryTiler/index.ts @@ -507,28 +507,31 @@ export class IfcGeometryTiler extends Component implements Disposable { // Split geometries to control the maximum size of fragment files for (const [id, value] of this._geometries) { exportMap.set(id, value); - if (exportMap.size > this.settings.minGeometrySize) { - let buffer = this._streamSerializer.export(exportMap) as Uint8Array; - let data: StreamedGeometries = {}; - - for (const [id, { boundingBox, hasHoles }] of exportMap) { - data[id] = { boundingBox, hasHoles }; - } - - await this.onGeometryStreamed.trigger({ data, buffer }); - - // Force memory disposal of all created items - data = null as any; - buffer = null as any; - exportMap.clear(); + await this.outputGeometries(exportMap); } } + // Output remaining geometries + await this.outputGeometries(exportMap); + this._geometries.clear(); this._geometryCount = 0; } + private async outputGeometries(exportMap: typeof this._geometries) { + let buffer = this._streamSerializer.export(exportMap) as Uint8Array; + let data: StreamedGeometries = {}; + for (const [id, { boundingBox, hasHoles }] of exportMap) { + data[id] = { boundingBox, hasHoles }; + } + await this.onGeometryStreamed.trigger({ data, buffer }); + // Force memory disposal of all created items + data = null as any; + buffer = null as any; + exportMap.clear(); + } + private registerGeometryData( group: FRAGS.FragmentsGroup, itemID: number,