@loaders.gl/tile-converter 4.0.0-alpha.18 → 4.0.0-alpha.20

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 (107) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/constants.d.ts +2 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +3 -1
  5. package/dist/converter-cli.js +10 -2
  6. package/dist/converter.min.js +172 -103
  7. package/dist/deps-installer/deps-installer.d.ts +3 -2
  8. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  9. package/dist/deps-installer/deps-installer.js +36 -10
  10. package/dist/dist.min.js +226 -151
  11. package/dist/es5/constants.js +5 -1
  12. package/dist/es5/constants.js.map +1 -1
  13. package/dist/es5/converter-cli.js +7 -2
  14. package/dist/es5/converter-cli.js.map +1 -1
  15. package/dist/es5/deps-installer/deps-installer.js +112 -38
  16. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
  18. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
  20. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/geometry-converter.js +78 -67
  22. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
  24. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  25. package/dist/es5/i3s-converter/i3s-converter.js +86 -99
  26. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  27. package/dist/es5/i3s-converter/types.js +11 -11
  28. package/dist/es5/i3s-converter/types.js.map +1 -1
  29. package/dist/es5/i3s-server/controllers/slpk-controller.js +1 -1
  30. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  31. package/dist/es5/index.js +3 -3
  32. package/dist/es5/index.js.map +1 -1
  33. package/dist/es5/pgm-loader.js +1 -1
  34. package/dist/es5/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +9 -9
  35. package/dist/es5/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  36. package/dist/es5/slpk-extractor/slpk-extractor.js +5 -5
  37. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  38. package/dist/esm/constants.js +2 -0
  39. package/dist/esm/constants.js.map +1 -1
  40. package/dist/esm/converter-cli.js +7 -2
  41. package/dist/esm/converter-cli.js.map +1 -1
  42. package/dist/esm/deps-installer/deps-installer.js +37 -11
  43. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  44. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
  45. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  46. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
  47. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  48. package/dist/esm/i3s-converter/helpers/geometry-converter.js +37 -25
  49. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  50. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
  51. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  52. package/dist/esm/i3s-converter/i3s-converter.js +49 -36
  53. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  54. package/dist/esm/i3s-converter/types.js +9 -9
  55. package/dist/esm/i3s-converter/types.js.map +1 -1
  56. package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
  57. package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
  58. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/pgm-loader.js +1 -1
  62. package/dist/esm/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +3 -3
  63. package/dist/esm/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  64. package/dist/esm/slpk-extractor/slpk-extractor.js +3 -3
  65. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  66. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
  67. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  68. package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
  69. package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
  70. package/dist/i3s-converter/helpers/geometry-converter.d.ts +7 -6
  71. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  72. package/dist/i3s-converter/helpers/geometry-converter.js +59 -47
  73. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
  74. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  75. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
  76. package/dist/i3s-converter/i3s-converter.d.ts +2 -1
  77. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  78. package/dist/i3s-converter/i3s-converter.js +49 -31
  79. package/dist/i3s-converter/types.d.ts +4 -2
  80. package/dist/i3s-converter/types.d.ts.map +1 -1
  81. package/dist/i3s-converter/types.js +11 -11
  82. package/dist/i3s-server/controllers/slpk-controller.js +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +3 -3
  86. package/dist/slpk-extractor/helpers/{file-handle-provider.d.ts → file-handle-file.d.ts} +5 -5
  87. package/dist/slpk-extractor/helpers/file-handle-file.d.ts.map +1 -0
  88. package/dist/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +5 -5
  89. package/dist/slpk-extractor/slpk-extractor.js +5 -5
  90. package/dist/slpk-extractor.min.js +32 -32
  91. package/package.json +15 -14
  92. package/src/constants.ts +3 -0
  93. package/src/converter-cli.ts +9 -2
  94. package/src/deps-installer/deps-installer.ts +55 -10
  95. package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
  96. package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
  97. package/src/i3s-converter/helpers/geometry-converter.ts +84 -48
  98. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
  99. package/src/i3s-converter/i3s-converter.ts +65 -39
  100. package/src/i3s-converter/types.ts +4 -2
  101. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  102. package/src/index.ts +1 -1
  103. package/src/slpk-extractor/helpers/{file-handle-provider.ts → file-handle-file.ts} +5 -5
  104. package/src/slpk-extractor/slpk-extractor.ts +3 -3
  105. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  106. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  107. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
