Visitar URL original
feat(front): make streamer file cacher public · ThatOpen/engine_components@a523c01 · GitHub
Skip to content

Commit a523c01

Browse files
committed
feat(front): make streamer file cacher public
1 parent 2796114 commit a523c01

2 files changed

Lines changed: 13 additions & 5 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.12",
4+
"version": "2.3.0-alpha.13",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,19 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
7676
*/
7777
url: string = "";
7878

79+
/**
80+
* Function used to retrieve tiles. Can be overriden to work with specific backends.
81+
*/
7982
fetch = async (fileName: string): Promise<Response | File> => {
8083
return fetch(this.url + fileName);
8184
};
8285

86+
87+
/**
88+
* Cache system that uses the File System API.
89+
*/
90+
fileDB = new StreamerFileDb();
91+
8392
private _culler: GeometryCullerRenderer | null = null;
8493

8594
private _world: OBC.World | null = null;
@@ -89,7 +98,6 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
8998
{ data: FRAG.StreamedGeometries; time: number }
9099
>();
91100

92-
private _fileDB = new StreamerFileDb();
93101

94102
private _isDisposing = false;
95103

@@ -376,7 +384,7 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
376384
* @returns A Promise that resolves when the cache is cleared.
377385
*/
378386
async clearCache() {
379-
await this._fileDB.clear();
387+
await this.fileDB.clear();
380388
}
381389

382390
/**
@@ -497,15 +505,15 @@ export class IfcStreamer extends OBC.Component implements OBC.Disposable {
497505
if (this.useCache) {
498506
// Add or update this file to clean it up from indexedDB automatically later
499507

500-
const found = await this._fileDB.get(fileName);
508+
const found = await this.fileDB.get(fileName);
501509

502510
if (found) {
503511
bytes = found;
504512
} else {
505513
const fetched = await this.fetch(fileName);
506514
const buffer = await fetched.arrayBuffer();
507515
bytes = new Uint8Array(buffer);
508-
await this._fileDB.add(fileName, bytes);
516+
await this.fileDB.add(fileName, bytes);
509517
}
510518
} else {
511519
const fetched = await this.fetch(fileName);

0 commit comments

Comments
 (0)