@loaders.gl/3d-tiles 4.0.0-alpha.20 → 4.0.0-alpha.22
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 +29 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +72 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +33 -0
- package/dist/3d-tiles-archive-loader.d.ts +13 -0
- package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
- package/dist/3d-tiles-archive-loader.js +31 -0
- package/dist/dist.min.js +5429 -215
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js +69 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
- package/dist/es5/3d-tiles-archive-loader.js +50 -0
- package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
- package/dist/es5/index.js +14 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +12 -12
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +2 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js +46 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js +23 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
- package/dist/esm/3d-tiles-archive-loader.js +20 -0
- package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +5 -7
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +2 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +31 -0
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
- package/dist/lib/filesystems/tiles-3d-archive-file-system.js +75 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +2 -2
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +6 -6
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +2 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +10 -2
- package/package.json +8 -7
- package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +84 -0
- package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +52 -0
- package/src/3d-tiles-archive-loader.ts +47 -0
- package/src/index.ts +3 -0
- package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
- package/src/lib/parsers/parse-3d-tile-gltf.ts +8 -8
- package/src/lib/parsers/parse-3d-tile-header.ts +2 -1
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FileProvider, HashElement } from '@loaders.gl/zip';
|
|
2
|
+
/**
|
|
3
|
+
* Class for handling information about 3tz file
|
|
4
|
+
*/
|
|
5
|
+
export declare class Tiles3DArchive {
|
|
6
|
+
/** FileProvider with whe whole file */
|
|
7
|
+
private fileProvider;
|
|
8
|
+
/** hash info */
|
|
9
|
+
private hashArray;
|
|
10
|
+
/**
|
|
11
|
+
* creates Tiles3DArchive handler
|
|
12
|
+
* @param fileProvider - FileProvider with the whole file
|
|
13
|
+
* @param hashFile - hash info
|
|
14
|
+
*/
|
|
15
|
+
constructor(fileProvider: FileProvider, hashFile: HashElement[]);
|
|
16
|
+
/**
|
|
17
|
+
* Returns file with the given path from 3tz archive
|
|
18
|
+
* @param path - path inside the 3tz
|
|
19
|
+
* @returns buffer with ready to use file
|
|
20
|
+
*/
|
|
21
|
+
getFile(path: string): Promise<ArrayBuffer>;
|
|
22
|
+
/**
|
|
23
|
+
* Trying to get raw file data by adress
|
|
24
|
+
* @param path - path inside the archive
|
|
25
|
+
* @returns buffer with the raw file data
|
|
26
|
+
*/
|
|
27
|
+
private getFileBytes;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=3d-tiles-archive-archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-archive.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-archive/3d-tiles-archive-archive.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAA2B,WAAW,EAAU,MAAM,iBAAiB,CAAC;AAe5F;;GAEG;AACH,qBAAa,cAAc;IACzB,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAAe;IACnC,gBAAgB;IAChB,OAAO,CAAC,SAAS,CAAgB;IAEjC;;;;OAIG;gBACS,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE;IAK/D;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAcjD;;;;OAIG;YACW,YAAY;CAwB3B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Tiles3DArchive = void 0;
|
|
7
|
+
const md5_1 = __importDefault(require("md5"));
|
|
8
|
+
const zip_1 = require("@loaders.gl/zip");
|
|
9
|
+
const compression_1 = require("@loaders.gl/compression");
|
|
10
|
+
/**
|
|
11
|
+
* Handling different compression types in zip
|
|
12
|
+
*/
|
|
13
|
+
const COMPRESSION_METHODS = {
|
|
14
|
+
/** No compression */
|
|
15
|
+
0: (data) => new compression_1.NoCompression().decompress(data),
|
|
16
|
+
/** Deflation */
|
|
17
|
+
8: (data) => new compression_1.DeflateCompression({ raw: true }).decompress(data)
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Class for handling information about 3tz file
|
|
21
|
+
*/
|
|
22
|
+
class Tiles3DArchive {
|
|
23
|
+
/**
|
|
24
|
+
* creates Tiles3DArchive handler
|
|
25
|
+
* @param fileProvider - FileProvider with the whole file
|
|
26
|
+
* @param hashFile - hash info
|
|
27
|
+
*/
|
|
28
|
+
constructor(fileProvider, hashFile) {
|
|
29
|
+
this.fileProvider = fileProvider;
|
|
30
|
+
this.hashArray = hashFile;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns file with the given path from 3tz archive
|
|
34
|
+
* @param path - path inside the 3tz
|
|
35
|
+
* @returns buffer with ready to use file
|
|
36
|
+
*/
|
|
37
|
+
async getFile(path) {
|
|
38
|
+
// sometimes paths are not in lower case when hash file is created,
|
|
39
|
+
// so first we're looking for lower case file name and then for original one
|
|
40
|
+
let data = await this.getFileBytes(path.toLocaleLowerCase());
|
|
41
|
+
if (!data) {
|
|
42
|
+
data = await this.getFileBytes(path);
|
|
43
|
+
}
|
|
44
|
+
if (!data) {
|
|
45
|
+
throw new Error('No such file in the archive');
|
|
46
|
+
}
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Trying to get raw file data by adress
|
|
51
|
+
* @param path - path inside the archive
|
|
52
|
+
* @returns buffer with the raw file data
|
|
53
|
+
*/
|
|
54
|
+
async getFileBytes(path) {
|
|
55
|
+
const nameHash = Buffer.from((0, md5_1.default)(path), 'hex');
|
|
56
|
+
const fileInfo = (0, zip_1.findBin)(nameHash, this.hashArray); // implement binary search
|
|
57
|
+
if (!fileInfo) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const localFileHeader = await (0, zip_1.parseZipLocalFileHeader)(fileInfo.offset, this.fileProvider);
|
|
61
|
+
if (!localFileHeader) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
|
|
65
|
+
const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
|
|
66
|
+
if (!compressionMethod) {
|
|
67
|
+
throw Error('Only Deflation compression is supported');
|
|
68
|
+
}
|
|
69
|
+
return compressionMethod(compressedFile);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Tiles3DArchive = Tiles3DArchive;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileProvider } from '@loaders.gl/zip';
|
|
2
|
+
import { Tiles3DArchive } from './3d-tiles-archive-archive';
|
|
3
|
+
/**
|
|
4
|
+
* Creates 3tz file handler from raw file
|
|
5
|
+
* @param fileProvider raw file data
|
|
6
|
+
* @param cb is called with information message during parsing
|
|
7
|
+
* @returns 3tz file handler
|
|
8
|
+
*/
|
|
9
|
+
export declare const parse3DTilesArchive: (fileProvider: FileProvider, cb?: ((msg: string) => void) | undefined) => Promise<Tiles3DArchive>;
|
|
10
|
+
//# sourceMappingURL=3d-tiles-archive-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-parser.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-archive/3d-tiles-archive-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iBAChB,YAAY,cACf,MAAM,KAAK,IAAI,kBACzB,QAAQ,cAAc,CA8BxB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse3DTilesArchive = void 0;
|
|
4
|
+
const zip_1 = require("@loaders.gl/zip");
|
|
5
|
+
const _3d_tiles_archive_archive_1 = require("./3d-tiles-archive-archive");
|
|
6
|
+
/**
|
|
7
|
+
* Creates 3tz file handler from raw file
|
|
8
|
+
* @param fileProvider raw file data
|
|
9
|
+
* @param cb is called with information message during parsing
|
|
10
|
+
* @returns 3tz file handler
|
|
11
|
+
*/
|
|
12
|
+
const parse3DTilesArchive = async (fileProvider, cb) => {
|
|
13
|
+
const hashCDOffset = await (0, zip_1.searchFromTheEnd)(fileProvider, zip_1.cdSignature);
|
|
14
|
+
const cdFileHeader = await (0, zip_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
|
|
15
|
+
let hashData;
|
|
16
|
+
if (cdFileHeader?.fileName !== '@3dtilesIndex1@') {
|
|
17
|
+
cb?.('3tz doesnt contain hash file');
|
|
18
|
+
hashData = await (0, zip_1.generateHashInfo)(fileProvider);
|
|
19
|
+
cb?.('hash info has been composed according to central directory records');
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
cb?.('3tz contains hash file');
|
|
23
|
+
const localFileHeader = await (0, zip_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
|
|
24
|
+
if (!localFileHeader) {
|
|
25
|
+
throw new Error('corrupted 3tz');
|
|
26
|
+
}
|
|
27
|
+
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
28
|
+
const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
29
|
+
hashData = (0, zip_1.parseHashFile)(hashFile);
|
|
30
|
+
}
|
|
31
|
+
return new _3d_tiles_archive_archive_1.Tiles3DArchive(fileProvider, hashData);
|
|
32
|
+
};
|
|
33
|
+
exports.parse3DTilesArchive = parse3DTilesArchive;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LoaderOptions, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
/** options to load data from 3tz */
|
|
3
|
+
export type Tiles3DArchiveFileLoaderOptions = LoaderOptions & {
|
|
4
|
+
'3d-tiles-archive'?: {
|
|
5
|
+
/** path inside the 3tz archive */
|
|
6
|
+
path?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Loader for 3tz packages
|
|
11
|
+
*/
|
|
12
|
+
export declare const Tiles3DArchiveFileLoader: LoaderWithParser<ArrayBuffer, never, Tiles3DArchiveFileLoaderOptions>;
|
|
13
|
+
//# sourceMappingURL=3d-tiles-archive-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-tiles-archive-loader.d.ts","sourceRoot":"","sources":["../src/3d-tiles-archive-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAQzE,oCAAoC;AACpC,MAAM,MAAM,+BAA+B,GAAG,aAAa,GAAG;IAC5D,kBAAkB,CAAC,EAAE;QACnB,kCAAkC;QAClC,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,gBAAgB,CACrD,WAAW,EACX,KAAK,EACL,+BAA+B,CAUhC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tiles3DArchiveFileLoader = void 0;
|
|
4
|
+
const zip_1 = require("@loaders.gl/zip");
|
|
5
|
+
const _3d_tiles_archive_parser_1 = require("./3d-tiles-archive/3d-tiles-archive-parser");
|
|
6
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
9
|
+
/**
|
|
10
|
+
* Loader for 3tz packages
|
|
11
|
+
*/
|
|
12
|
+
exports.Tiles3DArchiveFileLoader = {
|
|
13
|
+
name: '3tz',
|
|
14
|
+
id: '3tz',
|
|
15
|
+
module: '3d-tiles',
|
|
16
|
+
version: VERSION,
|
|
17
|
+
mimeTypes: ['application/octet-stream', 'application/vnd.maxar.archive.3tz+zip'],
|
|
18
|
+
parse: parse3DTilesArchive,
|
|
19
|
+
extensions: ['3tz'],
|
|
20
|
+
options: {}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* returns a single file from the 3tz archive
|
|
24
|
+
* @param data 3tz archive data
|
|
25
|
+
* @param options options
|
|
26
|
+
* @returns requested file
|
|
27
|
+
*/
|
|
28
|
+
async function parse3DTilesArchive(data, options = {}) {
|
|
29
|
+
const archive = await (0, _3d_tiles_archive_parser_1.parse3DTilesArchive)(new zip_1.DataViewFile(new DataView(data)));
|
|
30
|
+
return archive.getFile(options['3d-tiles-archive']?.path ?? '');
|
|
31
|
+
}
|