package/dist/dist.min.js CHANGED
@@ -46551,7 +46551,7 @@ var require_es55 = __commonJS({
46551
46551
 
46552
46552
  // src/index.ts
46553
46553
  __export(exports, {
46554
- FileHandleProvider: () => FileHandleProvider,
46554
+ FileHandleFile: () => FileHandleFile,
46555
46555
  I3SConverter: () => I3SConverter,
46556
46556
  Tiles3DConverter: () => Tiles3DConverter
46557
46557
  });
@@ -47134,32 +47134,33 @@ function requireFromString(code, filename2 = "", options) {
47134
47134
  var LATEST = "beta";
47135
47135
  var VERSION3 = typeof VERSION !== "undefined" ? VERSION : LATEST;
47136
47136
  var loadLibraryPromises = {};
47137
- async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
47137
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
47138
47138
  if (moduleName) {
47139
- libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
47139
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
47140
47140
  }
47141
47141
  loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
47142
47142
  return await loadLibraryPromises[libraryUrl];
47143
47143
  }
47144
- function getLibraryUrl(library, moduleName, options) {
47145
- if (library.startsWith("http")) {
47144
+ function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
47145
+ if (!options.useLocalLibraries && library.startsWith("http")) {
47146
47146
  return library;
47147
47147
  }
47148
+ libraryName = libraryName || library;
47148
47149
  const modules = options.modules || {};
47149
- if (modules[library]) {
47150
- return modules[library];
47150
+ if (modules[libraryName]) {
47151
+ return modules[libraryName];
47151
47152
  }
47152
47153
  if (!isBrowser2) {
47153
- return `modules/${moduleName}/dist/libs/${library}`;
47154
+ return `modules/${moduleName}/dist/libs/${libraryName}`;
47154
47155
  }
47155
47156
  if (options.CDN) {
47156
47157
  assert3(options.CDN.startsWith("http"));
47157
- return `${options.CDN}/${moduleName}@${VERSION3}/dist/libs/${library}`;
47158
+ return `${options.CDN}/${moduleName}@${VERSION3}/dist/libs/${libraryName}`;
47158
47159
  }
47159
47160
  if (isWorker) {
47160
- return `../src/libs/${library}`;
47161
+ return `../src/libs/${libraryName}`;
47161
47162
  }
47162
- return `modules/${moduleName}/src/libs/${library}`;
47163
+ return `modules/${moduleName}/src/libs/${libraryName}`;
47163
47164
  }
47164
47165
  async function loadLibraryFromFile(libraryUrl) {
47165
47166
  if (libraryUrl.endsWith("wasm")) {
@@ -48708,6 +48709,7 @@ var DEFAULT_LOADER_OPTIONS = {
48708
48709
  mimeType: void 0,
48709
48710
  nothrow: false,
48710
48711
  log: new ConsoleLog(),
48712
+ useLocalLibraries: false,
48711
48713
  CDN: "https://unpkg.com/@loaders.gl",
48712
48714
  worker: true,
48713
48715
  maxConcurrency: 3,
@@ -49211,12 +49213,12 @@ async function getArrayBufferOrStringFromData(data, loader, options) {
49211
49213
  // ../core/src/lib/loader-utils/get-fetch-function.ts
49212
49214
  function getFetchFunction(options, context) {
49213
49215
  const globalOptions = getGlobalLoaderOptions();
49214
- const fetchOptions = options || globalOptions;
49215
- if (typeof fetchOptions.fetch === "function") {
49216
- return fetchOptions.fetch;
49216
+ const loaderOptions = options || globalOptions;
49217
+ if (typeof loaderOptions.fetch === "function") {
49218
+ return loaderOptions.fetch;
49217
49219
  }
49218
- if (isObject(fetchOptions.fetch)) {
49219
- return (url) => fetchFile(url, fetchOptions);
49220
+ if (isObject(loaderOptions.fetch)) {
49221
+ return (url) => fetchFile(url, loaderOptions.fetch);
49220
49222
  }
49221
49223
  if (context?.fetch) {
49222
49224
  return context?.fetch;
@@ -50021,10 +50023,18 @@ function getUint32Array(dracoArray) {
50021
50023
  var DRACO_DECODER_VERSION = "1.5.5";
50022
50024
  var DRACO_ENCODER_VERSION = "1.4.1";
50023
50025
  var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
50024
- var DRACO_JS_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.js`;
50025
- var DRACO_WASM_WRAPPER_URL = `${STATIC_DECODER_URL}/draco_wasm_wrapper.js`;
50026
- var DRACO_WASM_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.wasm`;
50027
- var DRACO_ENCODER_URL = `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/draco_encoder.js`;
50026
+ var DRACO_EXTERNAL_LIBRARIES = {
50027
+ DECODER: "draco_wasm_wrapper.js",
50028
+ DECODER_WASM: "draco_decoder.wasm",
50029
+ FALLBACK_DECODER: "draco_decoder.js",
50030
+ ENCODER: "draco_encoder.js"
50031
+ };
50032
+ var DRACO_EXTERNAL_LIBRARY_URLS = {
50033
+ [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,
50034
+ [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,
50035
+ [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,
50036
+ [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
50037
+ };
50028
50038
  var loadDecoderPromise;
50029
50039
  async function loadDracoDecoderModule(options) {
50030
50040
  const modules = options.modules || {};
@@ -50042,13 +50052,13 @@ async function loadDracoDecoder(options) {
50042
50052
  let wasmBinary;
50043
50053
  switch (options.draco && options.draco.decoderType) {
50044
50054
  case "js":
50045
- DracoDecoderModule = await loadLibrary(DRACO_JS_DECODER_URL, "draco", options);
50055
+ DracoDecoderModule = await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER);
50046
50056
  break;
50047
50057
  case "wasm":
50048
50058
  default:
50049
50059
  [DracoDecoderModule, wasmBinary] = await Promise.all([
50050
- await loadLibrary(DRACO_WASM_WRAPPER_URL, "draco", options),
50051
- await loadLibrary(DRACO_WASM_DECODER_URL, "draco", options)
50060
+ await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER),
50061
+ await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM)
50052
50062
  ]);
50053
50063
  }
50054
50064
  DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
@@ -51733,9 +51743,12 @@ function testBrowserImageFormatSupport(mimeType) {
51733
51743
  var VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
51734
51744
 
51735
51745
  // ../textures/src/lib/parsers/basis-module-loader.ts
51736
- var VERSION11 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
51737
- var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION11}/dist/libs/basis_encoder.wasm`;
51738
- var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION11}/dist/libs/basis_encoder.js`;
51746
+ var BASIS_EXTERNAL_LIBRARIES = {
51747
+ TRANSCODER: "basis_transcoder.js",
51748
+ TRANSCODER_WASM: "basis_transcoder.wasm",
51749
+ ENCODER: "basis_encoder.js",
51750
+ ENCODER_WASM: "basis_encoder.wasm"
51751
+ };
51739
51752
  var loadBasisTranscoderPromise;
51740
51753
  async function loadBasisTranscoderModule(options) {
51741
51754
  const modules = options.modules || {};
@@ -51749,8 +51762,8 @@ async function loadBasisTranscoder(options) {
51749
51762
  let BASIS = null;
51750
51763
  let wasmBinary = null;
51751
51764
  [BASIS, wasmBinary] = await Promise.all([
51752
- await loadLibrary("basis_transcoder.js", "textures", options),
51753
- await loadLibrary("basis_transcoder.wasm", "textures", options)
51765
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
51766
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
51754
51767
  ]);
51755
51768
  BASIS = BASIS || globalThis.BASIS;
51756
51769
  return await initializeBasisTranscoderModule(BASIS, wasmBinary);
@@ -51781,8 +51794,8 @@ async function loadBasisEncoder(options) {
51781
51794
  let BASIS_ENCODER = null;
51782
51795
  let wasmBinary = null;
51783
51796
  [BASIS_ENCODER, wasmBinary] = await Promise.all([
51784
- await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
51785
- await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
51797
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
51798
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
51786
51799
  ]);
51787
51800
  BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
51788
51801
  return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
@@ -53420,7 +53433,7 @@ var EXT_MESHOPT_COMPRESSION = "EXT_meshopt_compression";
53420
53433
  var name = EXT_MESHOPT_COMPRESSION;
53421
53434
  async function decode2(gltfData, options) {
53422
53435
  const scenegraph = new GLTFScenegraph(gltfData);
53423
- if (!options?.gltf?.decompressMeshes) {
53436
+ if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) {
53424
53437
  return;
53425
53438
  }
53426
53439
  const promises = [];
@@ -53693,7 +53706,7 @@ var scratchScaleMatrix = new import_core6.Matrix3();
53693
53706
  async function decode4(gltfData, options) {
53694
53707
  const gltfScenegraph = new GLTFScenegraph(gltfData);
53695
53708
  const hasExtension = gltfScenegraph.hasExtension(EXT_MESHOPT_TRANSFORM);
53696
- if (!hasExtension) {
53709
+ if (!hasExtension || !options.gltf?.loadBuffers) {
53697
53710
  return;
53698
53711
  }
53699
53712
  const materials = gltfData.json.materials || [];
@@ -54526,7 +54539,11 @@ async function loadImage(gltf, image, index, options, context) {
54526
54539
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
54527
54540
  }
54528
54541
  assert6(arrayBuffer, "glTF image has no data");
54529
- let parsedImage = await parse7(arrayBuffer, [ImageLoader, BasisLoader], { mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context);
54542
+ let parsedImage = await parse7(arrayBuffer, [ImageLoader, BasisLoader], {
54543
+ ...options,
54544
+ mimeType: image.mimeType,
54545
+ basis: options.basis || { format: selectSupportedBasisFormat() }
54546
+ }, context);
54530
54547
  if (parsedImage && parsedImage[0]) {
54531
54548
  parsedImage = {
54532
54549
  compressed: true,
@@ -55402,7 +55419,7 @@ var console_2 = globalThis.console;
55402
55419
  var navigator_2 = globalThis.navigator || {};
55403
55420
 
55404
55421
  // ../3d-tiles/node_modules/@probe.gl/env/dist/utils/globals.js
55405
- var VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
55422
+ var VERSION11 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
55406
55423
  var isBrowser6 = isBrowser5();
55407
55424
 
55408
55425
  // ../3d-tiles/node_modules/@probe.gl/log/dist/utils/local-storage.js
@@ -55587,7 +55604,7 @@ var Log2 = class {
55587
55604
  id: ""
55588
55605
  };
55589
55606
  this.id = void 0;
55590
- this.VERSION = VERSION12;
55607
+ this.VERSION = VERSION11;
55591
55608
  this._startTs = getHiResTimestamp2();
55592
55609
  this._deltaTs = getHiResTimestamp2();
55593
55610
  this._storage = void 0;
@@ -55790,7 +55807,7 @@ var Log2 = class {
55790
55807
  return noop2;
55791
55808
  }
55792
55809
  };
55793
- Log2.VERSION = VERSION12;
55810
+ Log2.VERSION = VERSION11;
55794
55811
  function normalizeLogLevel2(logLevel) {
55795
55812
  if (!logLevel) {
55796
55813
  return 0;
@@ -58320,12 +58337,13 @@ function unifyObjectsByFeatureId(sortedData) {
58320
58337
  const uniqueObjects = [];
58321
58338
  for (let index = 0; index < sortedData.length; index++) {
58322
58339
  const currentObject = sortedData[index];
58323
- const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
58324
- if (existedObject) {
58325
- existedObject.positions = concatenateTypedArrays(existedObject.positions, currentObject.positions);
58326
- existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);
58327
- existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);
58328
- existedObject.texCoords = concatenateTypedArrays(existedObject.texCoords, currentObject.texCoords);
58340
+ const existingObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
58341
+ if (existingObject) {
58342
+ existingObject.positions = concatenateTypedArrays(existingObject.positions, currentObject.positions);
58343
+ existingObject.normals = concatenateTypedArrays(existingObject.normals, currentObject.normals);
58344
+ existingObject.colors = concatenateTypedArrays(existingObject.colors, currentObject.colors);
58345
+ existingObject.texCoords = concatenateTypedArrays(existingObject.texCoords, currentObject.texCoords);
58346
+ existingObject.uvRegions = concatenateTypedArrays(existingObject.uvRegions, currentObject.uvRegions);
58329
58347
  } else {
58330
58348
  uniqueObjects.push(currentObject);
58331
58349
  }
@@ -58533,10 +58551,26 @@ function prepareNodes(nodes) {
58533
58551
  }
58534
58552
  }
58535
58553
 
58536
- // src/i3s-converter/helpers/batch-ids-extensions.ts
58554
+ // src/constants.ts
58555
+ var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
58537
58556
  var EXT_MESH_FEATURES = "EXT_mesh_features";
58538
58557
  var EXT_FEATURE_METADATA2 = "EXT_feature_metadata";
58539
- function handleBatchIdsExtensions(attributes, primitive, images) {
58558
+
58559
+ // src/i3s-converter/helpers/batch-ids-extensions.ts
58560
+ function getTextureByMetadataClass(tileContent, metadataClass) {
58561
+ const extFeatureMetadata = tileContent.gltf?.extensions?.[EXT_FEATURE_METADATA2];
58562
+ if (!extFeatureMetadata?.featureTextures) {
58563
+ return null;
58564
+ }
58565
+ for (const textureKey in extFeatureMetadata.featureTextures) {
58566
+ const texture = extFeatureMetadata.featureTextures[textureKey];
58567
+ if (texture.class === metadataClass) {
58568
+ return textureKey;
58569
+ }
58570
+ }
58571
+ return null;
58572
+ }
58573
+ function handleBatchIdsExtensions(attributes, primitive, images, featureTexture) {
58540
58574
  const extensions = primitive?.extensions;
58541
58575
  if (!extensions) {
58542
58576
  return [];
@@ -58544,7 +58578,7 @@ function handleBatchIdsExtensions(attributes, primitive, images) {
58544
58578
  for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
58545
58579
  switch (extensionName) {
58546
58580
  case EXT_FEATURE_METADATA2:
58547
- return handleExtFeatureMetadataExtension(attributes, extensionData, images);
58581
+ return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
58548
58582
  case EXT_MESH_FEATURES:
58549
58583
  console.warn("EXT_mesh_features extension is not supported yet");
58550
58584
  return [];
@@ -58554,7 +58588,7 @@ function handleBatchIdsExtensions(attributes, primitive, images) {
58554
58588
  }
58555
58589
  return [];
58556
58590
  }
58557
- function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images) {
58591
+ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images, featureTexture) {
58558
58592
  const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
58559
58593
  if (featureIdAttribute?.featureIds?.attribute) {
58560
58594
  const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];
@@ -58571,7 +58605,6 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
58571
58605
  const textureCoordinates = attributes[textCoordAttribute].value;
58572
58606
  return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
58573
58607
  }
58574
- const featureTexture = extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
58575
58608
  if (featureTexture) {
58576
58609
  const batchIdsAttribute = attributes[featureTexture];
58577
58610
  return batchIdsAttribute.value;
@@ -58792,14 +58825,13 @@ var SHORT_INT_TYPE2 = "Int32";
58792
58825
  var DOUBLE_TYPE2 = "Float64";
58793
58826
  var OBJECT_ID_TYPE2 = "Oid32";
58794
58827
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
58795
- var EXT_FEATURE_METADATA3 = "EXT_feature_metadata";
58796
- var EXT_MESH_FEATURES2 = "EXT_mesh_features";
58797
58828
  var scratchVector4 = new import_core16.Vector3();
58798
- async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
58829
+ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
58799
58830
  const useCartesianPositions = generateBoundingVolumes;
58800
58831
  const materialAndTextureList = await convertMaterials(tileContent.gltf?.materials, shouldMergeMaterials);
58801
58832
  const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent, tileTransform, tileBoundingVolume);
58802
- const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
58833
+ const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
58834
+ const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
58803
58835
  if (generateBoundingVolumes) {
58804
58836
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
58805
58837
  }
@@ -58825,7 +58857,7 @@ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBounding
58825
58857
  propertyTable,
58826
58858
  attributeStorageInfo,
58827
58859
  draco,
58828
- workerSource
58860
+ libraries
58829
58861
  }));
58830
58862
  }
58831
58863
  if (!result.length) {
@@ -58857,7 +58889,7 @@ async function _makeNodeResources({
58857
58889
  propertyTable,
58858
58890
  attributeStorageInfo,
58859
58891
  draco,
58860
- workerSource
58892
+ libraries
58861
58893
  }) {
58862
58894
  const boundingVolumes = convertedAttributes.boundingVolumes;
58863
58895
  const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX2;
@@ -58877,7 +58909,7 @@ async function _makeNodeResources({
58877
58909
  uvRegions,
58878
58910
  featureIds,
58879
58911
  faceRange
58880
- }, workerSource.draco) : null;
58912
+ }, libraries) : null;
58881
58913
  let attributes = [];
58882
58914
  if (attributeStorageInfo && propertyTable) {
58883
58915
  attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
@@ -58896,7 +58928,7 @@ async function _makeNodeResources({
58896
58928
  boundingVolumes
58897
58929
  };
58898
58930
  }
58899
- async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
58931
+ async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
58900
58932
  const { nodes, images, cartographicOrigin, cartesianModelMatrix } = attributesData;
58901
58933
  const attributesMap = new Map();
58902
58934
  for (const materialAndTexture of materialAndTextureList) {
@@ -58915,7 +58947,7 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
58915
58947
  attributesMap.set(mergedMaterial.originalMaterialId, attributes);
58916
58948
  }
58917
58949
  }
58918
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
58950
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, void 0, featureTexture);
58919
58951
  for (const attrKey of attributesMap.keys()) {
58920
58952
  const attributes = attributesMap.get(attrKey);
58921
58953
  if (!attributes) {
@@ -58932,10 +58964,10 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
58932
58964
  }
58933
58965
  return attributesMap;
58934
58966
  }
58935
- function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58967
+ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58936
58968
  if (nodes) {
58937
58969
  for (const node2 of nodes) {
58938
- convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
58970
+ convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
58939
58971
  }
58940
58972
  }
58941
58973
  }
@@ -58956,15 +58988,15 @@ function getCompositeTransformationMatrix(node2, matrix) {
58956
58988
  }
58957
58989
  return transformationMatrix;
58958
58990
  }
58959
- function convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58991
+ function convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58960
58992
  const transformationMatrix = getCompositeTransformationMatrix(node2, matrix);
58961
58993
  const mesh = node2.mesh;
58962
58994
  if (mesh) {
58963
- convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
58995
+ convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
58964
58996
  }
58965
- convertNodes(node2.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
58997
+ convertNodes(node2.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
58966
58998
  }
58967
- function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
58999
+ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core16.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
58968
59000
  for (const primitive of mesh.primitives) {
58969
59001
  let outputAttributes = null;
58970
59002
  let materialUvRegion;
@@ -59005,7 +59037,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
59005
59037
  outputAttributes.uvRegions = concatenateTypedArrays(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
59006
59038
  }
59007
59039
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
59008
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
59040
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
59009
59041
  }
59010
59042
  }
59011
59043
  function normalizeIndices(primitive) {
@@ -59122,8 +59154,8 @@ function flattenBatchIds(batchedIds, indices) {
59122
59154
  }
59123
59155
  return newBatchIds;
59124
59156
  }
59125
- function getBatchIds(attributes, primitive, images) {
59126
- const batchIds = handleBatchIdsExtensions(attributes, primitive, images);
59157
+ function getBatchIds(attributes, primitive, images, featureTexture) {
59158
+ const batchIds = handleBatchIdsExtensions(attributes, primitive, images, featureTexture);
59127
59159
  if (batchIds.length) {
59128
59160
  return batchIds;
59129
59161
  }
@@ -59446,7 +59478,7 @@ function generateBigUint64Array(featureIds) {
59446
59478
  }
59447
59479
  return typedFeatureIds;
59448
59480
  }
59449
- async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
59481
+ async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes, libraries) {
59450
59482
  const { positions, normals, texCoords, colors, uvRegions, featureIds, faceRange } = attributes;
59451
59483
  const indices = new Uint32Array(vertexCount);
59452
59484
  for (let index = 0; index < indices.length; index++) {
@@ -59477,12 +59509,16 @@ async function generateCompressedGeometry(vertexCount, convertedAttributes, attr
59477
59509
  }
59478
59510
  return encode({ attributes: compressedAttributes, indices }, DracoWriterWorker, {
59479
59511
  ...DracoWriterWorker.options,
59480
- source: dracoWorkerSoure,
59481
59512
  reuseWorkers: true,
59482
59513
  _nodeWorkers: true,
59514
+ modules: libraries,
59515
+ useLocalLibraries: true,
59483
59516
  draco: {
59484
59517
  method: "MESH_SEQUENTIAL_ENCODING",
59485
59518
  attributesMetadata
59519
+ },
59520
+ ["draco-writer"]: {
59521
+ workerUrl: "./modules/draco/dist/draco-writer-worker-node.js"
59486
59522
  }
59487
59523
  });
59488
59524
  }
@@ -59498,7 +59534,7 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
59498
59534
  }
59499
59535
  return orderedFeatureIndices;
59500
59536
  }
59501
- function getPropertyTable(tileContent) {
59537
+ function getPropertyTable(tileContent, metadataClass) {
59502
59538
  if (!tileContent) {
59503
59539
  return null;
59504
59540
  }
@@ -59508,19 +59544,19 @@ function getPropertyTable(tileContent) {
59508
59544
  }
59509
59545
  const { extensionName, extension } = getPropertyTableExtension(tileContent);
59510
59546
  switch (extensionName) {
59511
- case EXT_MESH_FEATURES2: {
59547
+ case EXT_MESH_FEATURES: {
59512
59548
  console.warn("The I3S converter does not yet support the EXT_mesh_features extension");
59513
59549
  return null;
59514
59550
  }
59515
- case EXT_FEATURE_METADATA3: {
59516
- return getPropertyTableFromExtFeatureMetadata(extension);
59551
+ case EXT_FEATURE_METADATA2: {
59552
+ return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
59517
59553
  }
59518
59554
  default:
59519
59555
  return null;
59520
59556
  }
59521
59557
  }
59522
59558
  function getPropertyTableExtension(tileContent) {
59523
- const extensionsWithPropertyTables = [EXT_FEATURE_METADATA3, EXT_MESH_FEATURES2];
59559
+ const extensionsWithPropertyTables = [EXT_FEATURE_METADATA2, EXT_MESH_FEATURES];
59524
59560
  const extensionsUsed = tileContent?.gltf?.extensionsUsed;
59525
59561
  if (!extensionsUsed) {
59526
59562
  return { extensionName: null, extension: null };
@@ -59538,7 +59574,7 @@ function getPropertyTableExtension(tileContent) {
59538
59574
  const extension = tileContent?.gltf?.extensions?.[extensionName];
59539
59575
  return { extensionName, extension };
59540
59576
  }
59541
- function getPropertyTableFromExtFeatureMetadata(extension) {
59577
+ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
59542
59578
  if (extension?.featureTables) {
59543
59579
  const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
59544
59580
  if (firstFeatureTableName) {
@@ -59551,9 +59587,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
59551
59587
  }
59552
59588
  }
59553
59589
  if (extension?.featureTextures) {
59554
- const firstTextureName = Object.keys(extension.featureTextures)?.[0];
59555
- if (firstTextureName) {
59556
- const featureTable = extension?.featureTextures[firstTextureName];
59590
+ let featureTexture;
59591
+ for (const textureKey in extension.featureTextures) {
59592
+ const texture = extension.featureTextures[textureKey];
59593
+ if (texture.class === metadataClass) {
59594
+ featureTexture = textureKey;
59595
+ }
59596
+ }
59597
+ if (typeof featureTexture === "string") {
59598
+ const featureTable = extension?.featureTextures[featureTexture];
59557
59599
  const propertyTable = {};
59558
59600
  for (const propertyName in featureTable.properties) {
59559
59601
  propertyTable[propertyName] = featureTable.properties[propertyName].data;
@@ -59650,12 +59692,12 @@ function convertScreenThresholdToGeometricError(node2) {
59650
59692
 
59651
59693
  // src/pgm-loader.ts
59652
59694
  var import_geoid = __toModule(require_es54());
59653
- var VERSION13 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
59695
+ var VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
59654
59696
  var PGMLoader = {
59655
59697
  name: "PGM - Netpbm grayscale image format",
59656
59698
  id: "pgm",
59657
59699
  module: "tile-converter",
59658
- version: VERSION13,
59700
+ version: VERSION12,
59659
59701
  mimeTypes: ["image/x-portable-graymap"],
59660
59702
  parse: async (arrayBuffer, options) => (0, import_geoid.parsePGM)(new Uint8Array(arrayBuffer), options),
59661
59703
  extensions: ["pgm"],
@@ -60247,16 +60289,16 @@ function isAllVerticesInsideBoundingVolume(boundingVolume, positions) {
60247
60289
  }
60248
60290
 
60249
60291
  // src/i3s-converter/types.ts
60250
- var GltfPrimitiveModeString;
60251
- (function(GltfPrimitiveModeString2) {
60252
- GltfPrimitiveModeString2["POINTS"] = "POINTS";
60253
- GltfPrimitiveModeString2["LINES"] = "LINES";
60254
- GltfPrimitiveModeString2["LINE_LOOP"] = "LINE_LOOP";
60255
- GltfPrimitiveModeString2["LINE_STRIP"] = "LINE_STRIP";
60256
- GltfPrimitiveModeString2["TRIANGLES"] = "TRIANGLES";
60257
- GltfPrimitiveModeString2["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
60258
- GltfPrimitiveModeString2["TRIANGLE_FAN"] = "TRIANGLE_FAN";
60259
- })(GltfPrimitiveModeString || (GltfPrimitiveModeString = {}));
60292
+ var GLTFPrimitiveModeString;
60293
+ (function(GLTFPrimitiveModeString2) {
60294
+ GLTFPrimitiveModeString2["POINTS"] = "POINTS";
60295
+ GLTFPrimitiveModeString2["LINES"] = "LINES";
60296
+ GLTFPrimitiveModeString2["LINE_LOOP"] = "LINE_LOOP";
60297
+ GLTFPrimitiveModeString2["LINE_STRIP"] = "LINE_STRIP";
60298
+ GLTFPrimitiveModeString2["TRIANGLES"] = "TRIANGLES";
60299
+ GLTFPrimitiveModeString2["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
60300
+ GLTFPrimitiveModeString2["TRIANGLE_FAN"] = "TRIANGLE_FAN";
60301
+ })(GLTFPrimitiveModeString || (GLTFPrimitiveModeString = {}));
60260
60302
 
60261
60303
  // src/lib/utils/queue.ts
60262
60304
  var Queue = class extends Array {
@@ -60346,9 +60388,6 @@ var WriteQueue = class extends Queue {
60346
60388
  }
60347
60389
  };
60348
60390
 
60349
- // src/constants.ts
60350
- var BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
60351
-
60352
60391
  // src/i3s-converter/helpers/node-index-document.ts
60353
60392
  var import_path7 = __toModule(require("path"));
60354
60393
  var import_json_map_transform7 = __toModule(require_json_map_transform());
@@ -60667,31 +60706,35 @@ var traverseDatasetWith = async (tile, traversalProps, processTile, postprocessT
60667
60706
 
60668
60707
  // src/i3s-converter/helpers/preprocess-3d-tiles.ts
60669
60708
  var GLTF_PRIMITIVE_MODES = [
60670
- GltfPrimitiveModeString.POINTS,
60671
- GltfPrimitiveModeString.LINES,
60672
- GltfPrimitiveModeString.LINE_LOOP,
60673
- GltfPrimitiveModeString.LINE_STRIP,
60674
- GltfPrimitiveModeString.TRIANGLES,
60675
- GltfPrimitiveModeString.TRIANGLE_STRIP,
60676
- GltfPrimitiveModeString.TRIANGLE_FAN
60709
+ GLTFPrimitiveModeString.POINTS,
60710
+ GLTFPrimitiveModeString.LINES,
60711
+ GLTFPrimitiveModeString.LINE_LOOP,
60712
+ GLTFPrimitiveModeString.LINE_STRIP,
60713
+ GLTFPrimitiveModeString.TRIANGLES,
60714
+ GLTFPrimitiveModeString.TRIANGLE_STRIP,
60715
+ GLTFPrimitiveModeString.TRIANGLE_FAN
60677
60716
  ];
60678
60717
  var analyzeTileContent = async (tileContent) => {
60679
- const result = {
60680
- meshTopologyTypes: new Set()
60718
+ const defaultResult = {
60719
+ meshTopologyTypes: new Set(),
60720
+ metadataClasses: new Set()
60681
60721
  };
60682
60722
  if (!tileContent?.gltfArrayBuffer) {
60683
- return result;
60723
+ return defaultResult;
60684
60724
  }
60685
60725
  const gltfData = await parse(tileContent.gltfArrayBuffer, GLTFLoader, {
60686
60726
  gltf: { normalize: false, loadBuffers: false, loadImages: false, decompressMeshes: false }
60687
60727
  });
60688
60728
  const gltf = gltfData.json;
60689
60729
  if (!gltf) {
60690
- return result;
60730
+ return defaultResult;
60691
60731
  }
60692
- const meshTypes = getMeshTypesFromGltf(gltf);
60693
- result.meshTopologyTypes = meshTypes;
60694
- return result;
60732
+ const meshTopologyTypes = getMeshTypesFromGltf(gltf);
60733
+ const metadataClasses = getMetadataClassesFromGltf(gltf);
60734
+ return {
60735
+ meshTopologyTypes,
60736
+ metadataClasses
60737
+ };
60695
60738
  };
60696
60739
  var getMeshTypesFromGltf = (gltfJson) => {
60697
60740
  const result = new Set();
@@ -60706,14 +60749,27 @@ var getMeshTypesFromGltf = (gltfJson) => {
60706
60749
  }
60707
60750
  return result;
60708
60751
  };
60752
+ var getMetadataClassesFromGltf = (gltfJson) => {
60753
+ const result = new Set();
60754
+ const classes = gltfJson.extensions?.[EXT_FEATURE_METADATA2]?.schema?.classes;
60755
+ if (classes) {
60756
+ for (const classKey of Object.keys(classes)) {
60757
+ result.add(classKey);
60758
+ }
60759
+ }
60760
+ return result;
60761
+ };
60709
60762
  var mergePreprocessData = (object1, object2) => {
60710
60763
  for (const type of object2.meshTopologyTypes) {
60711
60764
  object1.meshTopologyTypes.add(type);
60712
60765
  }
60766
+ for (const metadataClass of object2.metadataClasses) {
60767
+ object1.metadataClasses.add(metadataClass);
60768
+ }
60713
60769
  };
60714
60770
 
60715
60771
  // src/i3s-converter/i3s-converter.ts
60716
- var ION_DEFAULT_TOKEN = import_process2.default.env?.IonToken || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ";
60772
+ var ION_DEFAULT_TOKEN = import_process2.default.env?.IonToken;
60717
60773
  var HARDCODED_NODES_PER_PAGE = 64;
60718
60774
  var _3D_TILES = "3DTILES";
60719
60775
  var _3D_OBJECT_LAYER_TYPE = "3DObject";
@@ -60728,12 +60784,14 @@ var I3SConverter = class {
60728
60784
  this.loadOptions = {
60729
60785
  _nodeWorkers: true,
60730
60786
  reuseWorkers: true,
60787
+ useLocalLibraries: true,
60731
60788
  basis: {
60732
60789
  format: "rgba32",
60733
60790
  workerUrl: "./modules/textures/dist/basis-worker-node.js"
60734
60791
  },
60735
60792
  draco: { workerUrl: "./modules/draco/dist/draco-worker-node.js" },
60736
- fetch: {}
60793
+ fetch: {},
60794
+ modules: {}
60737
60795
  };
60738
60796
  this.geoidHeightModel = null;
60739
60797
  this.Loader = Tiles3DLoader;
@@ -60741,7 +60799,8 @@ var I3SConverter = class {
60741
60799
  this.writeQueue = new WriteQueue();
60742
60800
  this.compressList = null;
60743
60801
  this.preprocessData = {
60744
- meshTopologyTypes: new Set()
60802
+ meshTopologyTypes: new Set(),
60803
+ metadataClasses: new Set()
60745
60804
  };
60746
60805
  this.nodePages = new NodePages(writeFile3, HARDCODED_NODES_PER_PAGE, this);
60747
60806
  this.options = {};
@@ -60783,7 +60842,9 @@ var I3SConverter = class {
60783
60842
  generateTextures,
60784
60843
  generateBoundingVolumes,
60785
60844
  instantNodeWriting = false,
60786
- mergeMaterials: mergeMaterials2 = true
60845
+ mergeMaterials: mergeMaterials2 = true,
60846
+ inquirer,
60847
+ metadataClass
60787
60848
  } = options;
60788
60849
  this.options = {
60789
60850
  maxDepth,
@@ -60794,7 +60855,9 @@ var I3SConverter = class {
60794
60855
  token,
60795
60856
  inputUrl,
60796
60857
  instantNodeWriting,
60797
- mergeMaterials: mergeMaterials2
60858
+ mergeMaterials: mergeMaterials2,
60859
+ inquirer,
60860
+ metadataClass
60798
60861
  };
60799
60862
  this.compressList = this.options.instantNodeWriting && [] || null;
60800
60863
  this.validate = Boolean(validate2);
@@ -60809,7 +60872,6 @@ var I3SConverter = class {
60809
60872
  if (slpk) {
60810
60873
  this.nodePages.useWriteFunction(writeFileForSlpk);
60811
60874
  }
60812
- await this.loadWorkers();
60813
60875
  try {
60814
60876
  const preloadOptions = await this._fetchPreloadOptions();
60815
60877
  let tilesetUrl = inputUrl;
@@ -60838,16 +60900,41 @@ var I3SConverter = class {
60838
60900
  console.log(`Analyze source tileset`);
60839
60901
  const sourceRootTile = this.sourceTileset.root;
60840
60902
  await traverseDatasetWith(sourceRootTile, null, this.analyzeTile.bind(this), void 0, this.options.maxDepth);
60841
- const { meshTopologyTypes } = this.preprocessData;
60903
+ const { meshTopologyTypes, metadataClasses } = this.preprocessData;
60842
60904
  console.log(`------------------------------------------------`);
60843
60905
  console.log(`Preprocess results:`);
60844
60906
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(", ")}`);
60907
+ if (metadataClasses.size) {
60908
+ console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(", ")}`);
60909
+ } else {
60910
+ console.log("Feature metadata classes have not been found");
60911
+ }
60845
60912
  console.log(`------------------------------------------------`);
60846
- if (!meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLE_STRIP)) {
60913
+ if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
60847
60914
  console.log("The tileset is of unsupported mesh topology types. The conversion will be interrupted.");
60848
60915
  console.log(`------------------------------------------------`);
60849
60916
  return false;
60850
60917
  }
60918
+ if (metadataClasses.size > 1) {
60919
+ if (this.options.metadataClass?.length) {
60920
+ console.log(`${this.options.metadataClass} has been selected`);
60921
+ } else if (this.options.inquirer) {
60922
+ const result = await this.options.inquirer.prompt([
60923
+ {
60924
+ name: "metadataClass",
60925
+ type: "list",
60926
+ message: "Select feature metadata data class to convert...",
60927
+ choices: Array.from(metadataClasses)
60928
+ }
60929
+ ]);
60930
+ this.options.metadataClass = result.metadataClass;
60931
+ console.log(`${result.metadataClass} has been selected`);
60932
+ } else {
60933
+ console.log(`A feature metadata class has not been selected. Start the converter with option "--metadata-class". For example, "npx tile-converter ... --metadata-class ${Array.from(metadataClasses)[0]}"`);
60934
+ console.log(`------------------------------------------------`);
60935
+ return false;
60936
+ }
60937
+ }
60851
60938
  return true;
60852
60939
  }
60853
60940
  async analyzeTile(sourceTile, traversalProps) {
@@ -61010,7 +61097,7 @@ var I3SConverter = class {
61010
61097
  }
61011
61098
  const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
61012
61099
  let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
61013
- const propertyTable = getPropertyTable(tileContent);
61100
+ const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
61014
61101
  if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
61015
61102
  this._convertPropertyTableToNodeAttributes(propertyTable);
61016
61103
  }
@@ -61064,7 +61151,7 @@ var I3SConverter = class {
61064
61151
  halfSize: [],
61065
61152
  quaternion: []
61066
61153
  };
61067
- const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.workerSource);
61154
+ const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
61068
61155
  return resourcesData;
61069
61156
  }
61070
61157
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
@@ -61195,9 +61282,12 @@ var I3SConverter = class {
61195
61282
  const arrayToEncode = new Uint8Array(copyArrayBuffer2);
61196
61283
  const ktx2TextureData = encode({ ...texture.image, data: arrayToEncode }, KTX2BasisWriterWorker, {
61197
61284
  ...KTX2BasisWriterWorker.options,
61198
- source: this.workerSource.ktx2,
61285
+ ["ktx2-basis-writer"]: {
61286
+ workerUrl: "./modules/textures/dist/ktx2-basis-writer-worker-node.js"
61287
+ },
61199
61288
  reuseWorkers: true,
61200
- _nodeWorkers: true
61289
+ _nodeWorkers: true,
61290
+ useLocalLibraries: true
61201
61291
  });
61202
61292
  await this.writeTextureFile(ktx2TextureData, "1", "ktx2", childPath, slpkChildPath);
61203
61293
  }
@@ -61356,22 +61446,6 @@ var I3SConverter = class {
61356
61446
  isContentSupported(sourceTile) {
61357
61447
  return ["b3dm", "glTF", "scenegraph"].includes(sourceTile.type || "");
61358
61448
  }
61359
- async loadWorkers() {
61360
- console.log(`Loading workers source...`);
61361
- if (this.options.draco) {
61362
- const url = getWorkerURL(DracoWriterWorker, { ...getGlobalLoaderOptions() });
61363
- const sourceResponse = await fetchFile(url);
61364
- const source = await sourceResponse.text();
61365
- this.workerSource.draco = source;
61366
- }
61367
- if (this.generateTextures) {
61368
- const url = getWorkerURL(KTX2BasisWriterWorker, { ...getGlobalLoaderOptions() });
61369
- const sourceResponse = await fetchFile(url);
61370
- const source = await sourceResponse.text();
61371
- this.workerSource.ktx2 = source;
61372
- }
61373
- console.log(`Loading workers source completed!`);
61374
- }
61375
61449
  };
61376
61450
 
61377
61451
  // src/3d-tiles-converter/3d-tiles-converter.ts
@@ -61380,7 +61454,7 @@ var import_process3 = __toModule(require("process"));
61380
61454
  var import_json_map_transform10 = __toModule(require_json_map_transform());
61381
61455
 
61382
61456
  // ../i3s/src/lib/parsers/constants.ts
61383
- var import_constants11 = __toModule(require_es55());
61457
+ var import_constants14 = __toModule(require_es55());
61384
61458
  function getConstructorForDataFormat(dataType) {
61385
61459
  switch (dataType) {
61386
61460
  case "UInt8":
@@ -61398,11 +61472,11 @@ function getConstructorForDataFormat(dataType) {
61398
61472
  }
61399
61473
  }
61400
61474
  var GL_TYPE_MAP = {
61401
- UInt8: import_constants11.default.UNSIGNED_BYTE,
61402
- UInt16: import_constants11.default.UNSIGNED_SHORT,
61403
- Float32: import_constants11.default.FLOAT,
61404
- UInt32: import_constants11.default.UNSIGNED_INT,
61405
- UInt64: import_constants11.default.DOUBLE
61475
+ UInt8: import_constants14.default.UNSIGNED_BYTE,
61476
+ UInt16: import_constants14.default.UNSIGNED_SHORT,
61477
+ Float32: import_constants14.default.FLOAT,
61478
+ UInt32: import_constants14.default.UNSIGNED_INT,
61479
+ UInt64: import_constants14.default.DOUBLE
61406
61480
  };
61407
61481
  function sizeOf(dataType) {
61408
61482
  switch (dataType) {
@@ -61528,12 +61602,12 @@ function parseStringsAttribute(arrayBuffer) {
61528
61602
  }
61529
61603
 
61530
61604
  // ../i3s/src/i3s-attribute-loader.ts
61531
- var VERSION14 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
61605
+ var VERSION13 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
61532
61606
  var I3SAttributeLoader = {
61533
61607
  name: "I3S Attribute",
61534
61608
  id: "i3s-attribute",
61535
61609
  module: "i3s",
61536
- version: VERSION14,
61610
+ version: VERSION13,
61537
61611
  mimeTypes: ["application/binary"],
61538
61612
  parse: async (arrayBuffer, options) => parseI3STileAttribute(arrayBuffer, options),
61539
61613
  extensions: ["bin"],
@@ -61991,13 +62065,13 @@ function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
61991
62065
  }
61992
62066
 
61993
62067
  // ../i3s/src/i3s-content-loader.ts
61994
- var VERSION15 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
62068
+ var VERSION14 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
61995
62069
  var I3SContentLoader = {
61996
62070
  name: "I3S Content (Indexed Scene Layers)",
61997
62071
  id: "i3s-content",
61998
62072
  module: "i3s",
61999
62073
  worker: true,
62000
- version: VERSION15,
62074
+ version: VERSION14,
62001
62075
  mimeTypes: ["application/octet-stream"],
62002
62076
  parse: parse6,
62003
62077
  extensions: ["bin"],
@@ -62020,7 +62094,7 @@ var import_culling5 = __toModule(require_es53());
62020
62094
  var import_geospatial9 = __toModule(require_es52());
62021
62095
 
62022
62096
  // ../i3s/src/i3s-node-page-loader.ts
62023
- var VERSION16 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
62097
+ var VERSION15 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
62024
62098
  async function parseNodePage(data, options) {
62025
62099
  return JSON.parse(new TextDecoder().decode(data));
62026
62100
  }
@@ -62028,7 +62102,7 @@ var I3SNodePageLoader = {
62028
62102
  name: "I3S Node Page",
62029
62103
  id: "i3s-node-page",
62030
62104
  module: "i3s",
62031
- version: VERSION16,
62105
+ version: VERSION15,
62032
62106
  mimeTypes: ["application/json"],
62033
62107
  parse: parseNodePage,
62034
62108
  extensions: ["json"],
@@ -62280,6 +62354,7 @@ async function normalizeTilesetData(tileset, options, context) {
62280
62354
  }
62281
62355
  return {
62282
62356
  ...tileset,
62357
+ loader: I3SLoader,
62283
62358
  url,
62284
62359
  basePath: url,
62285
62360
  type: TILESET_TYPE.I3S,
@@ -62291,7 +62366,7 @@ async function normalizeTilesetData(tileset, options, context) {
62291
62366
  }
62292
62367
 
62293
62368
  // ../i3s/src/i3s-loader.ts
62294
- var VERSION17 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
62369
+ var VERSION16 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
62295
62370
  var TILESET_REGEX = /layers\/[0-9]+$/;
62296
62371
  var TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
62297
62372
  var SLPK_HEX = "504b0304";
@@ -62300,7 +62375,7 @@ var I3SLoader = {
62300
62375
  name: "I3S (Indexed Scene Layers)",
62301
62376
  id: "i3s",
62302
62377
  module: "i3s",
62303
- version: VERSION17,
62378
+ version: VERSION16,
62304
62379
  mimeTypes: ["application/octet-stream"],
62305
62380
  parse: parseI3S,
62306
62381
  extensions: ["bin"],
@@ -62893,11 +62968,11 @@ FileHandle.open = async (path2) => {
62893
62968
  return new _FileHandle(fd, stats);
62894
62969
  };
62895
62970
 
62896
- // src/slpk-extractor/helpers/file-handle-provider.ts
62897
- var FileHandleProvider = class {
62971
+ // src/slpk-extractor/helpers/file-handle-file.ts
62972
+ var FileHandleFile = class {
62898
62973
  static async from(path2) {
62899
62974
  const fileDescriptor = await FileHandle.open(path2);
62900
- return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);
62975
+ return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
62901
62976
  }
62902
62977
  constructor(fileDescriptor, size) {
62903
62978
  this.fileDescriptor = fileDescriptor;
@@ -62945,7 +63020,7 @@ var FileHandleProvider = class {
62945
63020
  };
62946
63021
  // Annotate the CommonJS export names for ESM import in node:
62947
63022
  0 && (module.exports = {
62948
- FileHandleProvider,
63023
+ FileHandleFile,
62949
63024
  I3SConverter,
62950
63025
  Tiles3DConverter
62951
63026
  });