Skip to content

Commit

Permalink
fix(core): make geometry tiler split geometries according to limit
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 29, 2024
1 parent fca7863 commit ed12267
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 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.15",
"version": "2.4.0-alpha.17",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
28 changes: 19 additions & 9 deletions packages/core/src/fragments/IfcGeometryTiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,19 +502,29 @@ export class IfcGeometryTiler extends Component implements Disposable {
}

private async streamGeometries() {
let buffer = this._streamSerializer.export(this._geometries) as Uint8Array;
const exportMap: typeof this._geometries = new Map();

let data: StreamedGeometries = {};
// Split geometries to control the maximum size of fragment files
for (const [id, value] of this._geometries) {
exportMap.set(id, value);

for (const [id, { boundingBox, hasHoles }] of this._geometries) {
data[id] = { boundingBox, hasHoles };
}
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 });
await this.onGeometryStreamed.trigger({ data, buffer });

// Force memory disposal of all created items
data = null as any;
buffer = null as any;
exportMap.clear();
}
}

// Force memory disposal of all created items
data = null as any;
buffer = null as any;
this._geometries.clear();
this._geometryCount = 0;
}
Expand Down

0 comments on commit ed12267

Please sign in to comment.