@loaders.gl/3d-tiles 4.0.0-alpha.21 → 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.
Files changed (89) hide show
  1. package/dist/{tz3/tz3-archive.d.ts → 3d-tiles-archive/3d-tiles-archive-archive.d.ts} +12 -6
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
  3. package/dist/{tz3/tz3-archive.js → 3d-tiles-archive/3d-tiles-archive-archive.js} +16 -16
  4. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
  5. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
  6. package/dist/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +5 -5
  7. package/dist/3d-tiles-archive-loader.d.ts +13 -0
  8. package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
  9. package/dist/{tz3-loader.js → 3d-tiles-archive-loader.js} +9 -8
  10. package/dist/dist.min.js +375 -72
  11. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
  12. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  13. package/dist/es5/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +7 -7
  14. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  15. package/dist/es5/3d-tiles-archive-loader.js +50 -0
  16. package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
  17. package/dist/es5/index.js +14 -7
  18. package/dist/es5/index.js.map +1 -1
  19. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
  20. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  21. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
  22. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  23. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +12 -12
  24. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  25. package/dist/es5/lib/parsers/parse-3d-tile-header.js +2 -1
  26. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  27. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
  28. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  29. package/dist/es5/lib/utils/version.js +1 -1
  30. package/dist/esm/{tz3/tz3-archive.js → 3d-tiles-archive/3d-tiles-archive-archive.js} +14 -19
  31. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  32. package/dist/esm/{tz3/tz3-parser.js → 3d-tiles-archive/3d-tiles-archive-parser.js} +4 -4
  33. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  34. package/dist/esm/3d-tiles-archive-loader.js +20 -0
  35. package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
  36. package/dist/esm/index.js +2 -1
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
  39. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  40. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
  41. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  42. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +5 -7
  43. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  44. package/dist/esm/lib/parsers/parse-3d-tile-header.js +2 -1
  45. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  46. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
  47. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  48. package/dist/esm/lib/utils/version.js +1 -1
  49. package/dist/index.d.ts +3 -2
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +5 -3
  52. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +31 -0
  53. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
  54. package/dist/lib/filesystems/tiles-3d-archive-file-system.js +75 -0
  55. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  56. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +2 -2
  57. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
  58. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  59. package/dist/lib/parsers/parse-3d-tile-gltf.js +6 -6
  60. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  61. package/dist/lib/parsers/parse-3d-tile-header.js +2 -1
  62. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
  63. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  64. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +10 -2
  65. package/package.json +8 -7
  66. package/src/{tz3/tz3-archive.ts → 3d-tiles-archive/3d-tiles-archive-archive.ts} +20 -18
  67. package/src/{tz3/tz3-parser.ts → 3d-tiles-archive/3d-tiles-archive-parser.ts} +4 -4
  68. package/src/3d-tiles-archive-loader.ts +47 -0
  69. package/src/index.ts +3 -2
  70. package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
  71. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
  72. package/src/lib/parsers/parse-3d-tile-gltf.ts +8 -8
  73. package/src/lib/parsers/parse-3d-tile-header.ts +2 -1
  74. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
  75. package/dist/es5/tz3/tz3-archive.js +0 -161
  76. package/dist/es5/tz3/tz3-archive.js.map +0 -1
  77. package/dist/es5/tz3/tz3-parser.js.map +0 -1
  78. package/dist/es5/tz3-loader.js +0 -48
  79. package/dist/es5/tz3-loader.js.map +0 -1
  80. package/dist/esm/tz3/tz3-archive.js.map +0 -1
  81. package/dist/esm/tz3/tz3-parser.js.map +0 -1
  82. package/dist/esm/tz3-loader.js +0 -19
  83. package/dist/esm/tz3-loader.js.map +0 -1
  84. package/dist/tz3/tz3-archive.d.ts.map +0 -1
  85. package/dist/tz3/tz3-parser.d.ts +0 -10
  86. package/dist/tz3/tz3-parser.d.ts.map +0 -1
  87. package/dist/tz3-loader.d.ts +0 -14
  88. package/dist/tz3-loader.d.ts.map +0 -1
  89. package/src/tz3-loader.ts +0 -41
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tiles3DArchiveFileSystem = void 0;
4
+ const zip_1 = require("@loaders.gl/zip");
5
+ const _3d_tiles_archive_archive_1 = require("../../3d-tiles-archive/3d-tiles-archive-archive");
6
+ /**
7
+ * FileSystem adapter for a 3tz (3D tiles archive format) file
8
+ * Holds FileProvider object that provides random access to archived files.
9
+ * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
10
+ * access speed to archived files
11
+ * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
12
+ */
13
+ class Tiles3DArchiveFileSystem extends zip_1.ZipFileSystem {
14
+ /**
15
+ * Constructor
16
+ * @param file - instance of FileProvider or file path string
17
+ */
18
+ constructor(file) {
19
+ super(file);
20
+ }
21
+ /**
22
+ * Implementation of fetch against this file system.
23
+ * It tries to take `@3dtilesIndex1@` file from the archive and use it
24
+ * for faster access to archived files
25
+ * @param filename - name of a file
26
+ * @returns - Response with file data
27
+ */
28
+ async fetch(filename) {
29
+ const fileProvider = await this.fileProvider;
30
+ if (!fileProvider) {
31
+ throw new Error('No data detected in the zip archive');
32
+ }
33
+ await this.parseHashFile();
34
+ if (this.hashData) {
35
+ const archive = new _3d_tiles_archive_archive_1.Tiles3DArchive(fileProvider, this.hashData);
36
+ const fileData = await archive.getFile(filename);
37
+ const response = new Response(fileData);
38
+ Object.defineProperty(response, 'url', { value: `${this.fileName || ''}/${filename}` });
39
+ return response;
40
+ }
41
+ return super.fetch(filename);
42
+ }
43
+ /**
44
+ * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
45
+ * to files inside the archive
46
+ * @returns void
47
+ */
48
+ async parseHashFile() {
49
+ if (this.hashData !== undefined) {
50
+ return;
51
+ }
52
+ const fileProvider = await this.fileProvider;
53
+ if (!fileProvider) {
54
+ throw new Error('No data detected in the zip archive');
55
+ }
56
+ const hashCDOffset = await (0, zip_1.searchFromTheEnd)(fileProvider, zip_1.cdSignature);
57
+ const cdFileHeader = await (0, zip_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
58
+ // '@3dtilesIndex1@' is index file that must be the last in the archive. It allows
59
+ // to improve load and read performance when the archive contains a very large number
60
+ // of files.
61
+ if (cdFileHeader?.fileName === '@3dtilesIndex1@') {
62
+ const localFileHeader = await (0, zip_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
63
+ if (!localFileHeader) {
64
+ throw new Error('corrupted 3tz');
65
+ }
66
+ const fileDataOffset = localFileHeader.fileDataOffset;
67
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
68
+ this.hashData = (0, zip_1.parseHashFile)(hashFile);
69
+ }
70
+ else {
71
+ this.hashData = null;
72
+ }
73
+ }
74
+ }
75
+ exports.Tiles3DArchiveFileSystem = Tiles3DArchiveFileSystem;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf-view.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,UAqC1C;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
1
+ {"version":3,"file":"parse-3d-tile-gltf-view.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,UAqC1C;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
@@ -55,15 +55,15 @@ async function extractGLTF(tile, gltfFormat, options, context) {
55
55
  if (!context) {
56
56
  return;
57
57
  }
58
- const { parse, fetch } = context;
59
58
  if (tile.gltfUrl) {
59
+ const { fetch } = context;
60
60
  const response = await fetch(tile.gltfUrl, options);
61
61
  tile.gltfArrayBuffer = await response.arrayBuffer();
62
62
  tile.gltfByteOffset = 0;
63
63
  }
64
64
  if (tile.gltfArrayBuffer) {
65
65
  // TODO - Should handle byteOffset... However, not used now...
66
- const gltfWithBuffers = await parse(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
66
+ const gltfWithBuffers = await (0, loader_utils_1.parseFromContext)(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
67
67
  tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
68
68
  tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
69
69
  delete tile.gltfArrayBuffer;
@@ -1,4 +1,4 @@
1
- import type { LoaderContext } from '@loaders.gl/loader-utils';
1
+ import { LoaderContext } from '@loaders.gl/loader-utils';
2
2
  import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
3
  import { Tiles3DTileContent } from '../../types';
4
4
  export declare function parseGltf3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
1
+ {"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEzE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
+ // loaders.gl, MIT license
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.parseGltf3DTile = void 0;
5
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
6
  const gltf_1 = require("@loaders.gl/gltf");
5
7
  async function parseGltf3DTile(tile, arrayBuffer, options, context) {
6
8
  // Set flags
@@ -8,16 +10,14 @@ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
8
10
  // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
9
11
  tile.rotateYtoZ = true;
10
12
  // Save gltf up axis
11
- tile.gltfUpAxis =
12
- options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
13
- ? options['3d-tiles'].assetGltfUpAxis
14
- : 'Y';
13
+ tile.gltfUpAxis = options?.['3d-tiles']?.assetGltfUpAxis
14
+ ? options['3d-tiles'].assetGltfUpAxis
15
+ : 'Y';
15
16
  if (options?.['3d-tiles']?.loadGLTF) {
16
17
  if (!context) {
17
18
  return;
18
19
  }
19
- const { parse } = context;
20
- const gltfWithBuffers = await parse(arrayBuffer, gltf_1.GLTFLoader, options, context);
20
+ const gltfWithBuffers = await (0, loader_utils_1.parseFromContext)(arrayBuffer, gltf_1.GLTFLoader, options, context);
21
21
  tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
22
22
  tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse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AChC,aAAa,EAAE,oBAAoB,GAClC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA+B9C"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeImplicitTileData = exports.normalizeImplicitTileHeaders = exports.normalizeTileHeaders = exports.normalizeTileData = void 0;
4
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
5
  const tile_3d_subtree_loader_1 = require("../../tile-3d-subtree-loader");
5
6
  const core_1 = require("@loaders.gl/core");
6
7
  const tiles_1 = require("@loaders.gl/tiles");
@@ -46,7 +47,7 @@ function resolveUri(uri = '', basePath) {
46
47
  else if (uri.startsWith('/')) {
47
48
  return uri;
48
49
  }
49
- return `${basePath}/${uri}`;
50
+ return loader_utils_1.path.resolve(basePath, uri);
50
51
  }
51
52
  function normalizeTileData(tile, basePath) {
52
53
  if (!tile) {
@@ -1,5 +1,5 @@
1
- import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
2
1
  import { LoaderContext } from '@loaders.gl/loader-utils';
2
+ import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
3
  import { Tiles3DTileContent } from '../../types';
4
4
  export declare function parsePointCloud3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
5
5
  export declare function loadDraco(tile: Tiles3DTileContent, dracoData: any, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAuND,wBAAsB,SAAS,CAC7B,IAAI,EAAE,kBAAkB,EACxB,SAAS,KAAA,EACT,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
1
+ {"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AAWzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAuND,wBAAsB,SAAS,CAC7B,IAAI,EAAE,kBAAkB,EACxB,SAAS,KAAA,EACT,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CA+Df"}
@@ -7,6 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.loadDraco = exports.parsePointCloud3DTile = void 0;
9
9
  const draco_1 = require("@loaders.gl/draco");
10
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
10
11
  const math_1 = require("@loaders.gl/math");
11
12
  const core_1 = require("@math.gl/core");
12
13
  const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
@@ -192,7 +193,6 @@ async function loadDraco(tile, dracoData, options, context) {
192
193
  if (!context) {
193
194
  return;
194
195
  }
195
- const { parse } = context;
196
196
  const dracoOptions = {
197
197
  ...options,
198
198
  draco: {
@@ -202,16 +202,19 @@ async function loadDraco(tile, dracoData, options, context) {
202
202
  };
203
203
  // The entire tileset might be included, too expensive to serialize
204
204
  delete dracoOptions['3d-tiles'];
205
- const data = await parse(dracoData.buffer, draco_1.DracoLoader, dracoOptions);
205
+ const data = await (0, loader_utils_1.parseFromContext)(dracoData.buffer, draco_1.DracoLoader, dracoOptions, context);
206
206
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
207
207
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
208
208
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
209
209
  const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
210
+ // @ts-expect-error
210
211
  const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
212
+ // @ts-expect-error
211
213
  const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
212
214
  if (isQuantizedDraco) {
213
215
  // Draco quantization range == quantized volume scale - size in meters of the quantized volume
214
216
  // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
217
+ // @ts-expect-error This doesn't look right
215
218
  const quantization = data.POSITION.data.quantization;
216
219
  const range = quantization.range;
217
220
  tile.quantizedVolumeScale = new core_1.Vector3(range, range, range);
@@ -220,6 +223,7 @@ async function loadDraco(tile, dracoData, options, context) {
220
223
  tile.isQuantizedDraco = true;
221
224
  }
222
225
  if (isOctEncodedDraco) {
226
+ // @ts-expect-error This doesn't look right
223
227
  tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
224
228
  tile.isOctEncodedDraco = true;
225
229
  }
@@ -233,9 +237,13 @@ async function loadDraco(tile, dracoData, options, context) {
233
237
  }
234
238
  }
235
239
  tile.attributes = {
240
+ // @ts-expect-error
236
241
  positions: decodedPositions,
242
+ // @ts-expect-error
237
243
  colors: (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, decodedColors, undefined),
244
+ // @ts-expect-error
238
245
  normals: decodedNormals,
246
+ // @ts-expect-error
239
247
  batchIds: decodedBatchIds,
240
248
  ...batchTableAttributes
241
249
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/3d-tiles",
3
- "version": "4.0.0-alpha.21",
3
+ "version": "4.0.0-alpha.22",
4
4
  "description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,11 +34,12 @@
34
34
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
35
35
  },
36
36
  "dependencies": {
37
- "@loaders.gl/draco": "4.0.0-alpha.21",
38
- "@loaders.gl/gltf": "4.0.0-alpha.21",
39
- "@loaders.gl/loader-utils": "4.0.0-alpha.21",
40
- "@loaders.gl/math": "4.0.0-alpha.21",
41
- "@loaders.gl/tiles": "4.0.0-alpha.21",
37
+ "@loaders.gl/draco": "4.0.0-alpha.22",
38
+ "@loaders.gl/gltf": "4.0.0-alpha.22",
39
+ "@loaders.gl/loader-utils": "4.0.0-alpha.22",
40
+ "@loaders.gl/math": "4.0.0-alpha.22",
41
+ "@loaders.gl/tiles": "4.0.0-alpha.22",
42
+ "@loaders.gl/zip": "4.0.0-alpha.22",
42
43
  "@math.gl/core": "^3.5.1",
43
44
  "@math.gl/geospatial": "^3.5.1",
44
45
  "@probe.gl/log": "^4.0.4",
@@ -47,5 +48,5 @@
47
48
  "peerDependencies": {
48
49
  "@loaders.gl/core": "^4.0.0-alpha.8"
49
50
  },
50
- "gitHead": "df5d670b136192b26941396e944f9c46be788e83"
51
+ "gitHead": "0da838c506d1275383f2fd3d244d9c72b25397d2"
51
52
  }
@@ -1,6 +1,6 @@
1
1
  import md5 from 'md5';
2
2
  import {FileProvider, parseZipLocalFileHeader, HashElement, findBin} from '@loaders.gl/zip';
3
- import {DeflateCompression} from '@loaders.gl/compression';
3
+ import {DeflateCompression, NoCompression} from '@loaders.gl/compression';
4
4
 
5
5
  type CompressionHandler = (compressedFile: ArrayBuffer) => Promise<ArrayBuffer>;
6
6
 
@@ -9,24 +9,27 @@ type CompressionHandler = (compressedFile: ArrayBuffer) => Promise<ArrayBuffer>;
9
9
  */
10
10
  const COMPRESSION_METHODS: {[key: number]: CompressionHandler} = {
11
11
  /** No compression */
12
- 0: async (compressedFile) => compressedFile,
13
-
12
+ 0: (data) => new NoCompression().decompress(data),
14
13
  /** Deflation */
15
- 8: async (compressedFile) => {
16
- const compression = new DeflateCompression({raw: true});
17
- const decompressedData = await compression.decompress(compressedFile);
18
- return decompressedData;
19
- }
14
+ 8: (data) => new DeflateCompression({raw: true}).decompress(data)
20
15
  };
21
16
 
22
17
  /**
23
18
  * Class for handling information about 3tz file
24
19
  */
25
- export class TZ3Archive {
26
- private tz3Archive: FileProvider;
20
+ export class Tiles3DArchive {
21
+ /** FileProvider with whe whole file */
22
+ private fileProvider: FileProvider;
23
+ /** hash info */
27
24
  private hashArray: HashElement[];
28
- constructor(tz3Archive: FileProvider, hashFile: HashElement[]) {
29
- this.tz3Archive = tz3Archive;
25
+
26
+ /**
27
+ * creates Tiles3DArchive handler
28
+ * @param fileProvider - FileProvider with the whole file
29
+ * @param hashFile - hash info
30
+ */
31
+ constructor(fileProvider: FileProvider, hashFile: HashElement[]) {
32
+ this.fileProvider = fileProvider;
30
33
  this.hashArray = hashFile;
31
34
  }
32
35
 
@@ -35,7 +38,7 @@ export class TZ3Archive {
35
38
  * @param path - path inside the 3tz
36
39
  * @returns buffer with ready to use file
37
40
  */
38
- async getFile(path: string): Promise<Buffer> {
41
+ async getFile(path: string): Promise<ArrayBuffer> {
39
42
  // sometimes paths are not in lower case when hash file is created,
40
43
  // so first we're looking for lower case file name and then for original one
41
44
  let data = await this.getFileBytes(path.toLocaleLowerCase());
@@ -43,11 +46,10 @@ export class TZ3Archive {
43
46
  data = await this.getFileBytes(path);
44
47
  }
45
48
  if (!data) {
46
- throw new Error('No such file in the archieve');
49
+ throw new Error('No such file in the archive');
47
50
  }
48
- const decompressedFile = Buffer.from(data);
49
51
 
50
- return decompressedFile;
52
+ return data;
51
53
  }
52
54
 
53
55
  /**
@@ -62,12 +64,12 @@ export class TZ3Archive {
62
64
  return null;
63
65
  }
64
66
 
65
- const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.tz3Archive);
67
+ const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.fileProvider);
66
68
  if (!localFileHeader) {
67
69
  return null;
68
70
  }
69
71
 
70
- const compressedFile = await this.tz3Archive.slice(
72
+ const compressedFile = await this.fileProvider.slice(
71
73
  localFileHeader.fileDataOffset,
72
74
  localFileHeader.fileDataOffset + localFileHeader.compressedSize
73
75
  );
@@ -8,7 +8,7 @@ import {
8
8
  parseZipLocalFileHeader,
9
9
  searchFromTheEnd
10
10
  } from '@loaders.gl/zip';
11
- import {TZ3Archive} from './tz3-archive';
11
+ import {Tiles3DArchive} from './3d-tiles-archive-archive';
12
12
 
13
13
  /**
14
14
  * Creates 3tz file handler from raw file
@@ -16,10 +16,10 @@ import {TZ3Archive} from './tz3-archive';
16
16
  * @param cb is called with information message during parsing
17
17
  * @returns 3tz file handler
18
18
  */
19
- export const parse3tz = async (
19
+ export const parse3DTilesArchive = async (
20
20
  fileProvider: FileProvider,
21
21
  cb?: (msg: string) => void
22
- ): Promise<TZ3Archive> => {
22
+ ): Promise<Tiles3DArchive> => {
23
23
  const hashCDOffset = await searchFromTheEnd(fileProvider, cdHeaderSignature);
24
24
 
25
25
  const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
@@ -48,5 +48,5 @@ export const parse3tz = async (
48
48
  hashData = parseHashFile(hashFile);
49
49
  }
50
50
 
51
- return new TZ3Archive(fileProvider, hashData);
51
+ return new Tiles3DArchive(fileProvider, hashData);
52
52
  };
@@ -0,0 +1,47 @@
1
+ import {LoaderOptions, LoaderWithParser} from '@loaders.gl/loader-utils';
2
+ import {DataViewFile} from '@loaders.gl/zip';
3
+ import {parse3DTilesArchive as parse3DTilesArchiveFromProvider} from './3d-tiles-archive/3d-tiles-archive-parser';
4
+
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
+
9
+ /** options to load data from 3tz */
10
+ export type Tiles3DArchiveFileLoaderOptions = LoaderOptions & {
11
+ '3d-tiles-archive'?: {
12
+ /** path inside the 3tz archive */
13
+ path?: string;
14
+ };
15
+ };
16
+
17
+ /**
18
+ * Loader for 3tz packages
19
+ */
20
+ export const Tiles3DArchiveFileLoader: LoaderWithParser<
21
+ ArrayBuffer,
22
+ never,
23
+ Tiles3DArchiveFileLoaderOptions
24
+ > = {
25
+ name: '3tz',
26
+ id: '3tz',
27
+ module: '3d-tiles',
28
+ version: VERSION,
29
+ mimeTypes: ['application/octet-stream', 'application/vnd.maxar.archive.3tz+zip'],
30
+ parse: parse3DTilesArchive,
31
+ extensions: ['3tz'],
32
+ options: {}
33
+ };
34
+
35
+ /**
36
+ * returns a single file from the 3tz archive
37
+ * @param data 3tz archive data
38
+ * @param options options
39
+ * @returns requested file
40
+ */
41
+ async function parse3DTilesArchive(
42
+ data: ArrayBuffer,
43
+ options: Tiles3DArchiveFileLoaderOptions = {}
44
+ ): Promise<ArrayBuffer> {
45
+ const archive = await parse3DTilesArchiveFromProvider(new DataViewFile(new DataView(data)));
46
+ return archive.getFile(options['3d-tiles-archive']?.path ?? '');
47
+ }
package/src/index.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  export {Tiles3DLoader} from './tiles-3d-loader';
3
3
  export {CesiumIonLoader} from './cesium-ion-loader';
4
4
  export {Tile3DSubtreeLoader} from './tile-3d-subtree-loader';
5
- export type {TZ3LoaderOptions} from './tz3-loader';
6
- export {TZ3Loader} from './tz3-loader';
5
+ export type {Tiles3DArchiveFileLoaderOptions} from './3d-tiles-archive-loader';
6
+ export {Tiles3DArchiveFileLoader} from './3d-tiles-archive-loader';
7
+ export {Tiles3DArchiveFileSystem} from './lib/filesystems/tiles-3d-archive-file-system';
7
8
 
8
9
  // WRITERS
9
10
  export {Tile3DWriter} from './tile-3d-writer';
@@ -0,0 +1,97 @@
1
+ import {
2
+ FileProvider,
3
+ ZipFileSystem,
4
+ cdSignature as cdHeaderSignature,
5
+ searchFromTheEnd,
6
+ parseZipCDFileHeader,
7
+ HashElement,
8
+ parseHashFile,
9
+ parseZipLocalFileHeader
10
+ } from '@loaders.gl/zip';
11
+ import {Tiles3DArchive} from '../../3d-tiles-archive/3d-tiles-archive-archive';
12
+
13
+ /**
14
+ * FileSystem adapter for a 3tz (3D tiles archive format) file
15
+ * Holds FileProvider object that provides random access to archived files.
16
+ * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
17
+ * access speed to archived files
18
+ * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
19
+ */
20
+ export class Tiles3DArchiveFileSystem extends ZipFileSystem {
21
+ hashData?: HashElement[] | null;
22
+
23
+ /**
24
+ * Constructor
25
+ * @param file - instance of FileProvider or file path string
26
+ */
27
+ constructor(file: FileProvider | string) {
28
+ super(file);
29
+ }
30
+
31
+ /**
32
+ * Implementation of fetch against this file system.
33
+ * It tries to take `@3dtilesIndex1@` file from the archive and use it
34
+ * for faster access to archived files
35
+ * @param filename - name of a file
36
+ * @returns - Response with file data
37
+ */
38
+ async fetch(filename: string): Promise<Response> {
39
+ const fileProvider = await this.fileProvider;
40
+ if (!fileProvider) {
41
+ throw new Error('No data detected in the zip archive');
42
+ }
43
+ await this.parseHashFile();
44
+ if (this.hashData) {
45
+ const archive = new Tiles3DArchive(fileProvider, this.hashData);
46
+
47
+ const fileData = await archive.getFile(filename);
48
+ const response = new Response(fileData);
49
+ Object.defineProperty(response, 'url', {value: `${this.fileName || ''}/${filename}`});
50
+ return response;
51
+ }
52
+ return super.fetch(filename);
53
+ }
54
+
55
+ /**
56
+ * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
57
+ * to files inside the archive
58
+ * @returns void
59
+ */
60
+ private async parseHashFile(): Promise<void> {
61
+ if (this.hashData !== undefined) {
62
+ return;
63
+ }
64
+
65
+ const fileProvider = await this.fileProvider;
66
+ if (!fileProvider) {
67
+ throw new Error('No data detected in the zip archive');
68
+ }
69
+
70
+ const hashCDOffset = await searchFromTheEnd(fileProvider, cdHeaderSignature);
71
+
72
+ const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
73
+
74
+ // '@3dtilesIndex1@' is index file that must be the last in the archive. It allows
75
+ // to improve load and read performance when the archive contains a very large number
76
+ // of files.
77
+ if (cdFileHeader?.fileName === '@3dtilesIndex1@') {
78
+ const localFileHeader = await parseZipLocalFileHeader(
79
+ cdFileHeader.localHeaderOffset,
80
+ fileProvider
81
+ );
82
+ if (!localFileHeader) {
83
+ throw new Error('corrupted 3tz');
84
+ }
85
+
86
+ const fileDataOffset = localFileHeader.fileDataOffset;
87
+ const hashFile = await fileProvider.slice(
88
+ fileDataOffset,
89
+ fileDataOffset + localFileHeader.compressedSize
90
+ );
91
+
92
+ this.hashData = parseHashFile(hashFile);
93
+ } else {
94
+ this.hashData = null;
95
+ }
96
+ }
97
+ }
@@ -8,7 +8,7 @@
8
8
  // - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?
9
9
 
10
10
  import {GLTFLoader, postProcessGLTF, _getMemoryUsageGLTF} from '@loaders.gl/gltf';
11
- import {LoaderContext, sliceArrayBuffer} from '@loaders.gl/loader-utils';
11
+ import {LoaderContext, sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';
12
12
  import {Tiles3DTileContent} from '../../../types';
13
13
  import {Tiles3DLoaderOptions} from '../../../tiles-3d-loader';
14
14
 
@@ -74,15 +74,20 @@ export async function extractGLTF(
74
74
  if (!context) {
75
75
  return;
76
76
  }
77
- const {parse, fetch} = context;
78
77
  if (tile.gltfUrl) {
78
+ const {fetch} = context;
79
79
  const response = await fetch(tile.gltfUrl, options);
80
80
  tile.gltfArrayBuffer = await response.arrayBuffer();
81
81
  tile.gltfByteOffset = 0;
82
82
  }
83
83
  if (tile.gltfArrayBuffer) {
84
84
  // TODO - Should handle byteOffset... However, not used now...
85
- const gltfWithBuffers = await parse(tile.gltfArrayBuffer, GLTFLoader, options, context);
85
+ const gltfWithBuffers = await parseFromContext(
86
+ tile.gltfArrayBuffer,
87
+ GLTFLoader,
88
+ options,
89
+ context
90
+ );
86
91
  tile.gltf = postProcessGLTF(gltfWithBuffers);
87
92
  tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);
88
93
  delete tile.gltfArrayBuffer;
@@ -1,6 +1,8 @@
1
- import type {LoaderContext} from '@loaders.gl/loader-utils';
2
- import type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
1
+ // loaders.gl, MIT license
2
+
3
+ import {parseFromContext, LoaderContext} from '@loaders.gl/loader-utils';
3
4
  import {_getMemoryUsageGLTF, GLTFLoader, postProcessGLTF} from '@loaders.gl/gltf';
5
+ import type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
4
6
  import {Tiles3DTileContent} from '../../types';
5
7
 
6
8
  export async function parseGltf3DTile(
@@ -14,17 +16,15 @@ export async function parseGltf3DTile(
14
16
  // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
15
17
  tile.rotateYtoZ = true;
16
18
  // Save gltf up axis
17
- tile.gltfUpAxis =
18
- options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
19
- ? options['3d-tiles'].assetGltfUpAxis
20
- : 'Y';
19
+ tile.gltfUpAxis = options?.['3d-tiles']?.assetGltfUpAxis
20
+ ? options['3d-tiles'].assetGltfUpAxis
21
+ : 'Y';
21
22
 
22
23
  if (options?.['3d-tiles']?.loadGLTF) {
23
24
  if (!context) {
24
25
  return;
25
26
  }
26
- const {parse} = context;
27
- const gltfWithBuffers = await parse(arrayBuffer, GLTFLoader, options, context);
27
+ const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
28
28
  tile.gltf = postProcessGLTF(gltfWithBuffers);
29
29
  tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);
30
30
  } else {
@@ -1,5 +1,6 @@
1
1
  import type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';
2
2
  import type {LoaderOptions} from '@loaders.gl/loader-utils';
3
+ import {path} from '@loaders.gl/loader-utils';
3
4
  import {Tile3DSubtreeLoader} from '../../tile-3d-subtree-loader';
4
5
  import {load} from '@loaders.gl/core';
5
6
  import {LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE} from '@loaders.gl/tiles';
@@ -89,7 +90,7 @@ function resolveUri(uri: string = '', basePath: string): string {
89
90
  return uri;
90
91
  }
91
92
 
92
- return `${basePath}/${uri}`;
93
+ return path.resolve(basePath, uri);
93
94
  }
94
95
 
95
96
  export function normalizeTileData(