@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
package/dist/dist.min.js CHANGED
@@ -29,6 +29,15 @@
29
29
  return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
30
30
  };
31
31
 
32
+ // ../loader-utils/src/loader-types.ts
33
+ async function parseFromContext(data, loaders, options, context) {
34
+ return context._parse(data, loaders, options, context);
35
+ }
36
+ var init_loader_types = __esm({
37
+ "../loader-utils/src/loader-types.ts"() {
38
+ }
39
+ });
40
+
32
41
  // ../loader-utils/src/lib/env-utils/assert.ts
33
42
  function assert2(condition, message) {
34
43
  if (!condition) {
@@ -1181,9 +1190,16 @@
1181
1190
  }
1182
1191
  });
1183
1192
 
1193
+ // (disabled):fs
1194
+ var require_fs = __commonJS({
1195
+ "(disabled):fs"() {
1196
+ }
1197
+ });
1198
+
1184
1199
  // ../loader-utils/src/index.ts
1185
1200
  var init_src2 = __esm({
1186
1201
  "../loader-utils/src/index.ts"() {
1202
+ init_loader_types();
1187
1203
  init_assert();
1188
1204
  init_globals();
1189
1205
  init_parse_with_worker();
@@ -6257,6 +6273,11 @@
6257
6273
  loaders._state = loaders._state || {};
6258
6274
  return loaders._state;
6259
6275
  }
6276
+ function getGlobalLoaderOptions() {
6277
+ const state = getGlobalLoaderState();
6278
+ state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6279
+ return state.globalOptions;
6280
+ }
6260
6281
  function normalizeOptions(options, loader, loaders, url) {
6261
6282
  loaders = loaders || [];
6262
6283
  loaders = Array.isArray(loaders) ? loaders : [loaders];
@@ -6337,17 +6358,11 @@
6337
6358
  options.baseUri = url;
6338
6359
  }
6339
6360
  }
6340
- var getGlobalLoaderOptions;
6341
6361
  var init_option_utils = __esm({
6342
6362
  "../core/src/lib/loader-utils/option-utils.ts"() {
6343
6363
  init_is_type();
6344
6364
  init_loggers();
6345
6365
  init_option_defaults();
6346
- getGlobalLoaderOptions = () => {
6347
- const state = getGlobalLoaderState();
6348
- state.globalOptions = state.globalOptions || { ...DEFAULT_LOADER_OPTIONS };
6349
- return state.globalOptions;
6350
- };
6351
6366
  }
6352
6367
  });
6353
6368
 
@@ -6468,8 +6483,10 @@
6468
6483
  reason = reason || (loader ? `matched MIME type ${type}` : "");
6469
6484
  loader = loader || findLoaderByInitialBytes(loaders, data);
6470
6485
  reason = reason || (loader ? `matched initial data ${getFirstCharacters2(data)}` : "");
6471
- loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6472
- reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6486
+ if (options?.fallbackMimeType) {
6487
+ loader = loader || findLoaderByMIMEType(loaders, options?.fallbackMimeType);
6488
+ reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6489
+ }
6473
6490
  if (reason) {
6474
6491
  log.log(1, `selectLoader selected ${loader?.name}: ${reason}.`);
6475
6492
  }
@@ -6565,7 +6582,7 @@
6565
6582
  }
6566
6583
  switch (typeof test) {
6567
6584
  case "function":
6568
- return test(data, loader);
6585
+ return test(data);
6569
6586
  case "string":
6570
6587
  const magic = getMagicString2(data, byteOffset, test.length);
6571
6588
  return test === magic;
@@ -6838,7 +6855,7 @@
6838
6855
  return newContext;
6839
6856
  }
6840
6857
  function getLoadersFromContext(loaders, context) {
6841
- if (!context && loaders && !Array.isArray(loaders)) {
6858
+ if (loaders && !Array.isArray(loaders)) {
6842
6859
  return loaders;
6843
6860
  }
6844
6861
  let candidateLoaders;
@@ -6849,7 +6866,7 @@
6849
6866
  const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
6850
6867
  candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
6851
6868
  }
6852
- return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
6869
+ return candidateLoaders && candidateLoaders.length ? candidateLoaders : void 0;
6853
6870
  }
