Skip to content

Commit

Permalink
fix(core): stream remaining geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 30, 2024
1 parent ed12267 commit b61d3a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
31 changes: 17 additions & 14 deletions packages/core/src/fragments/IfcGeometryTiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b61d3a7

Please sign in to comment.