Skip to content

Commit 75ffbfa

Browse files
committed
feat(front): make streaming url more flexible
1 parent 0d16807 commit 75ffbfa

3 files changed

Lines changed: 15 additions & 20 deletions

File tree

packages/front/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components-front",
33
"description": "Collection of frontend tools to author BIM apps.",
4-
"version": "2.3.0-alpha.2",
4+
"version": "2.3.0-alpha.3",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

packages/front/src/fragments/IfcStreamer/index.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
6565
*/
6666
useCache = true;
6767

68-
fetch = async (url: string) => {
69-
return fetch(url);
68+
fetch = async (fileName: string) => {
69+
return fetch(this.url + fileName);
7070
};
7171

7272
private _culler: GeometryCullerRenderer | null = null;
@@ -216,8 +216,7 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
216216
) {
217217
const { assets, geometries, globalDataFileId } = settings;
218218

219-
const groupUrl = this.url + globalDataFileId;
220-
const groupData = await this.fetch(groupUrl);
219+
const groupData = await this.fetch(globalDataFileId);
221220
const groupArrayBuffer = await groupData.arrayBuffer();
222221
const groupBuffer = new Uint8Array(groupArrayBuffer);
223222
const fragments = this.components.get(OBC.FragmentsManager);
@@ -285,16 +284,16 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
285284
"-properties",
286285
);
287286

287+
FRAG.FragmentsGroup.url = this.url;
288+
288289
group.streamSettings = {
289-
baseUrl: this.url,
290290
baseFileName: propertiesFileID,
291291
ids,
292292
types,
293293
};
294294

295295
const { indexesFile } = properties;
296-
const indexURL = this.url + indexesFile;
297-
const fetched = await this.fetch(indexURL);
296+
const fetched = await this.fetch(indexesFile);
298297
const rels = await fetched.text();
299298
const indexer = this.components.get(OBC.IfcRelationsIndexer);
300299
indexer.setRelationMap(group, indexer.getRelationsMapFromJSON(rels));
@@ -473,40 +472,37 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
473472

474473
const sortedFiles = Array.from(files).sort((a, b) => b[1] - a[1]);
475474

476-
for (const [file] of sortedFiles) {
477-
const url = this.url + file;
478-
475+
for (const [fileName] of sortedFiles) {
479476
// If this file is still in the ram, get it
480477

481-
if (!this._ramCache.has(url)) {
478+
if (!this._ramCache.has(fileName)) {
482479
let bytes = new Uint8Array();
483480

484481
// If this file is in the local cache, get it
485482
if (this.useCache) {
486483
// Add or update this file to clean it up from indexedDB automatically later
487-
// this.dbCleaner.update(url);
488484

489-
const found = await this._fileDB.get(url);
485+
const found = await this._fileDB.get(fileName);
490486

491487
if (found) {
492488
bytes = found;
493489
} else {
494-
const fetched = await this.fetch(url);
490+
const fetched = await this.fetch(fileName);
495491
const buffer = await fetched.arrayBuffer();
496492
bytes = new Uint8Array(buffer);
497-
await this._fileDB.add(url, bytes);
493+
await this._fileDB.add(fileName, bytes);
498494
}
499495
} else {
500-
const fetched = await this.fetch(url);
496+
const fetched = await this.fetch(fileName);
501497
const buffer = await fetched.arrayBuffer();
502498
bytes = new Uint8Array(buffer);
503499
}
504500

505501
const data = this.serializer.import(bytes);
506-
this._ramCache.set(url, { data, time: performance.now() });
502+
this._ramCache.set(fileName, { data, time: performance.now() });
507503
}
508504

509-
const result = this._ramCache.get(url);
505+
const result = this._ramCache.get(fileName);
510506
if (!result) {
511507
continue;
512508
}

packages/front/src/fragments/IfcStreamer/src/streamer-file-db.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export class StreamerFileDb {
9797
}
9898

9999
for (const name of filesToDelete) {
100-
console.log(`deleted: ${name}`);
101100
rootDir.removeEntry(name);
102101
}
103102

0 commit comments

Comments
 (0)