6854
6871
  var init_loader_context = __esm({
6855
6872
  "../core/src/lib/loader-utils/loader-context.ts"() {
@@ -6861,7 +6878,6 @@
6861
6878
 
6862
6879
  // ../core/src/lib/api/parse.ts
6863
6880
  async function parse(data, loaders, options, context) {
6864
- assert3(!context || typeof context === "object");
6865
6881
  if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
6866
6882
  context = void 0;
6867
6883
  options = loaders;
@@ -6877,7 +6893,7 @@
6877
6893
  return null;
6878
6894
  }
6879
6895
  options = normalizeOptions(options, loader, candidateLoaders, url);
6880
- context = getLoaderContext({ url, parse, loaders: candidateLoaders }, options, context || null);
6896
+ context = getLoaderContext({ url, _parse: parse, loaders: candidateLoaders }, options, context || null);
6881
6897
  return await parseWithLoader(loader, data, options, context);
6882
6898
  }
6883
6899
  async function parseWithLoader(loader, data, options, context) {
@@ -6955,6 +6971,7 @@
6955
6971
  "../core/src/index.ts"() {
6956
6972
  init_fetch_file();
6957
6973
  init_load();
6974
+ init_src2();
6958
6975
  }
6959
6976
  });
6960
6977
 
@@ -8823,7 +8840,6 @@
8823
8840
  if (!context) {
8824
8841
  return;
8825
8842
  }
8826
- const { parse: parse5 } = context;
8827
8843
  const dracoOptions = {
8828
8844
  ...options,
8829
8845
  draco: {
@@ -8832,7 +8848,7 @@
8832
8848
  }
8833
8849
  };
8834
8850
  delete dracoOptions["3d-tiles"];
8835
- const data = await parse5(dracoData.buffer, DracoLoader2, dracoOptions);
8851
+ const data = await parseFromContext(dracoData.buffer, DracoLoader2, dracoOptions, context);
8836
8852
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
8837
8853
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
8838
8854
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
@@ -8870,6 +8886,7 @@
8870
8886
  var init_parse_3d_tile_point_cloud = __esm({
8871
8887
  "src/lib/parsers/parse-3d-tile-point-cloud.ts"() {
8872
8888
  init_src6();
8889
+ init_src2();
8873
8890
  init_src7();
8874
8891
  init_esm();
8875
8892
  init_tile_3d_feature_table();
@@ -10932,10 +10949,9 @@
10932
10949
  }
10933
10950
  const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView);
10934
10951
  const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
10935
- const { parse: parse5 } = context;
10936
10952
  const dracoOptions = { ...options };
10937
10953
  delete dracoOptions["3d-tiles"];
10938
- const decodedData = await parse5(bufferCopy, DracoLoader2, dracoOptions, context);
10954
+ const decodedData = await parseFromContext(bufferCopy, DracoLoader2, dracoOptions, context);
10939
10955
  const decodedAttributes = getGLTFAccessors(decodedData.attributes);
10940
10956
  for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
10941
10957
  if (attributeName in primitive.attributes) {
@@ -10993,8 +11009,8 @@
10993
11009
  var KHR_DRACO_MESH_COMPRESSION, name4;
10994
11010
  var init_KHR_draco_mesh_compression = __esm({
10995
11011
  "../gltf/src/lib/extensions/KHR_draco_mesh_compression.ts"() {
10996
- init_src6();
10997
11012
  init_src2();
11013
+ init_src6();
10998
11014
  init_gltf_scenegraph();
10999
11015
  init_gltf_attribute_utils();
11000
11016
  KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression";
@@ -11920,10 +11936,10 @@
11920
11936
  return Array.from(imageIndices).sort();
11921
11937
  }
11922
11938
  async function loadImage(gltf, image, index, options, context) {
11923
- const { fetch: fetch2, parse: parse5 } = context;
11924
11939
  let arrayBuffer;
11925
11940
  if (image.uri && !image.hasOwnProperty("bufferView")) {
11926
11941
  const uri = resolveUrl(image.uri, options);
11942
+ const { fetch: fetch2 } = context;
11927
11943
  const response = await fetch2(uri);
11928
11944
  arrayBuffer = await response.arrayBuffer();
11929
11945
  image.bufferView = {
@@ -11935,7 +11951,7 @@
11935
11951
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
11936
11952
  }
11937
11953
  assert7(arrayBuffer, "glTF image has no data");
11938
- let parsedImage = await parse5(arrayBuffer, [ImageLoader, BasisLoader], {
11954
+ let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], {
11939
11955
  ...options,
11940
11956
  mimeType: image.mimeType,
11941
11957
  basis: options.basis || { format: selectSupportedBasisFormat() }
@@ -12420,14 +12436,14 @@
12420
12436
  if (!context) {
12421
12437
  return;
12422
12438
  }
12423
- const { parse: parse5, fetch: fetch2 } = context;
12424
12439
  if (tile.gltfUrl) {
12440
+ const { fetch: fetch2 } = context;
12425
12441
  const response = await fetch2(tile.gltfUrl, options);
12426
12442
  tile.gltfArrayBuffer = await response.arrayBuffer();
12427
12443
  tile.gltfByteOffset = 0;
12428
12444
  }
12429
12445
  if (tile.gltfArrayBuffer) {
12430
- const gltfWithBuffers = await parse5(tile.gltfArrayBuffer, GLTFLoader, options, context);
12446
+ const gltfWithBuffers = await parseFromContext(tile.gltfArrayBuffer, GLTFLoader, options, context);
12431
12447
  tile.gltf = postProcessGLTF(gltfWithBuffers);
12432
12448
  tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
12433
12449
  delete tile.gltfArrayBuffer;
@@ -12661,13 +12677,12 @@
12661
12677
  // src/lib/parsers/parse-3d-tile-gltf.ts
12662
12678
  async function parseGltf3DTile(tile, arrayBuffer, options, context) {
12663
12679
  tile.rotateYtoZ = true;
12664
- tile.gltfUpAxis = options?.["3d-tiles"] && options["3d-tiles"].assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
12680
+ tile.gltfUpAxis = options?.["3d-tiles"]?.assetGltfUpAxis ? options["3d-tiles"].assetGltfUpAxis : "Y";
12665
12681
  if (options?.["3d-tiles"]?.loadGLTF) {
12666
12682
  if (!context) {
12667
12683
  return;
12668
12684
  }
12669
- const { parse: parse5 } = context;
12670
- const gltfWithBuffers = await parse5(arrayBuffer, GLTFLoader, options, context);
12685
+ const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
12671
12686
  tile.gltf = postProcessGLTF(gltfWithBuffers);
12672
12687
  tile.gpuMemoryUsageInBytes = getMemoryUsageGLTF(tile.gltf);
12673
12688
  } else {
@@ -12676,6 +12691,7 @@
12676
12691
  }
12677
12692
  var init_parse_3d_tile_gltf = __esm({
12678
12693
  "src/lib/parsers/parse-3d-tile-gltf.ts"() {
12694
+ init_src2();
12679
12695
  init_src10();
12680
12696
  }
12681
12697
  });
@@ -14903,7 +14919,7 @@
14903
14919
  } else if (uri.startsWith("/")) {
14904
14920
  return uri;
14905
14921
  }
14906
- return `${basePath}/${uri}`;
14922
+ return path_exports.resolve(basePath, uri);
14907
14923
  }
14908
14924
  function normalizeTileData(tile, basePath) {
14909
14925
  if (!tile) {
@@ -15028,6 +15044,7 @@
15028
15044
  }
15029
15045
  var init_parse_3d_tile_header2 = __esm({
15030
15046
  "src/lib/parsers/parse-3d-tile-header.ts"() {
15047
+ init_src2();
15031
15048
  init_tile_3d_subtree_loader();
15032
15049
  init_src3();
15033
15050
  init_src4();
@@ -15201,6 +15218,105 @@
15201
15218
  }
15202
15219
  });
15203
15220
 
15221
+ // ../zip/src/file-provider/file-handle.ts
15222
+ var import_fs, _FileHandle, FileHandle;
15223
+ var init_file_handle = __esm({
15224
+ "../zip/src/file-provider/file-handle.ts"() {
15225
+ import_fs = __toModule(require_fs());
15226
+ _FileHandle = class {
15227
+ constructor(fileDescriptor, stats) {
15228
+ this.read = (buffer, offset, length4, position) => {
15229
+ return new Promise((s2) => {
15230
+ (0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
15231
+ });
15232
+ };
15233
+ this.fileDescriptor = fileDescriptor;
15234
+ this.stats = stats;
15235
+ }
15236
+ async close() {
15237
+ return new Promise((resolve2) => {
15238
+ (0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
15239
+ });
15240
+ }
15241
+ get stat() {
15242
+ return this.stats;
15243
+ }
15244
+ };
15245
+ FileHandle = _FileHandle;
15246
+ FileHandle.open = async (path) => {
15247
+ const [fd, stats] = await Promise.all([
15248
+ new Promise((s2) => {
15249
+ (0, import_fs.open)(path, void 0, void 0, (_err, fd2) => s2(fd2));
15250
+ }),
15251
+ new Promise((s2) => {
15252
+ (0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => s2(stats2));
15253
+ })
15254
+ ]);
15255
+ return new _FileHandle(fd, stats);
15256
+ };
15257
+ }
15258
+ });
15259
+
15260
+ // ../zip/src/file-provider/file-handle-file.ts
15261
+ var FileHandleFile;
15262
+ var init_file_handle_file = __esm({
15263
+ "../zip/src/file-provider/file-handle-file.ts"() {
15264
+ init_file_handle();
15265
+ FileHandleFile = class {
15266
+ static async from(path) {
15267
+ const fileDescriptor = await FileHandle.open(path);
15268
+ return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
15269
+ }
15270
+ constructor(fileDescriptor, size) {
15271
+ this.fileDescriptor = fileDescriptor;
15272
+ this.size = size;
15273
+ }
15274
+ async destroy() {
15275
+ await this.fileDescriptor.close();
15276
+ }
15277
+ async getUint8(offset) {
15278
+ const val = new Uint8Array((await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer).at(0);
15279
+ if (val === void 0) {
15280
+ throw new Error("something went wrong");
15281
+ }
15282
+ return val;
15283
+ }
15284
+ async getUint16(offset) {
15285
+ const val = new Uint16Array((await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer).at(0);
15286
+ if (val === void 0) {
15287
+ throw new Error("something went wrong");
15288
+ }
15289
+ return val;
15290
+ }
15291
+ async getUint32(offset) {
15292
+ const val = new Uint32Array((await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer).at(0);
15293
+ if (val === void 0) {
15294
+ throw new Error("something went wrong");
15295
+ }
15296
+ return val;
15297
+ }
15298
+ async getBigUint64(offset) {
15299
+ const val = new BigInt64Array((await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer).at(0);
15300
+ if (val === void 0) {
15301
+ throw new Error("something went wrong");
15302
+ }
15303
+ return val;
15304
+ }
15305
+ async slice(startOffsset, endOffset) {
15306
+ const bigLength = endOffset - startOffsset;
15307
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
15308
+ throw new Error("too big slice");
15309
+ }
15310
+ const length4 = Number(bigLength);
15311
+ return (await this.fileDescriptor.read(Buffer.alloc(length4), 0, length4, startOffsset)).buffer.buffer;
15312
+ }
15313
+ get length() {
15314
+ return this.size;
15315
+ }
15316
+ };
15317
+ }
15318
+ });
15319
+
15204
15320
  // ../zip/src/file-provider/data-view-file.ts
15205
15321
  var toNumber2, DataViewFile;
15206
15322
  var init_data_view_file = __esm({
@@ -15707,14 +15823,13 @@
15707
15823
  }
15708
15824
  });
15709
15825
 
15710
- // ../zip/src/index.ts
15711
- var init_src11 = __esm({
15712
- "../zip/src/index.ts"() {
15713
- init_data_view_file();
15714
- init_cd_file_header();
15715
- init_local_file_header();
15716
- init_search_from_the_end();
15717
- init_hash_file_utility();
15826
+ // ../zip/src/file-provider/file-provider.ts
15827
+ var isFileProvider;
15828
+ var init_file_provider = __esm({
15829
+ "../zip/src/file-provider/file-provider.ts"() {
15830
+ isFileProvider = (fileProvider) => {
15831
+ return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
15832
+ };
15718
15833
  }
15719
15834
  });
15720
15835
 
@@ -15766,6 +15881,36 @@
15766
15881
  }
15767
15882
  });
15768
15883
 
15884
+ // ../compression/src/lib/no-compression.ts
15885
+ var NoCompression;
15886
+ var init_no_compression = __esm({
15887
+ "../compression/src/lib/no-compression.ts"() {
15888
+ init_compression();
15889
+ NoCompression = class extends Compression {
15890
+ constructor(options) {
15891
+ super(options);
15892
+ this.name = "uncompressed";
15893
+ this.extensions = [];
15894
+ this.contentEncodings = [];
15895
+ this.isSupported = true;
15896
+ this.options = options || {};
15897
+ }
15898
+ compressSync(input) {
15899
+ return input;
15900
+ }
15901
+ decompressSync(input) {
15902
+ return input;
15903
+ }
15904
+ async *compressBatches(asyncIterator) {
15905
+ return yield* asyncIterator;
15906
+ }
15907
+ async *decompressBatches(asyncIterator) {
15908
+ return yield* asyncIterator;
15909
+ }
15910
+ };
15911
+ }
15912
+ });
15913
+
15769
15914
  // ../../node_modules/pako/lib/utils/common.js
15770
15915
  var require_common = __commonJS({
15771
15916
  "../../node_modules/pako/lib/utils/common.js"(exports) {
@@ -19984,19 +20129,23 @@
19984
20129
  });
19985
20130
 
19986
20131
  // ../compression/src/index.ts
19987
- var init_src12 = __esm({
20132
+ var init_src11 = __esm({
19988
20133
  "../compression/src/index.ts"() {
20134
+ init_no_compression();
19989
20135
  init_deflate_compression();
19990
20136
  }
19991
20137
  });
19992
20138
 
19993
- // src/tz3/tz3-archive.ts
19994
- var import_md52, COMPRESSION_METHODS, TZ3Archive;
19995
- var init_tz3_archive = __esm({
19996
- "src/tz3/tz3-archive.ts"() {
19997
- import_md52 = __toModule(require_md5());
20139
+ // ../zip/src/filesystems/zip-filesystem.ts
20140
+ var COMPRESSION_METHODS, ZipFileSystem;
20141
+ var init_zip_filesystem = __esm({
20142
+ "../zip/src/filesystems/zip-filesystem.ts"() {
20143
+ init_src3();
20144
+ init_file_provider();
20145
+ init_file_handle_file();
20146
+ init_cd_file_header();
20147
+ init_local_file_header();
19998
20148
  init_src11();
19999
- init_src12();
20000
20149
  COMPRESSION_METHODS = {
20001
20150
  0: async (compressedFile) => compressedFile,
20002
20151
  8: async (compressedFile) => {
@@ -20005,9 +20154,110 @@
20005
20154
  return decompressedData;
20006
20155
  }
20007
20156
  };
20008
- TZ3Archive = class {
20009
- constructor(tz3Archive, hashFile) {
20010
- this.tz3Archive = tz3Archive;
20157
+ ZipFileSystem = class {
20158
+ constructor(file) {
20159
+ this.fileProvider = Promise.resolve(null);
20160
+ if (typeof file === "string") {
20161
+ this.fileName = file;
20162
+ if (!isBrowser) {
20163
+ this.fileProvider = FileHandleFile.from(file);
20164
+ } else {
20165
+ throw new Error("Cannot open file for random access in a WEB browser");
20166
+ }
20167
+ } else if (isFileProvider(file)) {
20168
+ this.fileProvider = Promise.resolve(file);
20169
+ }
20170
+ }
20171
+ async destroy() {
20172
+ const fileProvider = await this.fileProvider;
20173
+ if (fileProvider) {
20174
+ await fileProvider.destroy();
20175
+ }
20176
+ }
20177
+ async readdir() {
20178
+ const fileProvider = await this.fileProvider;
20179
+ if (!fileProvider) {
20180
+ throw new Error("No data detected in the zip archive");
20181
+ }
20182
+ const fileNames = [];
20183
+ const zipCDIterator = zipCDFileHeaderGenerator(fileProvider);
20184
+ for await (const cdHeader of zipCDIterator) {
20185
+ fileNames.push(cdHeader.fileName);
20186
+ }
20187
+ return fileNames;
20188
+ }
20189
+ async stat(filename2) {
20190
+ const cdFileHeader = await this.getCDFileHeader(filename2);
20191
+ return { ...cdFileHeader, size: Number(cdFileHeader.uncompressedSize) };
20192
+ }
20193
+ async fetch(filename2) {
20194
+ const fileProvider = await this.fileProvider;
20195
+ if (!fileProvider) {
20196
+ throw new Error("No data detected in the zip archive");
20197
+ }
20198
+ const cdFileHeader = await this.getCDFileHeader(filename2);
20199
+ const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
20200
+ if (!localFileHeader) {
20201
+ throw new Error("Local file header has not been found in the zip archive`");
20202
+ }
20203
+ const compressionHandler = COMPRESSION_METHODS[localFileHeader.compressionMethod.toString()];
20204
+ if (!compressionHandler) {
20205
+ throw Error("Only Deflation compression is supported");
20206
+ }
20207
+ const compressedFile = await fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20208
+ const uncompressedFile = await compressionHandler(compressedFile);
20209
+ const response = new Response(uncompressedFile);
20210
+ Object.defineProperty(response, "url", { value: `${this.fileName || ""}/${filename2}` });
20211
+ return response;
20212
+ }
20213
+ async getCDFileHeader(filename2) {
20214
+ const fileProvider = await this.fileProvider;
20215
+ if (!fileProvider) {
20216
+ throw new Error("No data detected in the zip archive");
20217
+ }
20218
+ const zipCDIterator = zipCDFileHeaderGenerator(fileProvider);
20219
+ let result = null;
20220
+ for await (const cdHeader of zipCDIterator) {
20221
+ if (cdHeader.fileName === filename2) {
20222
+ result = cdHeader;
20223
+ break;
20224
+ }
20225
+ }
20226
+ if (!result) {
20227
+ throw new Error("File has not been found in the zip archive");
20228
+ }
20229
+ return result;
20230
+ }
20231
+ };
20232
+ }
20233
+ });
20234
+
20235
+ // ../zip/src/index.ts
20236
+ var init_src12 = __esm({
20237
+ "../zip/src/index.ts"() {
20238
+ init_data_view_file();
20239
+ init_cd_file_header();
20240
+ init_local_file_header();
20241
+ init_search_from_the_end();
20242
+ init_hash_file_utility();
20243
+ init_zip_filesystem();
20244
+ }
20245
+ });
20246
+
20247
+ // src/3d-tiles-archive/3d-tiles-archive-archive.ts
20248
+ var import_md52, COMPRESSION_METHODS2, Tiles3DArchive;
20249
+ var init_d_tiles_archive_archive = __esm({
20250
+ "src/3d-tiles-archive/3d-tiles-archive-archive.ts"() {
20251
+ import_md52 = __toModule(require_md5());
20252
+ init_src12();
20253
+ init_src11();
20254
+ COMPRESSION_METHODS2 = {
20255
+ 0: (data) => new NoCompression().decompress(data),
20256
+ 8: (data) => new DeflateCompression({ raw: true }).decompress(data)
20257
+ };
20258
+ Tiles3DArchive = class {
20259
+ constructor(fileProvider, hashFile) {
20260
+ this.fileProvider = fileProvider;
20011
20261
  this.hashArray = hashFile;
20012
20262
  }
20013
20263
  async getFile(path) {
@@ -20016,10 +20266,9 @@
20016
20266
  data = await this.getFileBytes(path);
20017
20267
  }
20018
20268
  if (!data) {
20019
- throw new Error("No such file in the archieve");
20269
+ throw new Error("No such file in the archive");
20020
20270
  }
20021
- const decompressedFile = Buffer.from(data);
20022
- return decompressedFile;
20271
+ return data;
20023
20272
  }
20024
20273
  async getFileBytes(path) {
20025
20274
  const nameHash = Buffer.from((0, import_md52.default)(path), "hex");
@@ -20027,12 +20276,12 @@
20027
20276
  if (!fileInfo) {
20028
20277
  return null;
20029
20278
  }
20030
- const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.tz3Archive);
20279
+ const localFileHeader = await parseZipLocalFileHeader(fileInfo.offset, this.fileProvider);
20031
20280
  if (!localFileHeader) {
20032
20281
  return null;
20033
20282
  }
20034
- const compressedFile = await this.tz3Archive.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20035
- const compressionMethod = COMPRESSION_METHODS[localFileHeader.compressionMethod];
20283
+ const compressedFile = await this.fileProvider.slice(localFileHeader.fileDataOffset, localFileHeader.fileDataOffset + localFileHeader.compressedSize);
20284
+ const compressionMethod = COMPRESSION_METHODS2[localFileHeader.compressionMethod];
20036
20285
  if (!compressionMethod) {
20037
20286
  throw Error("Only Deflation compression is supported");
20038
20287
  }
@@ -20042,13 +20291,13 @@
20042
20291
  }
20043
20292
  });
20044
20293
 
20045
- // src/tz3/tz3-parser.ts
20046
- var parse3tz;
20047
- var init_tz3_parser = __esm({
20048
- "src/tz3/tz3-parser.ts"() {
20049
- init_src11();
20050
- init_tz3_archive();
20051
- parse3tz = async (fileProvider, cb) => {
20294
+ // src/3d-tiles-archive/3d-tiles-archive-parser.ts
20295
+ var parse3DTilesArchive;
20296
+ var init_d_tiles_archive_parser = __esm({
20297
+ "src/3d-tiles-archive/3d-tiles-archive-parser.ts"() {
20298
+ init_src12();
20299
+ init_d_tiles_archive_archive();
20300
+ parse3DTilesArchive = async (fileProvider, cb) => {
20052
20301
  const hashCDOffset = await searchFromTheEnd(fileProvider, signature);
20053
20302
  const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
20054
20303
  let hashData;
@@ -20066,34 +20315,86 @@
20066
20315
  const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
20067
20316
  hashData = parseHashFile(hashFile);
20068
20317
  }
20069
- return new TZ3Archive(fileProvider, hashData);
20318
+ return new Tiles3DArchive(fileProvider, hashData);
20070
20319
  };
20071
20320
  }
20072
20321
  });
20073
20322
 
20074
- // src/tz3-loader.ts
20075
- async function parse3tz2(data, options = {}) {
20076
- return (await parse3tz(new DataViewFile(new DataView(data)))).getFile(options.tz3?.path ?? "");
20323
+ // src/3d-tiles-archive-loader.ts
20324
+ async function parse3DTilesArchive2(data, options = {}) {
20325
+ const archive = await parse3DTilesArchive(new DataViewFile(new DataView(data)));
20326
+ return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
20077
20327
  }
20078
- var VERSION10, TZ3Loader;
20079
- var init_tz3_loader = __esm({
20080
- "src/tz3-loader.ts"() {
20081
- init_src11();
20082
- init_tz3_parser();
20328
+ var VERSION10, Tiles3DArchiveFileLoader;
20329
+ var init_d_tiles_archive_loader = __esm({
20330
+ "src/3d-tiles-archive-loader.ts"() {
20331
+ init_src12();
20332
+ init_d_tiles_archive_parser();
20083
20333
  VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
20084
- TZ3Loader = {
20334
+ Tiles3DArchiveFileLoader = {
20085
20335
  name: "3tz",
20086
20336
  id: "3tz",
20087
- module: "i3s",
20337
+ module: "3d-tiles",
20088
20338
  version: VERSION10,
20089
- mimeTypes: ["application/octet-stream"],
20090
- parse: parse3tz2,
20339
+ mimeTypes: ["application/octet-stream", "application/vnd.maxar.archive.3tz+zip"],
20340
+ parse: parse3DTilesArchive2,
20091
20341
  extensions: ["3tz"],
20092
20342
  options: {}
20093
20343
  };
20094
20344
  }
20095
20345
  });
20096
20346
 
20347
+ // src/lib/filesystems/tiles-3d-archive-file-system.ts
20348
+ var Tiles3DArchiveFileSystem;
20349
+ var init_tiles_3d_archive_file_system = __esm({
20350
+ "src/lib/filesystems/tiles-3d-archive-file-system.ts"() {
20351
+ init_src12();
20352
+ init_d_tiles_archive_archive();
20353
+ Tiles3DArchiveFileSystem = class extends ZipFileSystem {
20354
+ constructor(file) {
20355
+ super(file);
20356
+ }
20357
+ async fetch(filename2) {
20358
+ const fileProvider = await this.fileProvider;
20359
+ if (!fileProvider) {
20360
+ throw new Error("No data detected in the zip archive");
20361
+ }
20362
+ await this.parseHashFile();
20363
+ if (this.hashData) {
20364
+ const archive = new Tiles3DArchive(fileProvider, this.hashData);
20365
+ const fileData = await archive.getFile(filename2);
20366
+ const response = new Response(fileData);
20367
+ Object.defineProperty(response, "url", { value: `${this.fileName || ""}/${filename2}` });
20368
+ return response;
20369
+ }
20370
+ return super.fetch(filename2);
20371
+ }
20372
+ async parseHashFile() {
20373
+ if (this.hashData !== void 0) {
20374
+ return;
20375
+ }
20376
+ const fileProvider = await this.fileProvider;
20377
+ if (!fileProvider) {
20378
+ throw new Error("No data detected in the zip archive");
20379
+ }
20380
+ const hashCDOffset = await searchFromTheEnd(fileProvider, signature);
20381
+ const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);
20382
+ if (cdFileHeader?.fileName === "@3dtilesIndex1@") {
20383
+ const localFileHeader = await parseZipLocalFileHeader(cdFileHeader.localHeaderOffset, fileProvider);
20384
+ if (!localFileHeader) {
20385
+ throw new Error("corrupted 3tz");
20386
+ }
20387
+ const fileDataOffset = localFileHeader.fileDataOffset;
20388
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
20389
+ this.hashData = parseHashFile(hashFile);
20390
+ } else {
20391
+ this.hashData = null;
20392
+ }
20393
+ }
20394
+ };
20395
+ }
20396
+ });
20397
+
20097
20398
  // src/lib/encoders/helpers/encode-3d-tile-header.ts
20098
20399
  function encode3DTileHeader(tile, dataView, byteOffset) {
20099
20400
  const HEADER_SIZE = 12;
@@ -20320,11 +20621,12 @@
20320
20621
  __export(src_exports, {
20321
20622
  CesiumIonLoader: () => CesiumIonLoader,
20322
20623
  TILE3D_TYPE: () => TILE3D_TYPE,
20323
- TZ3Loader: () => TZ3Loader,
20324
20624
  Tile3DBatchTable: () => Tile3DBatchTableParser,
20325
20625
  Tile3DFeatureTable: () => Tile3DFeatureTable,
20326
20626
  Tile3DSubtreeLoader: () => Tile3DSubtreeLoader,
20327
20627
  Tile3DWriter: () => Tile3DWriter,
20628
+ Tiles3DArchiveFileLoader: () => Tiles3DArchiveFileLoader,
20629
+ Tiles3DArchiveFileSystem: () => Tiles3DArchiveFileSystem,
20328
20630
  Tiles3DLoader: () => Tiles3DLoader,
20329
20631
  _getIonTilesetMetadata: () => getIonTilesetMetadata
20330
20632
  });
@@ -20333,7 +20635,8 @@
20333
20635
  init_tiles_3d_loader();
20334
20636
  init_cesium_ion_loader();
20335
20637
  init_tile_3d_subtree_loader();
20336
- init_tz3_loader();
20638
+ init_d_tiles_archive_loader();
20639
+ init_tiles_3d_archive_file_system();
20337
20640
  init_tile_3d_writer();
20338
20641
  init_tile_3d_feature_table();
20339
20642
  init_tile_3d_batch_table();