@loaders.gl/3d-tiles 4.1.1 → 4.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +4 -5
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +25 -20
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
- package/dist/3d-tiles-archive-loader.js +1 -1
- package/dist/3d-tiles-archive-loader.js.map +1 -1
- package/dist/dist.dev.js +102 -119
- package/dist/index.cjs +28 -89
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/utils/version.js +1 -1
- package/dist/lib/utils/version.js.map +1 -1
- package/package.json +8 -8
- package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +30 -25
- package/src/index.ts +1 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +0 -32
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +0 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.js +0 -48
- package/dist/lib/filesystems/tiles-3d-archive-file-system.js.map +0 -1
- package/src/lib/filesystems/tiles-3d-archive-file-system.ts +0 -100
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { FileProvider } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { IndexedArchive } from '@loaders.gl/zip';
|
|
2
3
|
/**
|
|
3
4
|
* Class for handling information about 3tz file
|
|
4
5
|
*/
|
|
5
|
-
export declare class Tiles3DArchive {
|
|
6
|
-
/** FileProvider with whe whole file */
|
|
7
|
-
private fileProvider;
|
|
6
|
+
export declare class Tiles3DArchive extends IndexedArchive {
|
|
8
7
|
/** hash info */
|
|
9
|
-
private hashTable
|
|
8
|
+
private hashTable?;
|
|
10
9
|
/**
|
|
11
10
|
* creates Tiles3DArchive handler
|
|
12
11
|
* @param fileProvider - FileProvider with the whole file
|
|
13
12
|
* @param hashTable - hash info
|
|
14
13
|
*/
|
|
15
|
-
constructor(fileProvider: FileProvider, hashTable
|
|
14
|
+
constructor(fileProvider: FileProvider, hashTable?: Record<string, bigint>, fileName?: string);
|
|
16
15
|
/**
|
|
17
16
|
* Returns file with the given path from 3tz archive
|
|
18
17
|
* @param path - path inside the 3tz
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-archive-archive.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-archive/3d-tiles-archive-archive.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-archive.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-archive/3d-tiles-archive-archive.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAGtD,OAAO,EAAC,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AAcxE;;GAEG;AACH,qBAAa,cAAe,SAAQ,cAAc;IAChD,gBAAgB;IAChB,OAAO,CAAC,SAAS,CAAC,CAAyB;IAE3C;;;;OAIG;gBACS,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM;IAK7F;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAcjD;;;;OAIG;YACW,YAAY;CAgC3B"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { MD5Hash } from '@loaders.gl/crypto';
|
|
2
2
|
import { DeflateCompression, NoCompression } from '@loaders.gl/compression';
|
|
3
|
-
import { parseZipLocalFileHeader } from '@loaders.gl/zip';
|
|
3
|
+
import { IndexedArchive, parseZipLocalFileHeader } from '@loaders.gl/zip';
|
|
4
4
|
const COMPRESSION_METHODS = {
|
|
5
5
|
0: data => new NoCompression().decompress(data),
|
|
6
6
|
8: data => new DeflateCompression({
|
|
7
7
|
raw: true
|
|
8
8
|
}).decompress(data)
|
|
9
9
|
};
|
|
10
|
-
export class Tiles3DArchive {
|
|
11
|
-
constructor(fileProvider, hashTable) {
|
|
12
|
-
|
|
10
|
+
export class Tiles3DArchive extends IndexedArchive {
|
|
11
|
+
constructor(fileProvider, hashTable, fileName) {
|
|
12
|
+
super(fileProvider, hashTable, fileName);
|
|
13
13
|
this.hashTable = void 0;
|
|
14
|
-
this.fileProvider = fileProvider;
|
|
15
14
|
this.hashTable = hashTable;
|
|
16
15
|
}
|
|
17
16
|
async getFile(path) {
|
|
@@ -25,22 +24,28 @@ export class Tiles3DArchive {
|
|
|
25
24
|
return data;
|
|
26
25
|
}
|
|
27
26
|
async getFileBytes(path) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
let uncompressedFile;
|
|
28
|
+
if (this.hashTable) {
|
|
29
|
+
const arrayBuffer = new TextEncoder().encode(path).buffer;
|
|
30
|
+
const nameHash = await new MD5Hash().hash(arrayBuffer, 'hex');
|
|
31
|
+
const byteOffset = this.hashTable[nameHash];
|
|
32
|
+
if (byteOffset === undefined) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);
|
|
36
|
+
if (!localFileHeader) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
40
|
+
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
41
|
+
if (!compressionMethod) {
|
|
42
|
+
throw Error('Only Deflation compression is supported');
|
|
43
|
+
}
|
|
44
|
+
uncompressedFile = await compressionMethod(compressedFile);
|
|
45
|
+
} else {
|
|
46
|
+
uncompressedFile = await this.getFileWithoutHash(path);
|
|
33
47
|
}
|
|
34
|
-
|
|
35
|
-
if (!localFileHeader) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
39
|
-
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
40
|
-
if (!compressionMethod) {
|
|
41
|
-
throw Error('Only Deflation compression is supported');
|
|
42
|
-
}
|
|
43
|
-
return compressionMethod(compressedFile);
|
|
48
|
+
return uncompressedFile;
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
//# sourceMappingURL=3d-tiles-archive-archive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-archive-archive.js","names":["MD5Hash","DeflateCompression","NoCompression","parseZipLocalFileHeader","COMPRESSION_METHODS","data","decompress","raw","Tiles3DArchive","constructor","fileProvider","hashTable","getFile","path","getFileBytes","toLocaleLowerCase","Error","arrayBuffer","TextEncoder","encode","buffer","nameHash","hash","byteOffset","undefined","localFileHeader","compressedFile","slice","fileDataOffset","compressedSize","compressionMethod"],"sources":["../../src/3d-tiles-archive/3d-tiles-archive-archive.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\nimport {FileProvider} from '@loaders.gl/loader-utils';\nimport {MD5Hash} from '@loaders.gl/crypto';\nimport {DeflateCompression, NoCompression} from '@loaders.gl/compression';\nimport {parseZipLocalFileHeader} from '@loaders.gl/zip';\n\ntype CompressionHandler = (compressedFile: ArrayBuffer) => Promise<ArrayBuffer>;\n\n/**\n * Handling different compression types in zip\n */\nconst COMPRESSION_METHODS: {[key: number]: CompressionHandler} = {\n /** No compression */\n 0: (data) => new NoCompression().decompress(data),\n /** Deflation */\n 8: (data) => new DeflateCompression({raw: true}).decompress(data)\n};\n\n/**\n * Class for handling information about 3tz file\n */\nexport class Tiles3DArchive {\n /**
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-archive.js","names":["MD5Hash","DeflateCompression","NoCompression","IndexedArchive","parseZipLocalFileHeader","COMPRESSION_METHODS","data","decompress","raw","Tiles3DArchive","constructor","fileProvider","hashTable","fileName","getFile","path","getFileBytes","toLocaleLowerCase","Error","uncompressedFile","arrayBuffer","TextEncoder","encode","buffer","nameHash","hash","byteOffset","undefined","localFileHeader","compressedFile","slice","fileDataOffset","compressedSize","compressionMethod","getFileWithoutHash"],"sources":["../../src/3d-tiles-archive/3d-tiles-archive-archive.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\nimport {FileProvider} from '@loaders.gl/loader-utils';\nimport {MD5Hash} from '@loaders.gl/crypto';\nimport {DeflateCompression, NoCompression} from '@loaders.gl/compression';\nimport {IndexedArchive, parseZipLocalFileHeader} from '@loaders.gl/zip';\n\ntype CompressionHandler = (compressedFile: ArrayBuffer) => Promise<ArrayBuffer>;\n\n/**\n * Handling different compression types in zip\n */\nconst COMPRESSION_METHODS: {[key: number]: CompressionHandler} = {\n /** No compression */\n 0: (data) => new NoCompression().decompress(data),\n /** Deflation */\n 8: (data) => new DeflateCompression({raw: true}).decompress(data)\n};\n\n/**\n * Class for handling information about 3tz file\n */\nexport class Tiles3DArchive extends IndexedArchive {\n /** hash info */\n private hashTable?: Record<string, bigint>;\n\n /**\n * creates Tiles3DArchive handler\n * @param fileProvider - FileProvider with the whole file\n * @param hashTable - hash info\n */\n constructor(fileProvider: FileProvider, hashTable?: Record<string, bigint>, fileName?: string) {\n super(fileProvider, hashTable, fileName);\n this.hashTable = hashTable;\n }\n\n /**\n * Returns file with the given path from 3tz archive\n * @param path - path inside the 3tz\n * @returns buffer with ready to use file\n */\n async getFile(path: string): Promise<ArrayBuffer> {\n // sometimes paths are not in lower case when hash file is created,\n // so first we're looking for lower case file name and then for original one\n let data = await this.getFileBytes(path.toLocaleLowerCase());\n if (!data) {\n data = await this.getFileBytes(path);\n }\n if (!data) {\n throw new Error(`No such file in the archive: ${path}`);\n }\n\n return data;\n }\n\n /**\n * Trying to get raw file data by adress\n * @param path - path inside the archive\n * @returns buffer with the raw file data\n */\n private async getFileBytes(path: string): Promise<ArrayBuffer | null> {\n let uncompressedFile: ArrayBuffer;\n if (this.hashTable) {\n const arrayBuffer = new TextEncoder().encode(path).buffer;\n const nameHash = await new MD5Hash().hash(arrayBuffer, 'hex');\n const byteOffset = this.hashTable[nameHash];\n if (byteOffset === undefined) {\n return null;\n }\n\n const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);\n if (!localFileHeader) {\n return null;\n }\n\n const compressedFile = await this.fileProvider.slice(\n localFileHeader.fileDataOffset,\n localFileHeader.fileDataOffset + localFileHeader.compressedSize\n );\n\n const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];\n if (!compressionMethod) {\n throw Error('Only Deflation compression is supported');\n }\n\n uncompressedFile = await compressionMethod(compressedFile);\n } else {\n uncompressedFile = await this.getFileWithoutHash(path);\n }\n\n return uncompressedFile;\n }\n}\n"],"mappings":"AAKA,SAAQA,OAAO,QAAO,oBAAoB;AAC1C,SAAQC,kBAAkB,EAAEC,aAAa,QAAO,yBAAyB;AACzE,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,iBAAiB;AAOvE,MAAMC,mBAAwD,GAAG;EAE/D,CAAC,EAAGC,IAAI,IAAK,IAAIJ,aAAa,CAAC,CAAC,CAACK,UAAU,CAACD,IAAI,CAAC;EAEjD,CAAC,EAAGA,IAAI,IAAK,IAAIL,kBAAkB,CAAC;IAACO,GAAG,EAAE;EAAI,CAAC,CAAC,CAACD,UAAU,CAACD,IAAI;AAClE,CAAC;AAKD,OAAO,MAAMG,cAAc,SAASN,cAAc,CAAC;EASjDO,WAAWA,CAACC,YAA0B,EAAEC,SAAkC,EAAEC,QAAiB,EAAE;IAC7F,KAAK,CAACF,YAAY,EAAEC,SAAS,EAAEC,QAAQ,CAAC;IAAC,KARnCD,SAAS;IASf,IAAI,CAACA,SAAS,GAAGA,SAAS;EAC5B;EAOA,MAAME,OAAOA,CAACC,IAAY,EAAwB;IAGhD,IAAIT,IAAI,GAAG,MAAM,IAAI,CAACU,YAAY,CAACD,IAAI,CAACE,iBAAiB,CAAC,CAAC,CAAC;IAC5D,IAAI,CAACX,IAAI,EAAE;MACTA,IAAI,GAAG,MAAM,IAAI,CAACU,YAAY,CAACD,IAAI,CAAC;IACtC;IACA,IAAI,CAACT,IAAI,EAAE;MACT,MAAM,IAAIY,KAAK,CAAE,gCAA+BH,IAAK,EAAC,CAAC;IACzD;IAEA,OAAOT,IAAI;EACb;EAOA,MAAcU,YAAYA,CAACD,IAAY,EAA+B;IACpE,IAAII,gBAA6B;IACjC,IAAI,IAAI,CAACP,SAAS,EAAE;MAClB,MAAMQ,WAAW,GAAG,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACP,IAAI,CAAC,CAACQ,MAAM;MACzD,MAAMC,QAAQ,GAAG,MAAM,IAAIxB,OAAO,CAAC,CAAC,CAACyB,IAAI,CAACL,WAAW,EAAE,KAAK,CAAC;MAC7D,MAAMM,UAAU,GAAG,IAAI,CAACd,SAAS,CAACY,QAAQ,CAAC;MAC3C,IAAIE,UAAU,KAAKC,SAAS,EAAE;QAC5B,OAAO,IAAI;MACb;MAEA,MAAMC,eAAe,GAAG,MAAMxB,uBAAuB,CAACsB,UAAU,EAAE,IAAI,CAACf,YAAY,CAAC;MACpF,IAAI,CAACiB,eAAe,EAAE;QACpB,OAAO,IAAI;MACb;MAEA,MAAMC,cAAc,GAAG,MAAM,IAAI,CAAClB,YAAY,CAACmB,KAAK,CAClDF,eAAe,CAACG,cAAc,EAC9BH,eAAe,CAACG,cAAc,GAAGH,eAAe,CAACI,cACnD,CAAC;MAED,MAAMC,iBAAiB,GAAG5B,mBAAmB,CAACuB,eAAe,CAACK,iBAAiB,CAAC;MAChF,IAAI,CAACA,iBAAiB,EAAE;QACtB,MAAMf,KAAK,CAAC,yCAAyC,CAAC;MACxD;MAEAC,gBAAgB,GAAG,MAAMc,iBAAiB,CAACJ,cAAc,CAAC;IAC5D,CAAC,MAAM;MACLV,gBAAgB,GAAG,MAAM,IAAI,CAACe,kBAAkB,CAACnB,IAAI,CAAC;IACxD;IAEA,OAAOI,gBAAgB;EACzB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataViewFile } from '@loaders.gl/loader-utils';
|
|
2
2
|
import { parse3DTilesArchive as parse3DTilesArchiveFromProvider } from "./3d-tiles-archive/3d-tiles-archive-parser.js";
|
|
3
|
-
const VERSION = typeof "4.
|
|
3
|
+
const VERSION = typeof "4.2.0-alpha.2" !== 'undefined' ? "4.2.0-alpha.2" : 'latest';
|
|
4
4
|
export const Tiles3DArchiveFileLoader = {
|
|
5
5
|
name: '3tz',
|
|
6
6
|
id: '3tz',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-archive-loader.js","names":["DataViewFile","parse3DTilesArchive","parse3DTilesArchiveFromProvider","VERSION","Tiles3DArchiveFileLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","_options$3dTilesArc","_options$3dTilesArc2","arguments","length","undefined","archive","DataView","getFile","path"],"sources":["../src/3d-tiles-archive-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\nimport type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {DataViewFile} from '@loaders.gl/loader-utils';\nimport {parse3DTilesArchive as parse3DTilesArchiveFromProvider} from './3d-tiles-archive/3d-tiles-archive-parser';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** options to load data from 3tz */\nexport type Tiles3DArchiveFileLoaderOptions = LoaderOptions & {\n '3d-tiles-archive'?: {\n /** path inside the 3tz archive */\n path?: string;\n };\n};\n\n/**\n * Loader for 3tz packages\n */\nexport const Tiles3DArchiveFileLoader: LoaderWithParser<\n ArrayBuffer,\n never,\n Tiles3DArchiveFileLoaderOptions\n> = {\n name: '3tz',\n id: '3tz',\n module: '3d-tiles',\n version: VERSION,\n mimeTypes: ['application/octet-stream', 'application/vnd.maxar.archive.3tz+zip'],\n parse: parse3DTilesArchive,\n extensions: ['3tz'],\n options: {}\n};\n\n/**\n * returns a single file from the 3tz archive\n * @param data 3tz archive data\n * @param options options\n * @returns requested file\n */\nasync function parse3DTilesArchive(\n data: ArrayBuffer,\n options: Tiles3DArchiveFileLoaderOptions = {}\n): Promise<ArrayBuffer> {\n const archive = await parse3DTilesArchiveFromProvider(new DataViewFile(new DataView(data)));\n return archive.getFile(options['3d-tiles-archive']?.path ?? '');\n}\n"],"mappings":"AAKA,SAAQA,YAAY,QAAO,0BAA0B;AAAC,SAC9CC,mBAAmB,IAAIC,+BAA+B;AAI9D,MAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-loader.js","names":["DataViewFile","parse3DTilesArchive","parse3DTilesArchiveFromProvider","VERSION","Tiles3DArchiveFileLoader","name","id","module","version","mimeTypes","parse","extensions","options","data","_options$3dTilesArc","_options$3dTilesArc2","arguments","length","undefined","archive","DataView","getFile","path"],"sources":["../src/3d-tiles-archive-loader.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\nimport type {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {DataViewFile} from '@loaders.gl/loader-utils';\nimport {parse3DTilesArchive as parse3DTilesArchiveFromProvider} from './3d-tiles-archive/3d-tiles-archive-parser';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/** options to load data from 3tz */\nexport type Tiles3DArchiveFileLoaderOptions = LoaderOptions & {\n '3d-tiles-archive'?: {\n /** path inside the 3tz archive */\n path?: string;\n };\n};\n\n/**\n * Loader for 3tz packages\n */\nexport const Tiles3DArchiveFileLoader: LoaderWithParser<\n ArrayBuffer,\n never,\n Tiles3DArchiveFileLoaderOptions\n> = {\n name: '3tz',\n id: '3tz',\n module: '3d-tiles',\n version: VERSION,\n mimeTypes: ['application/octet-stream', 'application/vnd.maxar.archive.3tz+zip'],\n parse: parse3DTilesArchive,\n extensions: ['3tz'],\n options: {}\n};\n\n/**\n * returns a single file from the 3tz archive\n * @param data 3tz archive data\n * @param options options\n * @returns requested file\n */\nasync function parse3DTilesArchive(\n data: ArrayBuffer,\n options: Tiles3DArchiveFileLoaderOptions = {}\n): Promise<ArrayBuffer> {\n const archive = await parse3DTilesArchiveFromProvider(new DataViewFile(new DataView(data)));\n return archive.getFile(options['3d-tiles-archive']?.path ?? '');\n}\n"],"mappings":"AAKA,SAAQA,YAAY,QAAO,0BAA0B;AAAC,SAC9CC,mBAAmB,IAAIC,+BAA+B;AAI9D,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAa3E,OAAO,MAAMC,wBAIZ,GAAG;EACFC,IAAI,EAAE,KAAK;EACXC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,UAAU;EAClBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,EAAE,uCAAuC,CAAC;EAChFC,KAAK,EAAET,mBAAmB;EAC1BU,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,OAAO,EAAE,CAAC;AACZ,CAAC;AAQD,eAAeX,mBAAmBA,CAChCY,IAAiB,EAEK;EAAA,IAAAC,mBAAA,EAAAC,oBAAA;EAAA,IADtBH,OAAwC,GAAAI,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE7C,MAAMG,OAAO,GAAG,MAAMjB,+BAA+B,CAAC,IAAIF,YAAY,CAAC,IAAIoB,QAAQ,CAACP,IAAI,CAAC,CAAC,CAAC;EAC3F,OAAOM,OAAO,CAACE,OAAO,EAAAP,mBAAA,IAAAC,oBAAA,GAACH,OAAO,CAAC,kBAAkB,CAAC,cAAAG,oBAAA,uBAA3BA,oBAAA,CAA6BO,IAAI,cAAAR,mBAAA,cAAAA,mBAAA,GAAI,EAAE,CAAC;AACjE"}
|
package/dist/dist.dev.js
CHANGED
|
@@ -4268,8 +4268,8 @@ var __exports__ = (() => {
|
|
|
4268
4268
|
Tile3DFeatureTable: () => Tile3DFeatureTable,
|
|
4269
4269
|
Tile3DSubtreeLoader: () => Tile3DSubtreeLoader,
|
|
4270
4270
|
Tile3DWriter: () => Tile3DWriter,
|
|
4271
|
+
Tiles3DArchive: () => Tiles3DArchive,
|
|
4271
4272
|
Tiles3DArchiveFileLoader: () => Tiles3DArchiveFileLoader,
|
|
4272
|
-
Tiles3DArchiveFileSystem: () => Tiles3DArchiveFileSystem,
|
|
4273
4273
|
Tiles3DLoader: () => Tiles3DLoader,
|
|
4274
4274
|
_getIonTilesetMetadata: () => getIonTilesetMetadata
|
|
4275
4275
|
});
|
|
@@ -4309,7 +4309,7 @@ var __exports__ = (() => {
|
|
|
4309
4309
|
console.warn("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
4310
4310
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
4311
4311
|
} else {
|
|
4312
|
-
globalThis._loadersgl_.version = "4.
|
|
4312
|
+
globalThis._loadersgl_.version = "4.2.0-alpha.2";
|
|
4313
4313
|
}
|
|
4314
4314
|
}
|
|
4315
4315
|
return globalThis._loadersgl_.version;
|
|
@@ -10086,7 +10086,7 @@ var __exports__ = (() => {
|
|
|
10086
10086
|
}({});
|
|
10087
10087
|
|
|
10088
10088
|
// src/lib/utils/version.ts
|
|
10089
|
-
var VERSION2 = true ? "4.
|
|
10089
|
+
var VERSION2 = true ? "4.2.0-alpha.2" : "latest";
|
|
10090
10090
|
|
|
10091
10091
|
// src/lib/constants.ts
|
|
10092
10092
|
var TILE3D_TYPE = {
|
|
@@ -10120,7 +10120,7 @@ var __exports__ = (() => {
|
|
|
10120
10120
|
}
|
|
10121
10121
|
|
|
10122
10122
|
// ../draco/src/lib/utils/version.ts
|
|
10123
|
-
var VERSION3 = true ? "4.
|
|
10123
|
+
var VERSION3 = true ? "4.2.0-alpha.2" : "latest";
|
|
10124
10124
|
|
|
10125
10125
|
// ../draco/src/draco-loader.ts
|
|
10126
10126
|
var DracoLoader = {
|
|
@@ -11822,7 +11822,7 @@ var __exports__ = (() => {
|
|
|
11822
11822
|
});
|
|
11823
11823
|
|
|
11824
11824
|
// ../images/src/lib/utils/version.ts
|
|
11825
|
-
var VERSION4 = true ? "4.
|
|
11825
|
+
var VERSION4 = true ? "4.2.0-alpha.2" : "latest";
|
|
11826
11826
|
|
|
11827
11827
|
// ../images/src/lib/category-api/image-type.ts
|
|
11828
11828
|
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
@@ -13531,10 +13531,10 @@ var __exports__ = (() => {
|
|
|
13531
13531
|
}
|
|
13532
13532
|
|
|
13533
13533
|
// ../gltf/src/lib/utils/version.ts
|
|
13534
|
-
var VERSION5 = true ? "4.
|
|
13534
|
+
var VERSION5 = true ? "4.2.0-alpha.2" : "latest";
|
|
13535
13535
|
|
|
13536
13536
|
// ../textures/src/lib/utils/version.ts
|
|
13537
|
-
var VERSION6 = true ? "4.
|
|
13537
|
+
var VERSION6 = true ? "4.2.0-alpha.2" : "latest";
|
|
13538
13538
|
|
|
13539
13539
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
13540
13540
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -19190,37 +19190,6 @@ var __exports__ = (() => {
|
|
|
19190
19190
|
}
|
|
19191
19191
|
};
|
|
19192
19192
|
|
|
19193
|
-
// ../zip/src/hash-file-utility.ts
|
|
19194
|
-
function parseHashTable(arrayBuffer) {
|
|
19195
|
-
const dataView = new DataView(arrayBuffer);
|
|
19196
|
-
const hashMap = {};
|
|
19197
|
-
for (let i2 = 0; i2 < arrayBuffer.byteLength; i2 = i2 + 24) {
|
|
19198
|
-
const offset = dataView.getBigUint64(i2 + 16, true);
|
|
19199
|
-
const hash = bufferToHex(arrayBuffer, i2, 16);
|
|
19200
|
-
hashMap[hash] = offset;
|
|
19201
|
-
}
|
|
19202
|
-
return hashMap;
|
|
19203
|
-
}
|
|
19204
|
-
function bufferToHex(buffer, start, length4) {
|
|
19205
|
-
return [...new Uint8Array(buffer, start, length4)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
19206
|
-
}
|
|
19207
|
-
async function makeHashTableFromZipHeaders(fileProvider) {
|
|
19208
|
-
const zipCDIterator = makeZipCDHeaderIterator(fileProvider);
|
|
19209
|
-
return getHashTable(zipCDIterator);
|
|
19210
|
-
}
|
|
19211
|
-
async function getHashTable(zipCDIterator) {
|
|
19212
|
-
const md5Hash = new MD5Hash();
|
|
19213
|
-
const textEncoder = new TextEncoder();
|
|
19214
|
-
const hashTable = {};
|
|
19215
|
-
for await (const cdHeader of zipCDIterator) {
|
|
19216
|
-
const filename2 = cdHeader.fileName.split("\\").join("/").toLocaleLowerCase();
|
|
19217
|
-
const arrayBuffer = textEncoder.encode(filename2).buffer;
|
|
19218
|
-
const md5 = await md5Hash.hash(arrayBuffer, "hex");
|
|
19219
|
-
hashTable[md5] = cdHeader.localHeaderOffset;
|
|
19220
|
-
}
|
|
19221
|
-
return hashTable;
|
|
19222
|
-
}
|
|
19223
|
-
|
|
19224
19193
|
// ../compression/src/lib/compression.ts
|
|
19225
19194
|
var Compression = class {
|
|
19226
19195
|
constructor(options) {
|
|
@@ -19393,7 +19362,7 @@ var __exports__ = (() => {
|
|
|
19393
19362
|
};
|
|
19394
19363
|
|
|
19395
19364
|
// ../zip/src/filesystems/zip-filesystem.ts
|
|
19396
|
-
var
|
|
19365
|
+
var ZIP_COMPRESSION_HANDLERS = {
|
|
19397
19366
|
0: async (compressedFile) => compressedFile,
|
|
19398
19367
|
8: async (compressedFile) => {
|
|
19399
19368
|
const compression = new DeflateCompression({
|
|
@@ -19405,6 +19374,7 @@ var __exports__ = (() => {
|
|
|
19405
19374
|
};
|
|
19406
19375
|
var ZipFileSystem = class {
|
|
19407
19376
|
fileProvider = null;
|
|
19377
|
+
archive = null;
|
|
19408
19378
|
constructor(file) {
|
|
19409
19379
|
if (typeof file === "string") {
|
|
19410
19380
|
this.fileName = file;
|
|
@@ -19413,6 +19383,10 @@ var __exports__ = (() => {
|
|
|
19413
19383
|
} else {
|
|
19414
19384
|
throw new Error("Cannot open file for random access in a WEB browser");
|
|
19415
19385
|
}
|
|
19386
|
+
} else if (file instanceof IndexedArchive) {
|
|
19387
|
+
this.fileProvider = file.fileProvider;
|
|
19388
|
+
this.archive = file;
|
|
19389
|
+
this.fileName = file.fileName;
|
|
19416
19390
|
} else if (isFileProvider(file)) {
|
|
19417
19391
|
this.fileProvider = file;
|
|
19418
19392
|
}
|
|
@@ -19441,23 +19415,28 @@ var __exports__ = (() => {
|
|
|
19441
19415
|
};
|
|
19442
19416
|
}
|
|
19443
19417
|
async fetch(filename2) {
|
|
19444
|
-
|
|
19445
|
-
|
|
19446
|
-
|
|
19447
|
-
|
|
19448
|
-
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
|
|
19453
|
-
|
|
19454
|
-
|
|
19418
|
+
let uncompressedFile;
|
|
19419
|
+
if (this.archive) {
|
|
19420
|
+
uncompressedFile = await this.archive.getFile(filename2, "http");
|
|
19421
|
+
} else {
|
|
19422
|
+
if (!this.fileProvider) {
|
|
19423
|
+
throw new Error("No data detected in the zip archive");
|
|
19424
|
+
}
|
|
19425
|
+
const cdFileHeader = await this.getCDFileHeader(filename2);
|
|
19426
|
+
const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, this.fileProvider);
|
|
19427
|
+
if (!localFileHeader) {
|
|
19428
|
+
throw new Error("Local file header has not been found in the zip archive`");
|
|
19429
|
+
}
|
|
19430
|
+
const compressionHandler = ZIP_COMPRESSION_HANDLERS[localFileHeader.compressionMethod.toString()];
|
|
19431
|
+
if (!compressionHandler) {
|
|
19432
|
+
throw Error("Only Deflation compression is supported");
|
|
19433
|
+
}
|
|
19434
|
+
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
19435
|
+
uncompressedFile = await compressionHandler(compressedFile);
|
|
19455
19436
|
}
|
|
19456
|
-
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
19457
|
-
const uncompressedFile = await compressionHandler(compressedFile);
|
|
19458
19437
|
const response = new Response(uncompressedFile);
|
|
19459
19438
|
Object.defineProperty(response, "url", {
|
|
19460
|
-
value: `${this.fileName || ""}/${filename2}`
|
|
19439
|
+
value: filename2 ? `${this.fileName || ""}/${filename2}` : this.fileName || ""
|
|
19461
19440
|
});
|
|
19462
19441
|
return response;
|
|
19463
19442
|
}
|
|
@@ -19480,16 +19459,60 @@ var __exports__ = (() => {
|
|
|
19480
19459
|
}
|
|
19481
19460
|
};
|
|
19482
19461
|
|
|
19462
|
+
// ../zip/src/filesystems/IndexedArchive.ts
|
|
19463
|
+
var IndexedArchive = class {
|
|
19464
|
+
constructor(fileProvider, hashTable, fileName) {
|
|
19465
|
+
this.fileProvider = fileProvider;
|
|
19466
|
+
this.fileName = fileName;
|
|
19467
|
+
}
|
|
19468
|
+
async getFileWithoutHash(filename2) {
|
|
19469
|
+
const zipFS = new ZipFileSystem(this.fileProvider);
|
|
19470
|
+
const response = await zipFS.fetch(filename2);
|
|
19471
|
+
return await response.arrayBuffer();
|
|
19472
|
+
}
|
|
19473
|
+
};
|
|
19474
|
+
|
|
19475
|
+
// ../zip/src/hash-file-utility.ts
|
|
19476
|
+
function parseHashTable(arrayBuffer) {
|
|
19477
|
+
const dataView = new DataView(arrayBuffer);
|
|
19478
|
+
const hashMap = {};
|
|
19479
|
+
for (let i2 = 0; i2 < arrayBuffer.byteLength; i2 = i2 + 24) {
|
|
19480
|
+
const offset = dataView.getBigUint64(i2 + 16, true);
|
|
19481
|
+
const hash = bufferToHex(arrayBuffer, i2, 16);
|
|
19482
|
+
hashMap[hash] = offset;
|
|
19483
|
+
}
|
|
19484
|
+
return hashMap;
|
|
19485
|
+
}
|
|
19486
|
+
function bufferToHex(buffer, start, length4) {
|
|
19487
|
+
return [...new Uint8Array(buffer, start, length4)].map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
19488
|
+
}
|
|
19489
|
+
async function makeHashTableFromZipHeaders(fileProvider) {
|
|
19490
|
+
const zipCDIterator = makeZipCDHeaderIterator(fileProvider);
|
|
19491
|
+
return getHashTable(zipCDIterator);
|
|
19492
|
+
}
|
|
19493
|
+
async function getHashTable(zipCDIterator) {
|
|
19494
|
+
const md5Hash = new MD5Hash();
|
|
19495
|
+
const textEncoder = new TextEncoder();
|
|
19496
|
+
const hashTable = {};
|
|
19497
|
+
for await (const cdHeader of zipCDIterator) {
|
|
19498
|
+
const filename2 = cdHeader.fileName.split("\\").join("/").toLocaleLowerCase();
|
|
19499
|
+
const arrayBuffer = textEncoder.encode(filename2).buffer;
|
|
19500
|
+
const md5 = await md5Hash.hash(arrayBuffer, "hex");
|
|
19501
|
+
hashTable[md5] = cdHeader.localHeaderOffset;
|
|
19502
|
+
}
|
|
19503
|
+
return hashTable;
|
|
19504
|
+
}
|
|
19505
|
+
|
|
19483
19506
|
// src/3d-tiles-archive/3d-tiles-archive-archive.ts
|
|
19484
|
-
var
|
|
19507
|
+
var COMPRESSION_METHODS = {
|
|
19485
19508
|
0: (data) => new NoCompression().decompress(data),
|
|
19486
19509
|
8: (data) => new DeflateCompression({
|
|
19487
19510
|
raw: true
|
|
19488
19511
|
}).decompress(data)
|
|
19489
19512
|
};
|
|
19490
|
-
var Tiles3DArchive = class {
|
|
19491
|
-
constructor(fileProvider, hashTable) {
|
|
19492
|
-
|
|
19513
|
+
var Tiles3DArchive = class extends IndexedArchive {
|
|
19514
|
+
constructor(fileProvider, hashTable, fileName) {
|
|
19515
|
+
super(fileProvider, hashTable, fileName);
|
|
19493
19516
|
this.hashTable = hashTable;
|
|
19494
19517
|
}
|
|
19495
19518
|
async getFile(path) {
|
|
@@ -19503,22 +19526,28 @@ var __exports__ = (() => {
|
|
|
19503
19526
|
return data;
|
|
19504
19527
|
}
|
|
19505
19528
|
async getFileBytes(path) {
|
|
19506
|
-
|
|
19507
|
-
|
|
19508
|
-
|
|
19509
|
-
|
|
19510
|
-
|
|
19511
|
-
|
|
19512
|
-
|
|
19513
|
-
|
|
19514
|
-
|
|
19515
|
-
|
|
19516
|
-
|
|
19517
|
-
|
|
19518
|
-
|
|
19519
|
-
|
|
19529
|
+
let uncompressedFile;
|
|
19530
|
+
if (this.hashTable) {
|
|
19531
|
+
const arrayBuffer = new TextEncoder().encode(path).buffer;
|
|
19532
|
+
const nameHash = await new MD5Hash().hash(arrayBuffer, "hex");
|
|
19533
|
+
const byteOffset = this.hashTable[nameHash];
|
|
19534
|
+
if (byteOffset === void 0) {
|
|
19535
|
+
return null;
|
|
19536
|
+
}
|
|
19537
|
+
const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);
|
|
19538
|
+
if (!localFileHeader) {
|
|
19539
|
+
return null;
|
|
19540
|
+
}
|
|
19541
|
+
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
19542
|
+
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
19543
|
+
if (!compressionMethod) {
|
|
19544
|
+
throw Error("Only Deflation compression is supported");
|
|
19545
|
+
}
|
|
19546
|
+
uncompressedFile = await compressionMethod(compressedFile);
|
|
19547
|
+
} else {
|
|
19548
|
+
uncompressedFile = await this.getFileWithoutHash(path);
|
|
19520
19549
|
}
|
|
19521
|
-
return
|
|
19550
|
+
return uncompressedFile;
|
|
19522
19551
|
}
|
|
19523
19552
|
};
|
|
19524
19553
|
|
|
@@ -19543,7 +19572,7 @@ var __exports__ = (() => {
|
|
|
19543
19572
|
};
|
|
19544
19573
|
|
|
19545
19574
|
// src/3d-tiles-archive-loader.ts
|
|
19546
|
-
var VERSION8 = true ? "4.
|
|
19575
|
+
var VERSION8 = true ? "4.2.0-alpha.2" : "latest";
|
|
19547
19576
|
var Tiles3DArchiveFileLoader = {
|
|
19548
19577
|
name: "3tz",
|
|
19549
19578
|
id: "3tz",
|
|
@@ -19559,52 +19588,6 @@ var __exports__ = (() => {
|
|
|
19559
19588
|
return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
|
|
19560
19589
|
}
|
|
19561
19590
|
|
|
19562
|
-
// src/lib/filesystems/tiles-3d-archive-file-system.ts
|
|
19563
|
-
var Tiles3DArchiveFileSystem = class extends ZipFileSystem {
|
|
19564
|
-
constructor(file) {
|
|
19565
|
-
super(file);
|
|
19566
|
-
}
|
|
19567
|
-
async fetch(filename2) {
|
|
19568
|
-
const fileProvider = this.fileProvider;
|
|
19569
|
-
if (!fileProvider) {
|
|
19570
|
-
throw new Error("No data detected in the zip archive");
|
|
19571
|
-
}
|
|
19572
|
-
await this.parseHashTable();
|
|
19573
|
-
if (this.hashTable) {
|
|
19574
|
-
const archive = new Tiles3DArchive(fileProvider, this.hashTable);
|
|
19575
|
-
const fileData = await archive.getFile(filename2);
|
|
19576
|
-
const response = new Response(fileData);
|
|
19577
|
-
Object.defineProperty(response, "url", {
|
|
19578
|
-
value: `${this.fileName || ""}/${filename2}`
|
|
19579
|
-
});
|
|
19580
|
-
return response;
|
|
19581
|
-
}
|
|
19582
|
-
return super.fetch(filename2);
|
|
19583
|
-
}
|
|
19584
|
-
async parseHashTable() {
|
|
19585
|
-
if (this.hashTable !== void 0) {
|
|
19586
|
-
return;
|
|
19587
|
-
}
|
|
19588
|
-
const fileProvider = this.fileProvider;
|
|
19589
|
-
if (!fileProvider) {
|
|
19590
|
-
throw new Error("No data detected in the zip archive");
|
|
19591
|
-
}
|
|
19592
|
-
const hashCDOffset = await searchFromTheEnd(fileProvider, signature);
|
|
19593
|
-
const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
|
|
19594
|
-
if (cdFileHeader?.fileName === "@3dtilesIndex1@") {
|
|
19595
|
-
const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
|
|
19596
|
-
if (!localFileHeader) {
|
|
19597
|
-
throw new Error("corrupted 3tz");
|
|
19598
|
-
}
|
|
19599
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
19600
|
-
const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
19601
|
-
this.hashTable = parseHashTable(hashFile);
|
|
19602
|
-
} else {
|
|
19603
|
-
this.hashTable = null;
|
|
19604
|
-
}
|
|
19605
|
-
}
|
|
19606
|
-
};
|
|
19607
|
-
|
|
19608
19591
|
// src/lib/encoders/helpers/encode-3d-tile-header.ts
|
|
19609
19592
|
function encode3DTileHeader(tile, dataView, byteOffset) {
|
|
19610
19593
|
const HEADER_SIZE = 12;
|
package/dist/index.cjs
CHANGED
|
@@ -36,8 +36,8 @@ __export(src_exports, {
|
|
|
36
36
|
Tile3DFeatureTable: () => Tile3DFeatureTable,
|
|
37
37
|
Tile3DSubtreeLoader: () => Tile3DSubtreeLoader,
|
|
38
38
|
Tile3DWriter: () => Tile3DWriter,
|
|
39
|
+
Tiles3DArchive: () => Tiles3DArchive,
|
|
39
40
|
Tiles3DArchiveFileLoader: () => Tiles3DArchiveFileLoader,
|
|
40
|
-
Tiles3DArchiveFileSystem: () => Tiles3DArchiveFileSystem,
|
|
41
41
|
Tiles3DLoader: () => Tiles3DLoader,
|
|
42
42
|
_getIonTilesetMetadata: () => getIonTilesetMetadata
|
|
43
43
|
});
|
|
@@ -2486,14 +2486,14 @@ var COMPRESSION_METHODS = {
|
|
|
2486
2486
|
/** Deflation */
|
|
2487
2487
|
8: (data) => new import_compression.DeflateCompression({ raw: true }).decompress(data)
|
|
2488
2488
|
};
|
|
2489
|
-
var Tiles3DArchive = class {
|
|
2489
|
+
var Tiles3DArchive = class extends import_zip.IndexedArchive {
|
|
2490
2490
|
/**
|
|
2491
2491
|
* creates Tiles3DArchive handler
|
|
2492
2492
|
* @param fileProvider - FileProvider with the whole file
|
|
2493
2493
|
* @param hashTable - hash info
|
|
2494
2494
|
*/
|
|
2495
|
-
constructor(fileProvider, hashTable) {
|
|
2496
|
-
|
|
2495
|
+
constructor(fileProvider, hashTable, fileName) {
|
|
2496
|
+
super(fileProvider, hashTable, fileName);
|
|
2497
2497
|
this.hashTable = hashTable;
|
|
2498
2498
|
}
|
|
2499
2499
|
/**
|
|
@@ -2517,25 +2517,31 @@ var Tiles3DArchive = class {
|
|
|
2517
2517
|
* @returns buffer with the raw file data
|
|
2518
2518
|
*/
|
|
2519
2519
|
async getFileBytes(path3) {
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2520
|
+
let uncompressedFile;
|
|
2521
|
+
if (this.hashTable) {
|
|
2522
|
+
const arrayBuffer = new TextEncoder().encode(path3).buffer;
|
|
2523
|
+
const nameHash = await new import_crypto.MD5Hash().hash(arrayBuffer, "hex");
|
|
2524
|
+
const byteOffset = this.hashTable[nameHash];
|
|
2525
|
+
if (byteOffset === void 0) {
|
|
2526
|
+
return null;
|
|
2527
|
+
}
|
|
2528
|
+
const localFileHeader = await (0, import_zip.parseZipLocalFileHeader)(byteOffset, this.fileProvider);
|
|
2529
|
+
if (!localFileHeader) {
|
|
2530
|
+
return null;
|
|
2531
|
+
}
|
|
2532
|
+
const compressedFile = await this.fileProvider.slice(
|
|
2533
|
+
localFileHeader.fileDataOffset,
|
|
2534
|
+
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
2535
|
+
);
|
|
2536
|
+
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
2537
|
+
if (!compressionMethod) {
|
|
2538
|
+
throw Error("Only Deflation compression is supported");
|
|
2539
|
+
}
|
|
2540
|
+
uncompressedFile = await compressionMethod(compressedFile);
|
|
2541
|
+
} else {
|
|
2542
|
+
uncompressedFile = await this.getFileWithoutHash(path3);
|
|
2537
2543
|
}
|
|
2538
|
-
return
|
|
2544
|
+
return uncompressedFile;
|
|
2539
2545
|
}
|
|
2540
2546
|
};
|
|
2541
2547
|
|
|
@@ -2585,73 +2591,6 @@ async function parse3DTilesArchive2(data, options = {}) {
|
|
|
2585
2591
|
return archive.getFile(((_a = options["3d-tiles-archive"]) == null ? void 0 : _a.path) ?? "");
|
|
2586
2592
|
}
|
|
2587
2593
|
|
|
2588
|
-
// src/lib/filesystems/tiles-3d-archive-file-system.ts
|
|
2589
|
-
var import_zip3 = require("@loaders.gl/zip");
|
|
2590
|
-
var Tiles3DArchiveFileSystem = class extends import_zip3.ZipFileSystem {
|
|
2591
|
-
/**
|
|
2592
|
-
* Constructor
|
|
2593
|
-
* @param file - instance of FileProvider or file path string
|
|
2594
|
-
*/
|
|
2595
|
-
constructor(file) {
|
|
2596
|
-
super(file);
|
|
2597
|
-
}
|
|
2598
|
-
/**
|
|
2599
|
-
* Implementation of fetch against this file system.
|
|
2600
|
-
* It tries to take `@3dtilesIndex1@` file from the archive and use it
|
|
2601
|
-
* for faster access to archived files
|
|
2602
|
-
* @param filename - name of a file
|
|
2603
|
-
* @returns - Response with file data
|
|
2604
|
-
*/
|
|
2605
|
-
async fetch(filename) {
|
|
2606
|
-
const fileProvider = this.fileProvider;
|
|
2607
|
-
if (!fileProvider) {
|
|
2608
|
-
throw new Error("No data detected in the zip archive");
|
|
2609
|
-
}
|
|
2610
|
-
await this.parseHashTable();
|
|
2611
|
-
if (this.hashTable) {
|
|
2612
|
-
const archive = new Tiles3DArchive(fileProvider, this.hashTable);
|
|
2613
|
-
const fileData = await archive.getFile(filename);
|
|
2614
|
-
const response = new Response(fileData);
|
|
2615
|
-
Object.defineProperty(response, "url", { value: `${this.fileName || ""}/${filename}` });
|
|
2616
|
-
return response;
|
|
2617
|
-
}
|
|
2618
|
-
return super.fetch(filename);
|
|
2619
|
-
}
|
|
2620
|
-
/**
|
|
2621
|
-
* Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
|
|
2622
|
-
* to files inside the archive
|
|
2623
|
-
* @returns void
|
|
2624
|
-
*/
|
|
2625
|
-
async parseHashTable() {
|
|
2626
|
-
if (this.hashTable !== void 0) {
|
|
2627
|
-
return;
|
|
2628
|
-
}
|
|
2629
|
-
const fileProvider = this.fileProvider;
|
|
2630
|
-
if (!fileProvider) {
|
|
2631
|
-
throw new Error("No data detected in the zip archive");
|
|
2632
|
-
}
|
|
2633
|
-
const hashCDOffset = await (0, import_zip3.searchFromTheEnd)(fileProvider, import_zip3.CD_HEADER_SIGNATURE);
|
|
2634
|
-
const cdFileHeader = await (0, import_zip3.parseZipCDFileHeader)(hashCDOffset, fileProvider);
|
|
2635
|
-
if ((cdFileHeader == null ? void 0 : cdFileHeader.fileName) === "@3dtilesIndex1@") {
|
|
2636
|
-
const localFileHeader = await (0, import_zip3.parseZipLocalFileHeader)(
|
|
2637
|
-
cdFileHeader.localHeaderOffset,
|
|
2638
|
-
fileProvider
|
|
2639
|
-
);
|
|
2640
|
-
if (!localFileHeader) {
|
|
2641
|
-
throw new Error("corrupted 3tz");
|
|
2642
|
-
}
|
|
2643
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
2644
|
-
const hashFile = await fileProvider.slice(
|
|
2645
|
-
fileDataOffset,
|
|
2646
|
-
fileDataOffset + localFileHeader.compressedSize
|
|
2647
|
-
);
|
|
2648
|
-
this.hashTable = (0, import_zip3.parseHashTable)(hashFile);
|
|
2649
|
-
} else {
|
|
2650
|
-
this.hashTable = null;
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
};
|
|
2654
|
-
|
|
2655
2594
|
// src/lib/encoders/encode-3d-tile.ts
|
|
2656
2595
|
var import_loader_utils15 = require("@loaders.gl/loader-utils");
|
|
2657
2596
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { CesiumIonLoader } from './cesium-ion-loader';
|
|
|
3
3
|
export { Tile3DSubtreeLoader } from './tile-3d-subtree-loader';
|
|
4
4
|
export type { Tiles3DArchiveFileLoaderOptions } from './3d-tiles-archive-loader';
|
|
5
5
|
export { Tiles3DArchiveFileLoader } from './3d-tiles-archive-loader';
|
|
6
|
-
export { Tiles3DArchiveFileSystem } from './lib/filesystems/tiles-3d-archive-file-system';
|
|
7
6
|
export { Tile3DWriter } from './tile-3d-writer';
|
|
8
7
|
export { default as Tile3DFeatureTable } from './lib/classes/tile-3d-feature-table';
|
|
9
8
|
export { default as Tile3DBatchTable } from './lib/classes/tile-3d-batch-table';
|
|
@@ -11,4 +10,5 @@ export { TILE3D_TYPE } from './lib/constants';
|
|
|
11
10
|
export { getIonTilesetMetadata as _getIonTilesetMetadata } from './lib/ion/ion';
|
|
12
11
|
export type { FeatureTableJson, B3DMContent, Tile3DBoundingVolume, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON, Tiles3DTilesetJSONPostprocessed, Tiles3DTileContent, ImplicitTilingExensionData } from './types';
|
|
13
12
|
export type { Tiles3DLoaderOptions } from './tiles-3d-loader';
|
|
13
|
+
export { Tiles3DArchive } from './3d-tiles-archive/3d-tiles-archive-archive';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAC,+BAA+B,EAAC,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAC,+BAA+B,EAAC,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AAGnE,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAG9E,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,qBAAqB,IAAI,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC9E,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,+BAA+B,EAC/B,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AACjB,YAAY,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAC,cAAc,EAAC,MAAM,6CAA6C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ export { Tiles3DLoader } from "./tiles-3d-loader.js";
|
|
|
2
2
|
export { CesiumIonLoader } from "./cesium-ion-loader.js";
|
|
3
3
|
export { Tile3DSubtreeLoader } from "./tile-3d-subtree-loader.js";
|
|
4
4
|
export { Tiles3DArchiveFileLoader } from "./3d-tiles-archive-loader.js";
|
|
5
|
-
export { Tiles3DArchiveFileSystem } from "./lib/filesystems/tiles-3d-archive-file-system.js";
|
|
6
5
|
export { Tile3DWriter } from "./tile-3d-writer.js";
|
|
7
6
|
export { default as Tile3DFeatureTable } from "./lib/classes/tile-3d-feature-table.js";
|
|
8
7
|
export { default as Tile3DBatchTable } from "./lib/classes/tile-3d-batch-table.js";
|
|
9
8
|
export { TILE3D_TYPE } from "./lib/constants.js";
|
|
10
9
|
export { getIonTilesetMetadata as _getIonTilesetMetadata } from "./lib/ion/ion.js";
|
|
10
|
+
export { Tiles3DArchive } from "./3d-tiles-archive/3d-tiles-archive-archive.js";
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Tiles3DLoader","CesiumIonLoader","Tile3DSubtreeLoader","Tiles3DArchiveFileLoader","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Tiles3DLoader","CesiumIonLoader","Tile3DSubtreeLoader","Tiles3DArchiveFileLoader","Tile3DWriter","default","Tile3DFeatureTable","Tile3DBatchTable","TILE3D_TYPE","getIonTilesetMetadata","_getIonTilesetMetadata","Tiles3DArchive"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\n// LOADERS\nexport {Tiles3DLoader} from './tiles-3d-loader';\nexport {CesiumIonLoader} from './cesium-ion-loader';\nexport {Tile3DSubtreeLoader} from './tile-3d-subtree-loader';\nexport type {Tiles3DArchiveFileLoaderOptions} from './3d-tiles-archive-loader';\nexport {Tiles3DArchiveFileLoader} from './3d-tiles-archive-loader';\n\n// WRITERS\nexport {Tile3DWriter} from './tile-3d-writer';\n\n// CLASSES\nexport {default as Tile3DFeatureTable} from './lib/classes/tile-3d-feature-table';\nexport {default as Tile3DBatchTable} from './lib/classes/tile-3d-batch-table';\n\n// EXPERIMENTAL\nexport {TILE3D_TYPE} from './lib/constants';\nexport {getIonTilesetMetadata as _getIonTilesetMetadata} from './lib/ion/ion';\nexport type {\n FeatureTableJson,\n B3DMContent,\n Tile3DBoundingVolume,\n Tiles3DTileJSON,\n Tiles3DTileJSONPostprocessed,\n Tiles3DTilesetJSON,\n Tiles3DTilesetJSONPostprocessed,\n Tiles3DTileContent,\n ImplicitTilingExensionData\n} from './types';\nexport type {Tiles3DLoaderOptions} from './tiles-3d-loader';\nexport {Tiles3DArchive} from './3d-tiles-archive/3d-tiles-archive-archive';\n"],"mappings":"SAKQA,aAAa;AAAA,SACbC,eAAe;AAAA,SACfC,mBAAmB;AAAA,SAEnBC,wBAAwB;AAAA,SAGxBC,YAAY;AAAA,SAGZC,OAAO,IAAIC,kBAAkB;AAAA,SAC7BD,OAAO,IAAIE,gBAAgB;AAAA,SAG3BC,WAAW;AAAA,SACXC,qBAAqB,IAAIC,sBAAsB;AAAA,SAa/CC,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = typeof "4.
|
|
1
|
+
export const VERSION = typeof "4.2.0-alpha.2" !== 'undefined' ? "4.2.0-alpha.2" : 'latest';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":["VERSION"],"sources":["../../../src/lib/utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","names":["VERSION"],"sources":["../../../src/lib/utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/3d-tiles",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-alpha.2",
|
|
4
4
|
"description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"build-bundle": "ocular-bundle ./src/index.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@loaders.gl/draco": "4.
|
|
49
|
-
"@loaders.gl/gltf": "4.
|
|
50
|
-
"@loaders.gl/loader-utils": "4.
|
|
51
|
-
"@loaders.gl/math": "4.
|
|
52
|
-
"@loaders.gl/tiles": "4.
|
|
53
|
-
"@loaders.gl/zip": "4.
|
|
48
|
+
"@loaders.gl/draco": "4.2.0-alpha.2",
|
|
49
|
+
"@loaders.gl/gltf": "4.2.0-alpha.2",
|
|
50
|
+
"@loaders.gl/loader-utils": "4.2.0-alpha.2",
|
|
51
|
+
"@loaders.gl/math": "4.2.0-alpha.2",
|
|
52
|
+
"@loaders.gl/tiles": "4.2.0-alpha.2",
|
|
53
|
+
"@loaders.gl/zip": "4.2.0-alpha.2",
|
|
54
54
|
"@math.gl/core": "^4.0.0",
|
|
55
55
|
"@math.gl/geospatial": "^4.0.0",
|
|
56
56
|
"@probe.gl/log": "^4.0.4",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@loaders.gl/core": "^4.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "d66a6a4626ea84c5f2cad5fa5cf7ebb6943c57c8"
|
|
63
63
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {FileProvider} from '@loaders.gl/loader-utils';
|
|
6
6
|
import {MD5Hash} from '@loaders.gl/crypto';
|
|
7
7
|
import {DeflateCompression, NoCompression} from '@loaders.gl/compression';
|
|
8
|
-
import {parseZipLocalFileHeader} from '@loaders.gl/zip';
|
|
8
|
+
import {IndexedArchive, parseZipLocalFileHeader} from '@loaders.gl/zip';
|
|
9
9
|
|
|
10
10
|
type CompressionHandler = (compressedFile: ArrayBuffer) => Promise<ArrayBuffer>;
|
|
11
11
|
|
|
@@ -22,19 +22,17 @@ const COMPRESSION_METHODS: {[key: number]: CompressionHandler} = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Class for handling information about 3tz file
|
|
24
24
|
*/
|
|
25
|
-
export class Tiles3DArchive {
|
|
26
|
-
/** FileProvider with whe whole file */
|
|
27
|
-
private fileProvider: FileProvider;
|
|
25
|
+
export class Tiles3DArchive extends IndexedArchive {
|
|
28
26
|
/** hash info */
|
|
29
|
-
private hashTable
|
|
27
|
+
private hashTable?: Record<string, bigint>;
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
* creates Tiles3DArchive handler
|
|
33
31
|
* @param fileProvider - FileProvider with the whole file
|
|
34
32
|
* @param hashTable - hash info
|
|
35
33
|
*/
|
|
36
|
-
constructor(fileProvider: FileProvider, hashTable
|
|
37
|
-
|
|
34
|
+
constructor(fileProvider: FileProvider, hashTable?: Record<string, bigint>, fileName?: string) {
|
|
35
|
+
super(fileProvider, hashTable, fileName);
|
|
38
36
|
this.hashTable = hashTable;
|
|
39
37
|
}
|
|
40
38
|
|
|
@@ -63,28 +61,35 @@ export class Tiles3DArchive {
|
|
|
63
61
|
* @returns buffer with the raw file data
|
|
64
62
|
*/
|
|
65
63
|
private async getFileBytes(path: string): Promise<ArrayBuffer | null> {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
let uncompressedFile: ArrayBuffer;
|
|
65
|
+
if (this.hashTable) {
|
|
66
|
+
const arrayBuffer = new TextEncoder().encode(path).buffer;
|
|
67
|
+
const nameHash = await new MD5Hash().hash(arrayBuffer, 'hex');
|
|
68
|
+
const byteOffset = this.hashTable[nameHash];
|
|
69
|
+
if (byteOffset === undefined) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);
|
|
74
|
+
if (!localFileHeader) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const compressedFile = await this.fileProvider.slice(
|
|
79
|
+
localFileHeader.fileDataOffset,
|
|
80
|
+
localFileHeader.fileDataOffset + localFileHeader.compressedSize
|
|
81
|
+
);
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
84
|
+
if (!compressionMethod) {
|
|
85
|
+
throw Error('Only Deflation compression is supported');
|
|
86
|
+
}
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
uncompressedFile = await compressionMethod(compressedFile);
|
|
89
|
+
} else {
|
|
90
|
+
uncompressedFile = await this.getFileWithoutHash(path);
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
return
|
|
93
|
+
return uncompressedFile;
|
|
89
94
|
}
|
|
90
95
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export {CesiumIonLoader} from './cesium-ion-loader';
|
|
|
8
8
|
export {Tile3DSubtreeLoader} from './tile-3d-subtree-loader';
|
|
9
9
|
export type {Tiles3DArchiveFileLoaderOptions} from './3d-tiles-archive-loader';
|
|
10
10
|
export {Tiles3DArchiveFileLoader} from './3d-tiles-archive-loader';
|
|
11
|
-
export {Tiles3DArchiveFileSystem} from './lib/filesystems/tiles-3d-archive-file-system';
|
|
12
11
|
|
|
13
12
|
// WRITERS
|
|
14
13
|
export {Tile3DWriter} from './tile-3d-writer';
|
|
@@ -32,3 +31,4 @@ export type {
|
|
|
32
31
|
ImplicitTilingExensionData
|
|
33
32
|
} from './types';
|
|
34
33
|
export type {Tiles3DLoaderOptions} from './tiles-3d-loader';
|
|
34
|
+
export {Tiles3DArchive} from './3d-tiles-archive/3d-tiles-archive-archive';
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { FileProvider } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { ZipFileSystem } from '@loaders.gl/zip';
|
|
3
|
-
/**
|
|
4
|
-
* FileSystem adapter for a 3tz (3D tiles archive format) file
|
|
5
|
-
* Holds FileProvider object that provides random access to archived files.
|
|
6
|
-
* The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
|
|
7
|
-
* access speed to archived files
|
|
8
|
-
* @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
|
|
9
|
-
*/
|
|
10
|
-
export declare class Tiles3DArchiveFileSystem extends ZipFileSystem {
|
|
11
|
-
hashTable?: Record<string, bigint> | null;
|
|
12
|
-
/**
|
|
13
|
-
* Constructor
|
|
14
|
-
* @param file - instance of FileProvider or file path string
|
|
15
|
-
*/
|
|
16
|
-
constructor(file: FileProvider | string);
|
|
17
|
-
/**
|
|
18
|
-
* Implementation of fetch against this file system.
|
|
19
|
-
* It tries to take `@3dtilesIndex1@` file from the archive and use it
|
|
20
|
-
* for faster access to archived files
|
|
21
|
-
* @param filename - name of a file
|
|
22
|
-
* @returns - Response with file data
|
|
23
|
-
*/
|
|
24
|
-
fetch(filename: string): Promise<Response>;
|
|
25
|
-
/**
|
|
26
|
-
* Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
|
|
27
|
-
* to files inside the archive
|
|
28
|
-
* @returns void
|
|
29
|
-
*/
|
|
30
|
-
private parseHashTable;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=tiles-3d-archive-file-system.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-archive-file-system.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/tiles-3d-archive-file-system.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EACL,aAAa,EAMd,MAAM,iBAAiB,CAAC;AAGzB;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAE1C;;;OAGG;gBACS,IAAI,EAAE,YAAY,GAAG,MAAM;IAIvC;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBhD;;;;OAIG;YACW,cAAc;CAqC7B"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ZipFileSystem, CD_HEADER_SIGNATURE, searchFromTheEnd, parseZipCDFileHeader, parseHashTable, parseZipLocalFileHeader } from '@loaders.gl/zip';
|
|
2
|
-
import { Tiles3DArchive } from "../../3d-tiles-archive/3d-tiles-archive-archive.js";
|
|
3
|
-
export class Tiles3DArchiveFileSystem extends ZipFileSystem {
|
|
4
|
-
constructor(file) {
|
|
5
|
-
super(file);
|
|
6
|
-
this.hashTable = void 0;
|
|
7
|
-
}
|
|
8
|
-
async fetch(filename) {
|
|
9
|
-
const fileProvider = this.fileProvider;
|
|
10
|
-
if (!fileProvider) {
|
|
11
|
-
throw new Error('No data detected in the zip archive');
|
|
12
|
-
}
|
|
13
|
-
await this.parseHashTable();
|
|
14
|
-
if (this.hashTable) {
|
|
15
|
-
const archive = new Tiles3DArchive(fileProvider, this.hashTable);
|
|
16
|
-
const fileData = await archive.getFile(filename);
|
|
17
|
-
const response = new Response(fileData);
|
|
18
|
-
Object.defineProperty(response, 'url', {
|
|
19
|
-
value: `${this.fileName || ''}/${filename}`
|
|
20
|
-
});
|
|
21
|
-
return response;
|
|
22
|
-
}
|
|
23
|
-
return super.fetch(filename);
|
|
24
|
-
}
|
|
25
|
-
async parseHashTable() {
|
|
26
|
-
if (this.hashTable !== undefined) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const fileProvider = this.fileProvider;
|
|
30
|
-
if (!fileProvider) {
|
|
31
|
-
throw new Error('No data detected in the zip archive');
|
|
32
|
-
}
|
|
33
|
-
const hashCDOffset = await searchFromTheEnd(fileProvider, CD_HEADER_SIGNATURE);
|
|
34
|
-
const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
|
|
35
|
-
if ((cdFileHeader === null || cdFileHeader === void 0 ? void 0 : cdFileHeader.fileName) === '@3dtilesIndex1@') {
|
|
36
|
-
const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
|
|
37
|
-
if (!localFileHeader) {
|
|
38
|
-
throw new Error('corrupted 3tz');
|
|
39
|
-
}
|
|
40
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
41
|
-
const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
42
|
-
this.hashTable = parseHashTable(hashFile);
|
|
43
|
-
} else {
|
|
44
|
-
this.hashTable = null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=tiles-3d-archive-file-system.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-archive-file-system.js","names":["ZipFileSystem","CD_HEADER_SIGNATURE","searchFromTheEnd","parseZipCDFileHeader","parseHashTable","parseZipLocalFileHeader","Tiles3DArchive","Tiles3DArchiveFileSystem","constructor","file","hashTable","fetch","filename","fileProvider","Error","archive","fileData","getFile","response","Response","Object","defineProperty","value","fileName","undefined","hashCDOffset","cdFileHeader","localFileHeader","localHeaderOffset","fileDataOffset","hashFile","slice","compressedSize"],"sources":["../../../src/lib/filesystems/tiles-3d-archive-file-system.ts"],"sourcesContent":["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright vis.gl contributors\n\nimport {FileProvider} from '@loaders.gl/loader-utils';\nimport {\n ZipFileSystem,\n CD_HEADER_SIGNATURE,\n searchFromTheEnd,\n parseZipCDFileHeader,\n parseHashTable,\n parseZipLocalFileHeader\n} from '@loaders.gl/zip';\nimport {Tiles3DArchive} from '../../3d-tiles-archive/3d-tiles-archive-archive';\n\n/**\n * FileSystem adapter for a 3tz (3D tiles archive format) file\n * Holds FileProvider object that provides random access to archived files.\n * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases\n * access speed to archived files\n * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md\n */\nexport class Tiles3DArchiveFileSystem extends ZipFileSystem {\n hashTable?: Record<string, bigint> | null;\n\n /**\n * Constructor\n * @param file - instance of FileProvider or file path string\n */\n constructor(file: FileProvider | string) {\n super(file);\n }\n\n /**\n * Implementation of fetch against this file system.\n * It tries to take `@3dtilesIndex1@` file from the archive and use it\n * for faster access to archived files\n * @param filename - name of a file\n * @returns - Response with file data\n */\n async fetch(filename: string): Promise<Response> {\n const fileProvider = this.fileProvider;\n if (!fileProvider) {\n throw new Error('No data detected in the zip archive');\n }\n await this.parseHashTable();\n if (this.hashTable) {\n const archive = new Tiles3DArchive(fileProvider, this.hashTable);\n\n const fileData = await archive.getFile(filename);\n const response = new Response(fileData);\n Object.defineProperty(response, 'url', {value: `${this.fileName || ''}/${filename}`});\n return response;\n }\n return super.fetch(filename);\n }\n\n /**\n * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access\n * to files inside the archive\n * @returns void\n */\n private async parseHashTable(): Promise<void> {\n if (this.hashTable !== undefined) {\n return;\n }\n\n const fileProvider = this.fileProvider;\n if (!fileProvider) {\n throw new Error('No data detected in the zip archive');\n }\n\n const hashCDOffset = await searchFromTheEnd(fileProvider, CD_HEADER_SIGNATURE);\n\n const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);\n\n // '@3dtilesIndex1@' is index file that must be the last in the archive. It allows\n // to improve load and read performance when the archive contains a very large number\n // of files.\n if (cdFileHeader?.fileName === '@3dtilesIndex1@') {\n const localFileHeader = await parseZipLocalFileHeader(\n cdFileHeader.localHeaderOffset,\n fileProvider\n );\n if (!localFileHeader) {\n throw new Error('corrupted 3tz');\n }\n\n const fileDataOffset = localFileHeader.fileDataOffset;\n const hashFile = await fileProvider.slice(\n fileDataOffset,\n fileDataOffset + localFileHeader.compressedSize\n );\n\n this.hashTable = parseHashTable(hashFile);\n } else {\n this.hashTable = null;\n }\n }\n}\n"],"mappings":"AAKA,SACEA,aAAa,EACbC,mBAAmB,EACnBC,gBAAgB,EAChBC,oBAAoB,EACpBC,cAAc,EACdC,uBAAuB,QAClB,iBAAiB;AAAC,SACjBC,cAAc;AAStB,OAAO,MAAMC,wBAAwB,SAASP,aAAa,CAAC;EAO1DQ,WAAWA,CAACC,IAA2B,EAAE;IACvC,KAAK,CAACA,IAAI,CAAC;IAAC,KAPdC,SAAS;EAQT;EASA,MAAMC,KAAKA,CAACC,QAAgB,EAAqB;IAC/C,MAAMC,YAAY,GAAG,IAAI,CAACA,YAAY;IACtC,IAAI,CAACA,YAAY,EAAE;MACjB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;IACxD;IACA,MAAM,IAAI,CAACV,cAAc,CAAC,CAAC;IAC3B,IAAI,IAAI,CAACM,SAAS,EAAE;MAClB,MAAMK,OAAO,GAAG,IAAIT,cAAc,CAACO,YAAY,EAAE,IAAI,CAACH,SAAS,CAAC;MAEhE,MAAMM,QAAQ,GAAG,MAAMD,OAAO,CAACE,OAAO,CAACL,QAAQ,CAAC;MAChD,MAAMM,QAAQ,GAAG,IAAIC,QAAQ,CAACH,QAAQ,CAAC;MACvCI,MAAM,CAACC,cAAc,CAACH,QAAQ,EAAE,KAAK,EAAE;QAACI,KAAK,EAAG,GAAE,IAAI,CAACC,QAAQ,IAAI,EAAG,IAAGX,QAAS;MAAC,CAAC,CAAC;MACrF,OAAOM,QAAQ;IACjB;IACA,OAAO,KAAK,CAACP,KAAK,CAACC,QAAQ,CAAC;EAC9B;EAOA,MAAcR,cAAcA,CAAA,EAAkB;IAC5C,IAAI,IAAI,CAACM,SAAS,KAAKc,SAAS,EAAE;MAChC;IACF;IAEA,MAAMX,YAAY,GAAG,IAAI,CAACA,YAAY;IACtC,IAAI,CAACA,YAAY,EAAE;MACjB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;IACxD;IAEA,MAAMW,YAAY,GAAG,MAAMvB,gBAAgB,CAACW,YAAY,EAAEZ,mBAAmB,CAAC;IAE9E,MAAMyB,YAAY,GAAG,MAAMvB,oBAAoB,CAACsB,YAAY,EAAEZ,YAAY,CAAC;IAK3E,IAAI,CAAAa,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEH,QAAQ,MAAK,iBAAiB,EAAE;MAChD,MAAMI,eAAe,GAAG,MAAMtB,uBAAuB,CACnDqB,YAAY,CAACE,iBAAiB,EAC9Bf,YACF,CAAC;MACD,IAAI,CAACc,eAAe,EAAE;QACpB,MAAM,IAAIb,KAAK,CAAC,eAAe,CAAC;MAClC;MAEA,MAAMe,cAAc,GAAGF,eAAe,CAACE,cAAc;MACrD,MAAMC,QAAQ,GAAG,MAAMjB,YAAY,CAACkB,KAAK,CACvCF,cAAc,EACdA,cAAc,GAAGF,eAAe,CAACK,cACnC,CAAC;MAED,IAAI,CAACtB,SAAS,GAAGN,cAAc,CAAC0B,QAAQ,CAAC;IAC3C,CAAC,MAAM;MACL,IAAI,CAACpB,SAAS,GAAG,IAAI;IACvB;EACF;AACF"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {FileProvider} from '@loaders.gl/loader-utils';
|
|
6
|
-
import {
|
|
7
|
-
ZipFileSystem,
|
|
8
|
-
CD_HEADER_SIGNATURE,
|
|
9
|
-
searchFromTheEnd,
|
|
10
|
-
parseZipCDFileHeader,
|
|
11
|
-
parseHashTable,
|
|
12
|
-
parseZipLocalFileHeader
|
|
13
|
-
} from '@loaders.gl/zip';
|
|
14
|
-
import {Tiles3DArchive} from '../../3d-tiles-archive/3d-tiles-archive-archive';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* FileSystem adapter for a 3tz (3D tiles archive format) file
|
|
18
|
-
* Holds FileProvider object that provides random access to archived files.
|
|
19
|
-
* The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
|
|
20
|
-
* access speed to archived files
|
|
21
|
-
* @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
|
|
22
|
-
*/
|
|
23
|
-
export class Tiles3DArchiveFileSystem extends ZipFileSystem {
|
|
24
|
-
hashTable?: Record<string, bigint> | null;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Constructor
|
|
28
|
-
* @param file - instance of FileProvider or file path string
|
|
29
|
-
*/
|
|
30
|
-
constructor(file: FileProvider | string) {
|
|
31
|
-
super(file);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Implementation of fetch against this file system.
|
|
36
|
-
* It tries to take `@3dtilesIndex1@` file from the archive and use it
|
|
37
|
-
* for faster access to archived files
|
|
38
|
-
* @param filename - name of a file
|
|
39
|
-
* @returns - Response with file data
|
|
40
|
-
*/
|
|
41
|
-
async fetch(filename: string): Promise<Response> {
|
|
42
|
-
const fileProvider = this.fileProvider;
|
|
43
|
-
if (!fileProvider) {
|
|
44
|
-
throw new Error('No data detected in the zip archive');
|
|
45
|
-
}
|
|
46
|
-
await this.parseHashTable();
|
|
47
|
-
if (this.hashTable) {
|
|
48
|
-
const archive = new Tiles3DArchive(fileProvider, this.hashTable);
|
|
49
|
-
|
|
50
|
-
const fileData = await archive.getFile(filename);
|
|
51
|
-
const response = new Response(fileData);
|
|
52
|
-
Object.defineProperty(response, 'url', {value: `${this.fileName || ''}/${filename}`});
|
|
53
|
-
return response;
|
|
54
|
-
}
|
|
55
|
-
return super.fetch(filename);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
|
|
60
|
-
* to files inside the archive
|
|
61
|
-
* @returns void
|
|
62
|
-
*/
|
|
63
|
-
private async parseHashTable(): Promise<void> {
|
|
64
|
-
if (this.hashTable !== undefined) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const fileProvider = this.fileProvider;
|
|
69
|
-
if (!fileProvider) {
|
|
70
|
-
throw new Error('No data detected in the zip archive');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const hashCDOffset = await searchFromTheEnd(fileProvider, CD_HEADER_SIGNATURE);
|
|
74
|
-
|
|
75
|
-
const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
|
|
76
|
-
|
|
77
|
-
// '@3dtilesIndex1@' is index file that must be the last in the archive. It allows
|
|
78
|
-
// to improve load and read performance when the archive contains a very large number
|
|
79
|
-
// of files.
|
|
80
|
-
if (cdFileHeader?.fileName === '@3dtilesIndex1@') {
|
|
81
|
-
const localFileHeader = await parseZipLocalFileHeader(
|
|
82
|
-
cdFileHeader.localHeaderOffset,
|
|
83
|
-
fileProvider
|
|
84
|
-
);
|
|
85
|
-
if (!localFileHeader) {
|
|
86
|
-
throw new Error('corrupted 3tz');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
90
|
-
const hashFile = await fileProvider.slice(
|
|
91
|
-
fileDataOffset,
|
|
92
|
-
fileDataOffset + localFileHeader.compressedSize
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
this.hashTable = parseHashTable(hashFile);
|
|
96
|
-
} else {
|
|
97
|
-
this.hashTable = null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|