@loaders.gl/3d-tiles 4.0.0-alpha.23 → 4.0.0-alpha.25

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 (75) hide show
  1. package/dist/cesium-ion-loader.d.ts +2 -2
  2. package/dist/cesium-ion-loader.d.ts.map +1 -1
  3. package/dist/dist.min.js +421 -270
  4. package/dist/es5/3d-tiles-archive-loader.js +1 -1
  5. package/dist/es5/cesium-ion-loader.js.map +1 -1
  6. package/dist/es5/lib/utils/version.js +1 -1
  7. package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
  8. package/dist/es5/tile-3d-writer.js.map +1 -1
  9. package/dist/es5/types.js.map +1 -1
  10. package/dist/esm/3d-tiles-archive-loader.js +1 -1
  11. package/dist/esm/cesium-ion-loader.js.map +1 -1
  12. package/dist/esm/lib/utils/version.js +1 -1
  13. package/dist/esm/tile-3d-subtree-loader.js.map +1 -1
  14. package/dist/esm/tile-3d-writer.js.map +1 -1
  15. package/dist/esm/types.js.map +1 -1
  16. package/dist/tile-3d-subtree-loader.d.ts +3 -3
  17. package/dist/tile-3d-subtree-loader.d.ts.map +1 -1
  18. package/dist/tile-3d-writer.d.ts +2 -2
  19. package/dist/tile-3d-writer.d.ts.map +1 -1
  20. package/dist/types.d.ts +2 -5
  21. package/dist/types.d.ts.map +1 -1
  22. package/package.json +8 -8
  23. package/src/cesium-ion-loader.ts +2 -2
  24. package/src/tile-3d-subtree-loader.ts +3 -3
  25. package/src/tile-3d-writer.ts +2 -2
  26. package/src/types.ts +3 -5
  27. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +0 -72
  28. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +0 -33
  29. package/dist/3d-tiles-archive-loader.js +0 -31
  30. package/dist/bundle.js +0 -5
  31. package/dist/cesium-ion-loader.js +0 -40
  32. package/dist/index.js +0 -30
  33. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +0 -113
  34. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +0 -197
  35. package/dist/lib/classes/tile-3d-batch-table.js +0 -245
  36. package/dist/lib/classes/tile-3d-feature-table.js +0 -72
  37. package/dist/lib/constants.js +0 -26
  38. package/dist/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  39. package/dist/lib/encoders/encode-3d-tile-composite.js +0 -24
  40. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  41. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +0 -39
  42. package/dist/lib/encoders/encode-3d-tile.js +0 -33
  43. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +0 -30
  44. package/dist/lib/filesystems/tiles-3d-archive-file-system.js +0 -75
  45. package/dist/lib/ion/ion.js +0 -68
  46. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -65
  47. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  48. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -42
  49. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -303
  50. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -96
  51. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +0 -28
  52. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -87
  53. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +0 -93
  54. package/dist/lib/parsers/helpers/parse-utils.js +0 -32
  55. package/dist/lib/parsers/parse-3d-tile-batched-model.js +0 -33
  56. package/dist/lib/parsers/parse-3d-tile-composite.js +0 -24
  57. package/dist/lib/parsers/parse-3d-tile-gltf.js +0 -29
  58. package/dist/lib/parsers/parse-3d-tile-header.js +0 -194
  59. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -172
  60. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -441
  61. package/dist/lib/parsers/parse-3d-tile.js +0 -33
  62. package/dist/lib/utils/obb/s2-corners-to-obb.js +0 -37
  63. package/dist/lib/utils/s2/converters/s2-to-boundary.js +0 -61
  64. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +0 -36
  65. package/dist/lib/utils/s2/converters/s2-to-region.js +0 -59
  66. package/dist/lib/utils/s2/index.js +0 -23
  67. package/dist/lib/utils/s2/s2-geometry-functions.js +0 -29
  68. package/dist/lib/utils/s2/s2-token-functions.js +0 -68
  69. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +0 -32
  70. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +0 -260
  71. package/dist/lib/utils/version.js +0 -7
  72. package/dist/tile-3d-subtree-loader.js +0 -23
  73. package/dist/tile-3d-writer.js +0 -27
  74. package/dist/tiles-3d-loader.js +0 -80
  75. package/dist/types.js +0 -2
package/dist/dist.min.js CHANGED
@@ -69,16 +69,45 @@
69
69
  }
70
70
  });
71
71
 
72
+ // ../loader-utils/src/lib/option-utils/merge-loader-options.ts
73
+ function mergeLoaderOptions(baseOptions, newOptions) {
74
+ return mergeOptionsRecursively(baseOptions || {}, newOptions);
75
+ }
76
+ function mergeOptionsRecursively(baseOptions, newOptions) {
77
+ const options = { ...baseOptions };
78
+ for (const [key, newValue] of Object.entries(newOptions)) {
79
+ if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
80
+ options[key] = mergeOptionsRecursively(options[key] || {}, newOptions[key]);
81
+ } else {
82
+ options[key] = newOptions[key];
83
+ }
84
+ }
85
+ return options;
86
+ }
87
+ var init_merge_loader_options = __esm({
88
+ "../loader-utils/src/lib/option-utils/merge-loader-options.ts"() {
89
+ }
90
+ });
91
+
72
92
  // ../worker-utils/src/lib/env-utils/version.ts
73
- var DEFAULT_VERSION, VERSION;
74
- var init_version = __esm({
75
- "../worker-utils/src/lib/env-utils/version.ts"() {
76
- DEFAULT_VERSION = "beta";
77
- VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
93
+ function getVersion() {
94
+ if (!globalThis._loadersgl_?.version) {
95
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
78
96
  if (typeof __VERSION__ === "undefined") {
79
97
  console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
98
+ globalThis._loadersgl_.version = NPM_TAG;
99
+ } else {
100
+ globalThis._loadersgl_.version = __VERSION__;
80
101
  }
81
102
  }
103
+ return globalThis._loadersgl_.version;
104
+ }
105
+ var NPM_TAG, VERSION;
106
+ var init_version = __esm({
107
+ "../worker-utils/src/lib/env-utils/version.ts"() {
108
+ NPM_TAG = "beta";
109
+ VERSION = getVersion();
110
+ }
82
111
  });
83
112
 
84
113
  // ../worker-utils/src/lib/env-utils/assert.ts
@@ -543,12 +572,11 @@
543
572
  assert3(url);
544
573
  return url;
545
574
  }
546
- var NPM_TAG;
547
575
  var init_get_worker_url = __esm({
548
576
  "../worker-utils/src/lib/worker-api/get-worker-url.ts"() {
549
577
  init_assert2();
550
578
  init_globals2();
551
- NPM_TAG = "beta";
579
+ init_version();
552
580
  }
553
581
  });
554
582
 
@@ -596,7 +624,7 @@
596
624
  }
597
625
  if (options.CDN) {
598
626
  assert3(options.CDN.startsWith("http"));
599
- return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
627
+ return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
600
628
  }
601
629
  if (isWorker) {
602
630
  return `../src/libs/${libraryName}`;
@@ -652,15 +680,13 @@
652
680
  }
653
681
  return await node.readFileAsText(url);
654
682
  }
655
- var node, LATEST, VERSION2, loadLibraryPromises;
683
+ var node, loadLibraryPromises;
656
684
  var init_library_utils = __esm({
657
685
  "../worker-utils/src/lib/library-utils/library-utils.ts"() {
658
686
  init_globals2();
659
687
  node = __toModule(require_require_utils());
660
688
  init_assert2();
661
689
  init_version();
662
- LATEST = "beta";
663
- VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
664
690
  loadLibraryPromises = {};
665
691
  }
666
692
  });
@@ -1190,9 +1216,9 @@
1190
1216
  }
1191
1217
  });
1192
1218
 
1193
- // (disabled):fs
1194
- var require_fs = __commonJS({
1195
- "(disabled):fs"() {
1219
+ // ../loader-utils/src/lib/node/fs.browser.ts
1220
+ var init_fs_browser = __esm({
1221
+ "../loader-utils/src/lib/node/fs.browser.ts"() {
1196
1222
  }
1197
1223
  });
1198
1224
 
@@ -1207,15 +1233,15 @@
1207
1233
  });
1208
1234
 
1209
1235
  // ../loader-utils/src/lib/file-provider/file-handle.ts
1210
- var import_fs, FileHandle;
1236
+ var FileHandle;
1211
1237
  var init_file_handle = __esm({
1212
1238
  "../loader-utils/src/lib/file-provider/file-handle.ts"() {
1213
- import_fs = __toModule(require_fs());
1239
+ init_fs_browser();
1214
1240
  FileHandle = class {
1215
1241
  constructor(fileDescriptor, stats) {
1216
1242
  this.read = (buffer, offset, length4, position) => {
1217
1243
  return new Promise((s2) => {
1218
- (0, import_fs.read)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
1244
+ (void 0)(this.fileDescriptor, buffer, offset, length4, position, (_err, bytesRead, buffer2) => s2({ bytesRead, buffer: buffer2 }));
1219
1245
  });
1220
1246
  };
1221
1247
  this.fileDescriptor = fileDescriptor;
@@ -1224,18 +1250,14 @@
1224
1250
  static async open(path) {
1225
1251
  const [fd, stats] = await Promise.all([
1226
1252
  new Promise((resolve2, reject) => {
1227
- (0, import_fs.open)(path, void 0, void 0, (_err, fd2) => _err ? reject(_err) : resolve2(fd2));
1253
+ (void 0)(path, void 0, void 0, (_err, fd2) => _err ? reject(_err) : resolve2(fd2));
1228
1254
  }),
1229
- new Promise((resolve2, reject) => {
1230
- (0, import_fs.stat)(path, { bigint: true }, (_err, stats2) => _err ? reject(_err) : resolve2(stats2));
1231
- })
1255
+ (void 0)(path, { bigint: true })
1232
1256
  ]);
1233
1257
  return new FileHandle(fd, stats);
1234
1258
  }
1235
1259
  async close() {
1236
- return new Promise((resolve2) => {
1237
- (0, import_fs.close)(this.fileDescriptor, (_err) => resolve2());
1238
- });
1260
+ return (void 0)(this.fileDescriptor);
1239
1261
  }
1240
1262
  get stat() {
1241
1263
  return this.stats;
@@ -1350,6 +1372,7 @@
1350
1372
  init_loader_types();
1351
1373
  init_assert();
1352
1374
  init_globals();
1375
+ init_merge_loader_options();
1353
1376
  init_parse_with_worker();
1354
1377
  init_parse_json();
1355
1378
  init_array_buffer_utils();
@@ -5767,11 +5790,11 @@
5767
5790
  });
5768
5791
 
5769
5792
  // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
5770
- var VERSION3, isBrowser4;
5793
+ var VERSION2, isBrowser4;
5771
5794
  var init_globals4 = __esm({
5772
5795
  "../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js"() {
5773
5796
  init_is_browser();
5774
- VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
5797
+ VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
5775
5798
  isBrowser4 = isBrowser3();
5776
5799
  }
5777
5800
  });
@@ -6108,7 +6131,7 @@
6108
6131
  id: ""
6109
6132
  };
6110
6133
  _defineProperty(this, "id", void 0);
6111
- _defineProperty(this, "VERSION", VERSION3);
6134
+ _defineProperty(this, "VERSION", VERSION2);
6112
6135
  _defineProperty(this, "_startTs", getHiResTimestamp());
6113
6136
  _defineProperty(this, "_deltaTs", getHiResTimestamp());
6114
6137
  _defineProperty(this, "_storage", void 0);
@@ -6311,7 +6334,7 @@
6311
6334
  return noop;
6312
6335
  }
6313
6336
  };
6314
- _defineProperty(Log, "VERSION", VERSION3);
6337
+ _defineProperty(Log, "VERSION", VERSION2);
6315
6338
  }
6316
6339
  });
6317
6340
 
@@ -7049,6 +7072,7 @@
7049
7072
  }
7050
7073
  async function parseWithLoader(loader, data, options, context) {
7051
7074
  validateWorkerVersion(loader);
7075
+ options = mergeLoaderOptions(loader.options, options);
7052
7076
  if (isResponse(data)) {
7053
7077
  const response = data;
7054
7078
  const { ok, redirected, status, statusText, type, url } = response;
@@ -7079,6 +7103,7 @@
7079
7103
  init_normalize_loader();
7080
7104
  init_is_type();
7081
7105
  init_option_utils();
7106
+ init_src2();
7082
7107
  init_get_data();
7083
7108
  init_loader_context();
7084
7109
  init_resource_utils();
@@ -7158,10 +7183,10 @@
7158
7183
  });
7159
7184
 
7160
7185
  // src/lib/utils/version.ts
7161
- var VERSION4;
7186
+ var VERSION3;
7162
7187
  var init_version2 = __esm({
7163
7188
  "src/lib/utils/version.ts"() {
7164
- VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
7189
+ VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
7165
7190
  }
7166
7191
  });
7167
7192
 
@@ -7207,10 +7232,10 @@
7207
7232
  });
7208
7233
 
7209
7234
  // ../draco/src/lib/utils/version.ts
7210
- var VERSION5;
7235
+ var VERSION4;
7211
7236
  var init_version3 = __esm({
7212
7237
  "../draco/src/lib/utils/version.ts"() {
7213
- VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
7238
+ VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
7214
7239
  }
7215
7240
  });
7216
7241
 
@@ -7231,7 +7256,7 @@
7231
7256
  name: "Draco",
7232
7257
  id: "draco",
7233
7258
  module: "draco",
7234
- version: VERSION5,
7259
+ version: VERSION4,
7235
7260
  worker: true,
7236
7261
  extensions: ["drc"],
7237
7262
  mimeTypes: ["application/octet-stream"],
@@ -7775,7 +7800,7 @@
7775
7800
  var init_draco_module_loader = __esm({
7776
7801
  "../draco/src/lib/draco-module-loader.ts"() {
7777
7802
  init_src();
7778
- DRACO_DECODER_VERSION = "1.5.5";
7803
+ DRACO_DECODER_VERSION = "1.5.6";
7779
7804
  DRACO_ENCODER_VERSION = "1.4.1";
7780
7805
  STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
7781
7806
  DRACO_EXTERNAL_LIBRARIES = {
@@ -9060,10 +9085,10 @@
9060
9085
  });
9061
9086
 
9062
9087
  // ../images/src/lib/utils/version.ts
9063
- var VERSION6;
9088
+ var VERSION5;
9064
9089
  var init_version4 = __esm({
9065
9090
  "../images/src/lib/utils/version.ts"() {
9066
- VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
9091
+ VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
9067
9092
  }
9068
9093
  });
9069
9094
 
@@ -9512,7 +9537,7 @@
9512
9537
  id: "image",
9513
9538
  module: "images",
9514
9539
  name: "Images",
9515
- version: VERSION6,
9540
+ version: VERSION5,
9516
9541
  mimeTypes: MIME_TYPES,
9517
9542
  extensions: EXTENSIONS,
9518
9543
  parse: parseImage,
@@ -9582,6 +9607,30 @@
9582
9607
  }
9583
9608
  });
9584
9609
 
9610
+ // ../gltf/src/lib/gltf-utils/gltf-constants.ts
9611
+ var COMPONENTS, BYTES;
9612
+ var init_gltf_constants = __esm({
9613
+ "../gltf/src/lib/gltf-utils/gltf-constants.ts"() {
9614
+ COMPONENTS = {
9615
+ SCALAR: 1,
9616
+ VEC2: 2,
9617
+ VEC3: 3,
9618
+ VEC4: 4,
9619
+ MAT2: 4,
9620
+ MAT3: 9,
9621
+ MAT4: 16
9622
+ };
9623
+ BYTES = {
9624
+ 5120: 1,
9625
+ 5121: 1,
9626
+ 5122: 2,
9627
+ 5123: 2,
9628
+ 5125: 4,
9629
+ 5126: 4
9630
+ };
9631
+ }
9632
+ });
9633
+
9585
9634
  // ../gltf/src/lib/gltf-utils/gltf-utils.ts
9586
9635
  function getAccessorTypeFromSize(size) {
9587
9636
  const type = TYPES[size - 1];
@@ -9603,6 +9652,27 @@
9603
9652
  assert7(byteLength >= 0 && byteLength <= bufferView.byteLength);
9604
9653
  return { ArrayType, length: length4, byteLength };
9605
9654
  }
9655
+ function getFloat32ArrayForAccessor(gltfData, texCoordAccessor) {
9656
+ const accessor = gltfData.json.accessors?.[texCoordAccessor];
9657
+ if (accessor && typeof accessor.bufferView !== "undefined") {
9658
+ const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
9659
+ if (bufferView) {
9660
+ const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
9661
+ const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
9662
+ const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView);
9663
+ const bytes = BYTES[accessor.componentType];
9664
+ const components = COMPONENTS[accessor.type];
9665
+ const elementAddressScale = bufferView.byteStride || bytes * components;
9666
+ const result = new Float32Array(length4);
9667
+ for (let i2 = 0; i2 < accessor.count; i2++) {
9668
+ const uv = new ArrayType(arrayBuffer, byteOffset + i2 * elementAddressScale, 2);
9669
+ result.set(uv, i2 * components);
9670
+ }
9671
+ return result;
9672
+ }
9673
+ }
9674
+ return null;
9675
+ }
9606
9676
  function getMemoryUsageGLTF(gltf) {
9607
9677
  let { images, bufferViews } = gltf;
9608
9678
  images = images || [];
@@ -9620,6 +9690,7 @@
9620
9690
  var init_gltf_utils = __esm({
9621
9691
  "../gltf/src/lib/gltf-utils/gltf-utils.ts"() {
9622
9692
  init_assert6();
9693
+ init_gltf_constants();
9623
9694
  MIPMAP_FACTOR = 1.33;
9624
9695
  TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
9625
9696
  ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
@@ -10082,25 +10153,44 @@
10082
10153
  }
10083
10154
  });
10084
10155
 
10085
- // ../gltf/src/lib/extensions/data-processing.ts
10156
+ // ../gltf/src/lib/extensions/utils/3d-tiles-utils.ts
10086
10157
  function getArrayElementByteSize(attributeType, componentType) {
10087
10158
  return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10088
10159
  }
10089
- function convertRawBufferToMetadataArray(typedArray, attributeType, componentType, elementCount = 1) {
10160
+ function getOffsetsForProperty(scenegraph, bufferViewIndex, offsetType, numberOfElements) {
10161
+ if (offsetType !== "UINT8" && offsetType !== "UINT16" && offsetType !== "UINT32" && offsetType !== "UINT64") {
10162
+ return null;
10163
+ }
10164
+ const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
10165
+ const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
10166
+ if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
10167
+ return null;
10168
+ }
10169
+ return arrayOffsets;
10170
+ }
10171
+ function convertRawBufferToMetadataArray(data, attributeType, componentType, elementCount = 1) {
10090
10172
  const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
10091
10173
  const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[componentType];
10092
- const length4 = elementCount * numberOfComponents;
10093
10174
  const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType];
10094
- const offset = typedArray.byteOffset % size ? Math.ceil(typedArray.byteOffset / size) * size : typedArray.byteOffset;
10095
- return new ArrayType(typedArray.buffer, offset, length4);
10175
+ const length4 = elementCount * numberOfComponents;
10176
+ const byteLength = length4 * size;
10177
+ let buffer = data.buffer;
10178
+ let offset = data.byteOffset;
10179
+ if (offset % size !== 0) {
10180
+ const bufferArray = new Uint8Array(buffer);
10181
+ buffer = bufferArray.slice(offset, offset + byteLength).buffer;
10182
+ offset = 0;
10183
+ }
10184
+ return new ArrayType(buffer, offset, length4);
10096
10185
  }
10097
10186
  function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
10098
10187
  const json = scenegraph.gltf.json;
10099
10188
  const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
10100
10189
  const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10101
- const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10102
- const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10103
- const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10190
+ const textureCoordinates = getFloat32ArrayForAccessor(scenegraph.gltf, texCoordAccessorIndex);
10191
+ if (!textureCoordinates) {
10192
+ return null;
10193
+ }
10104
10194
  const textureIndex = textureInfo.index;
10105
10195
  const imageIndex = json.textures?.[textureIndex]?.source;
10106
10196
  if (typeof imageIndex !== "undefined") {
@@ -10118,8 +10208,9 @@
10118
10208
  return null;
10119
10209
  }
10120
10210
  function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
10121
- if (propertyData === null)
10211
+ if (!propertyData?.length) {
10122
10212
  return;
10213
+ }
10123
10214
  const featureIndices = [];
10124
10215
  for (const texelData of propertyData) {
10125
10216
  let index = featureTable.findIndex((item) => item === texelData);
@@ -10143,12 +10234,12 @@
10143
10234
  primitive.attributes[attributeName] = accessorIndex;
10144
10235
  }
10145
10236
  function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
10146
- const CHANNELS_MAP = [
10147
- { offset: 0, shift: 0 },
10148
- { offset: 1, shift: 8 },
10149
- { offset: 2, shift: 16 },
10150
- { offset: 3, shift: 24 }
10151
- ];
10237
+ const CHANNELS_MAP = {
10238
+ r: { offset: 0, shift: 0 },
10239
+ g: { offset: 1, shift: 8 },
10240
+ b: { offset: 2, shift: 16 },
10241
+ a: { offset: 3, shift: 24 }
10242
+ };
10152
10243
  const u = textureCoordinates[index];
10153
10244
  const v = textureCoordinates[index + 1];
10154
10245
  let components = 1;
@@ -10157,7 +10248,7 @@
10157
10248
  const offset = coordinatesToOffset(u, v, parsedImage, components);
10158
10249
  let value = 0;
10159
10250
  for (const c of channels) {
10160
- const map2 = CHANNELS_MAP[c];
10251
+ const map2 = typeof c === "number" ? Object.values(CHANNELS_MAP)[c] : CHANNELS_MAP[c];
10161
10252
  const imageOffset = offset + map2.offset;
10162
10253
  const imageData = getImageData(parsedImage);
10163
10254
  if (imageData.data.length <= imageOffset) {
@@ -10180,8 +10271,8 @@
10180
10271
  return offset;
10181
10272
  }
10182
10273
  var ATTRIBUTE_TYPE_TO_COMPONENTS2, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2;
10183
- var init_data_processing = __esm({
10184
- "../gltf/src/lib/extensions/data-processing.ts"() {
10274
+ var init_d_tiles_utils = __esm({
10275
+ "../gltf/src/lib/extensions/utils/3d-tiles-utils.ts"() {
10185
10276
  init_gltf_utils();
10186
10277
  init_src8();
10187
10278
  init_src7();
@@ -10224,17 +10315,91 @@
10224
10315
  }
10225
10316
  });
10226
10317
 
10318
+ // ../gltf/src/lib/extensions/EXT_mesh_features.ts
10319
+ var EXT_mesh_features_exports = {};
10320
+ __export(EXT_mesh_features_exports, {
10321
+ decode: () => decode,
10322
+ name: () => name
10323
+ });
10324
+ async function decode(gltfData, options) {
10325
+ const scenegraph = new GLTFScenegraph(gltfData);
10326
+ decodeExtMeshFeatures(scenegraph, options);
10327
+ }
10328
+ function decodeExtMeshFeatures(scenegraph, options) {
10329
+ const json = scenegraph.gltf.json;
10330
+ if (!json.meshes) {
10331
+ return;
10332
+ }
10333
+ for (const mesh of json.meshes) {
10334
+ for (const primitive of mesh.primitives) {
10335
+ processMeshPrimitiveFeatures(scenegraph, primitive, options);
10336
+ }
10337
+ }
10338
+ }
10339
+ function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
10340
+ if (!options?.gltf?.loadBuffers) {
10341
+ return;
10342
+ }
10343
+ const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
10344
+ const featureIds = extension?.featureIds;
10345
+ if (!featureIds) {
10346
+ return;
10347
+ }
10348
+ for (const featureId of featureIds) {
10349
+ let featureIdData = null;
10350
+ if (typeof featureId.attribute !== "undefined") {
10351
+ const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
10352
+ const accessorIndex = primitive.attributes[accessorKey];
10353
+ featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex);
10354
+ } else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
10355
+ featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
10356
+ } else {
10357
+ }
10358
+ featureId.data = featureIdData;
10359
+ }
10360
+ }
10361
+ var EXT_MESH_FEATURES_NAME, name;
10362
+ var init_EXT_mesh_features = __esm({
10363
+ "../gltf/src/lib/extensions/EXT_mesh_features.ts"() {
10364
+ init_gltf_scenegraph();
10365
+ init_d_tiles_utils();
10366
+ EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
10367
+ name = EXT_MESH_FEATURES_NAME;
10368
+ }
10369
+ });
10370
+
10227
10371
  // ../gltf/src/lib/extensions/EXT_structural_metadata.ts
10228
10372
  var EXT_structural_metadata_exports = {};
10229
10373
  __export(EXT_structural_metadata_exports, {
10230
- decode: () => decode,
10374
+ decode: () => decode2,
10375
+ getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
10231
10376
  getPropertyTablePopulated: () => getPropertyTablePopulated,
10232
- name: () => name
10377
+ name: () => name2
10233
10378
  });
10234
- async function decode(gltfData, options) {
10379
+ async function decode2(gltfData, options) {
10235
10380
  const scenegraph = new GLTFScenegraph(gltfData);
10236
10381
  decodeExtStructuralMetadata(scenegraph, options);
10237
10382
  }
10383
+ function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
10384
+ if (extension.propertyTables) {
10385
+ const firstPropertyTable = extension?.propertyTables[0];
10386
+ const propertyTableWithData = {};
10387
+ for (const propertyName in firstPropertyTable.properties) {
10388
+ propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
10389
+ }
10390
+ return propertyTableWithData;
10391
+ }
10392
+ if (extension.propertyTextures) {
10393
+ const firstPropertyTexture = extension?.propertyTextures[0];
10394
+ const propertyTableWithData = {};
10395
+ for (const propertyName in firstPropertyTexture.properties) {
10396
+ propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
10397
+ }
10398
+ return propertyTableWithData;
10399
+ }
10400
+ console.warn("Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.");
10401
+ return null;
10402
+ }
10238
10403
  function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
10239
10404
  const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10240
10405
  const propertyTable = extension?.propertyTables?.[propertyTableIndex];
@@ -10245,30 +10410,53 @@
10245
10410
  throw new Error(`Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`);
10246
10411
  }
10247
10412
  function decodeExtStructuralMetadata(scenegraph, options) {
10413
+ if (!options.gltf?.loadBuffers) {
10414
+ return;
10415
+ }
10248
10416
  const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
10249
- if (!extension?.schema) {
10417
+ if (!extension) {
10250
10418
  return;
10251
10419
  }
10420
+ if (options.gltf?.loadImages) {
10421
+ decodePropertyTextures(scenegraph, extension);
10422
+ }
10423
+ decodePropertyTables(scenegraph, extension);
10424
+ }
10425
+ function decodePropertyTextures(scenegraph, extension) {
10252
10426
  const propertyTextures = extension.propertyTextures;
10253
10427
  const json = scenegraph.gltf.json;
10254
- if (propertyTextures && json.meshes && options?.gltf?.loadImages) {
10428
+ if (propertyTextures && json.meshes) {
10255
10429
  for (const mesh of json.meshes) {
10256
10430
  for (const primitive of mesh.primitives) {
10257
10431
  processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
10258
10432
  }
10259
10433
  }
10260
10434
  }
10261
- const schemaClasses = extension.schema.classes;
10435
+ }
10436
+ function decodePropertyTables(scenegraph, extension) {
10437
+ const schema = extension.schema;
10438
+ if (!schema) {
10439
+ return;
10440
+ }
10441
+ const schemaClasses = schema.classes;
10262
10442
  const propertyTables = extension.propertyTables;
10263
10443
  if (schemaClasses && propertyTables) {
10264
10444
  for (const schemaName in schemaClasses) {
10265
10445
  const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
10266
10446
  if (propertyTable) {
10267
- processPropertyTable(scenegraph, extension.schema, propertyTable);
10447
+ processPropertyTable(scenegraph, schema, propertyTable);
10268
10448
  }
10269
10449
  }
10270
10450
  }
10271
10451
  }
10452
+ function findPropertyTableByClass(propertyTables, schemaClassName) {
10453
+ for (const propertyTable of propertyTables) {
10454
+ if (propertyTable.class === schemaClassName) {
10455
+ return propertyTable;
10456
+ }
10457
+ }
10458
+ return null;
10459
+ }
10272
10460
  function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
10273
10461
  if (!propertyTextures) {
10274
10462
  return;
@@ -10291,9 +10479,9 @@
10291
10479
  extension.dataAttributeNames = [];
10292
10480
  }
10293
10481
  const className = propertyTexture.class;
10294
- for (const propName in propertyTexture.properties) {
10295
- const attributeName = `${className}_${propName}`;
10296
- const textureInfoTopLevel = propertyTexture.properties?.[propName];
10482
+ for (const propertyName in propertyTexture.properties) {
10483
+ const attributeName = `${className}_${propertyName}`;
10484
+ const textureInfoTopLevel = propertyTexture.properties?.[propertyName];
10297
10485
  if (!textureInfoTopLevel) {
10298
10486
  continue;
10299
10487
  }
@@ -10329,14 +10517,8 @@
10329
10517
  let data = [];
10330
10518
  const valuesBufferView = propertyTableProperty.values;
10331
10519
  const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
10332
- let arrayOffsets = null;
10333
- if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined" && typeof propertyTableProperty.arrayOffsetType !== "undefined") {
10334
- arrayOffsets = getOffsetArray(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
10335
- }
10336
- let stringOffsets = null;
10337
- if (typeof propertyTableProperty.stringOffsets !== "undefined" && typeof propertyTableProperty.stringOffsetType !== "undefined") {
10338
- stringOffsets = getOffsetArray(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
10339
- }
10520
+ const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements);
10521
+ const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements);
10340
10522
  switch (classProperty.type) {
10341
10523
  case "SCALAR":
10342
10524
  case "VEC2":
@@ -10364,11 +10546,17 @@
10364
10546
  }
10365
10547
  return data;
10366
10548
  }
10367
- function getOffsetArray(scenegraph, offsets, offsetType, numberOfElements) {
10368
- const arrayOffsetsBufferView = offsets;
10369
- const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(arrayOffsetsBufferView);
10370
- const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
10371
- return arrayOffsets;
10549
+ function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
10550
+ if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined") {
10551
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || "UINT32", numberOfElements);
10552
+ }
10553
+ return null;
10554
+ }
10555
+ function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
10556
+ if (typeof propertyTableProperty.stringOffsets !== "undefined") {
10557
+ return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType || "UINT32", numberOfElements);
10558
+ }
10559
+ return null;
10372
10560
  }
10373
10561
  function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10374
10562
  const isArray2 = classProperty.array;
@@ -10378,52 +10566,42 @@
10378
10566
  let valuesData;
10379
10567
  if (classProperty.componentType) {
10380
10568
  valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
10569
+ if (!valuesData) {
10570
+ valuesData = valuesDataBytes;
10571
+ }
10381
10572
  } else {
10382
10573
  valuesData = valuesDataBytes;
10383
10574
  }
10384
10575
  if (isArray2) {
10385
10576
  if (arrayOffsets) {
10386
- return handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
10577
+ return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
10387
10578
  }
10388
10579
  if (arrayCount) {
10389
- return handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
10580
+ return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
10390
10581
  }
10391
10582
  return [];
10392
10583
  }
10393
- const attributeValueArray = [];
10394
- for (let index = 0; index < numberOfElements; index++) {
10395
- const value = valuesData[index];
10396
- attributeValueArray.push(value);
10397
- }
10398
- return attributeValueArray;
10584
+ return valuesData;
10399
10585
  }
10400
- function handleVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize) {
10586
+ function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) {
10401
10587
  const attributeValueArray = [];
10402
10588
  for (let index = 0; index < numberOfElements; index++) {
10403
- const array = [];
10404
10589
  const arrayOffset = arrayOffsets[index];
10405
10590
  const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10406
- if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
10407
- const typedArrayOffset = arrayOffset / elementSize;
10408
- const elementCount = arrayByteSize / elementSize;
10409
- for (let i2 = 0; i2 < elementCount; i2++) {
10410
- const value = valuesData[typedArrayOffset + i2];
10411
- array.push(value);
10412
- }
10591
+ if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
10592
+ break;
10413
10593
  }
10414
- attributeValueArray.push(array);
10594
+ const typedArrayOffset = arrayOffset / valueSize;
10595
+ const elementCount = arrayByteSize / valueSize;
10596
+ attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));
10415
10597
  }
10416
10598
  return attributeValueArray;
10417
10599
  }
10418
- function handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
10600
+ function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
10419
10601
  const attributeValueArray = [];
10420
10602
  for (let index = 0; index < numberOfElements; index++) {
10421
- const array = [];
10422
- for (let i2 = 0; i2 < arrayCount; i2++) {
10423
- const value = valuesData[i2];
10424
- array.push(value);
10425
- }
10426
- attributeValueArray.push(array);
10603
+ const elementOffset = index * arrayCount;
10604
+ attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));
10427
10605
  }
10428
10606
  return attributeValueArray;
10429
10607
  }
@@ -10449,9 +10627,6 @@
10449
10627
  return [];
10450
10628
  }
10451
10629
  function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
10452
- const data = [];
10453
- const isArray2 = classProperty.array;
10454
- const arrayCount = classProperty.count;
10455
10630
  const enumType = classProperty.enumType;
10456
10631
  if (!enumType) {
10457
10632
  throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");
@@ -10463,69 +10638,77 @@
10463
10638
  const enumValueType = enumEntry.valueType || "UINT16";
10464
10639
  const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
10465
10640
  const elementCount = valuesDataBytes.byteLength / elementSize;
10466
- const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
10467
- if (isArray2) {
10641
+ let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
10642
+ if (!valuesData) {
10643
+ valuesData = valuesDataBytes;
10644
+ }
10645
+ if (classProperty.array) {
10468
10646
  if (arrayOffsets) {
10469
- return handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize, enumEntry);
10470
- }
10647
+ return parseVariableLengthArrayENUM({
10648
+ valuesData,
10649
+ numberOfElements,
10650
+ arrayOffsets,
10651
+ valuesDataBytesLength: valuesDataBytes.length,
10652
+ elementSize,
10653
+ enumEntry
10654
+ });
10655
+ }
10656
+ const arrayCount = classProperty.count;
10471
10657
  if (arrayCount) {
10472
- return handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
10658
+ return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
10473
10659
  }
10474
10660
  return [];
10475
10661
  }
10476
- for (let index = 0; index < numberOfElements; index++) {
10477
- const enumValue = valuesData[index];
10478
- const enumObject = getEnumByValue(enumEntry, enumValue);
10479
- if (enumObject) {
10480
- data.push(enumObject.name);
10481
- }
10482
- }
10483
- return data;
10662
+ return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);
10484
10663
  }
10485
- function handleVariableLengthArrayENUM(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize, enumEntry) {
10664
+ function parseVariableLengthArrayENUM(params) {
10665
+ const {
10666
+ valuesData,
10667
+ numberOfElements,
10668
+ arrayOffsets,
10669
+ valuesDataBytesLength,
10670
+ elementSize,
10671
+ enumEntry
10672
+ } = params;
10486
10673
  const attributeValueArray = [];
10487
10674
  for (let index = 0; index < numberOfElements; index++) {
10488
- const array = [];
10489
10675
  const arrayOffset = arrayOffsets[index];
10490
10676
  const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
10491
- if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {
10492
- const typedArrayOffset = arrayOffset / elementSize;
10493
- const elementCount = arrayByteSize / elementSize;
10494
- for (let i2 = 0; i2 < elementCount; i2++) {
10495
- const value = valuesData[typedArrayOffset + i2];
10496
- const enumObject = getEnumByValue(enumEntry, value);
10497
- if (enumObject) {
10498
- array.push(enumObject.name);
10499
- }
10500
- }
10677
+ if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
10678
+ break;
10501
10679
  }
10680
+ const typedArrayOffset = arrayOffset / elementSize;
10681
+ const elementCount = arrayByteSize / elementSize;
10682
+ const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);
10502
10683
  attributeValueArray.push(array);
10503
10684
  }
10504
10685
  return attributeValueArray;
10505
10686
  }
10506
- function handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
10687
+ function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
10507
10688
  const attributeValueArray = [];
10508
10689
  for (let index = 0; index < numberOfElements; index++) {
10509
- const array = [];
10510
- for (let i2 = 0; i2 < arrayCount; i2++) {
10511
- const value = valuesData[i2];
10512
- const enumObject = getEnumByValue(enumEntry, value);
10513
- if (enumObject) {
10514
- array.push(enumObject.name);
10515
- }
10516
- }
10690
+ const elementOffset = arrayCount * index;
10691
+ const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);
10517
10692
  attributeValueArray.push(array);
10518
10693
  }
10519
10694
  return attributeValueArray;
10520
10695
  }
10521
- function findPropertyTableByClass(propertyTables, schemaClassName) {
10522
- for (let i2 = 0, len2 = propertyTables.length; i2 < len2; i2++) {
10523
- const propertyTable = propertyTables[i2];
10524
- if (propertyTable.class === schemaClassName) {
10525
- return propertyTable;
10696
+ function getEnumsArray(valuesData, offset, count, enumEntry) {
10697
+ const array = [];
10698
+ for (let i2 = 0; i2 < count; i2++) {
10699
+ if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {
10700
+ array.push("");
10701
+ } else {
10702
+ const value = valuesData[offset + i2];
10703
+ const enumObject = getEnumByValue(enumEntry, value);
10704
+ if (enumObject) {
10705
+ array.push(enumObject.name);
10706
+ } else {
10707
+ array.push("");
10708
+ }
10526
10709
  }
10527
10710
  }
10528
- return null;
10711
+ return array;
10529
10712
  }
10530
10713
  function getEnumByValue(enumEntry, value) {
10531
10714
  for (const enumValue of enumEntry.values) {
@@ -10535,79 +10718,13 @@
10535
10718
  }
10536
10719
  return null;
10537
10720
  }
10538
- var EXT_STRUCTURAL_METADATA_NAME, name;
10721
+ var EXT_STRUCTURAL_METADATA_NAME, name2;
10539
10722
  var init_EXT_structural_metadata = __esm({
10540
10723
  "../gltf/src/lib/extensions/EXT_structural_metadata.ts"() {
10541
10724
  init_gltf_scenegraph();
10542
- init_data_processing();
10725
+ init_d_tiles_utils();
10543
10726
  EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
10544
- name = EXT_STRUCTURAL_METADATA_NAME;
10545
- }
10546
- });
10547
-
10548
- // ../gltf/src/lib/extensions/EXT_mesh_features.ts
10549
- var EXT_mesh_features_exports = {};
10550
- __export(EXT_mesh_features_exports, {
10551
- decode: () => decode2,
10552
- name: () => name2
10553
- });
10554
- async function decode2(gltfData, options) {
10555
- const scenegraph = new GLTFScenegraph(gltfData);
10556
- decodeExtMeshFeatures(scenegraph, options);
10557
- }
10558
- function decodeExtMeshFeatures(scenegraph, options) {
10559
- const json = scenegraph.gltf.json;
10560
- if (!json.meshes) {
10561
- return;
10562
- }
10563
- for (const mesh of json.meshes) {
10564
- for (const primitive of mesh.primitives) {
10565
- processMeshPrimitiveFeatures(scenegraph, primitive, options);
10566
- }
10567
- }
10568
- }
10569
- function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
10570
- const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
10571
- const featureIds = extension?.featureIds;
10572
- if (!featureIds)
10573
- return;
10574
- if (!extension.dataAttributeNames) {
10575
- extension.dataAttributeNames = [];
10576
- }
10577
- let featureIdCount = 0;
10578
- for (const featureId of featureIds) {
10579
- let propertyTable = null;
10580
- if (typeof featureId.propertyTable === "number") {
10581
- propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);
10582
- }
10583
- let propertyData = null;
10584
- if (typeof featureId.attribute !== "undefined") {
10585
- const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
10586
- const accessorIndex = primitive.attributes[accessorKey];
10587
- const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);
10588
- propertyData = Array.prototype.slice.call(propertyDataTypedArray);
10589
- } else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
10590
- propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
10591
- } else {
10592
- }
10593
- const attributeName = featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;
10594
- const featureTable = [];
10595
- if (propertyData) {
10596
- primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive);
10597
- }
10598
- extension.dataAttributeNames.push(attributeName);
10599
- featureId.data = featureTable;
10600
- featureIdCount++;
10601
- }
10602
- }
10603
- var EXT_MESH_FEATURES_NAME, name2;
10604
- var init_EXT_mesh_features = __esm({
10605
- "../gltf/src/lib/extensions/EXT_mesh_features.ts"() {
10606
- init_gltf_scenegraph();
10607
- init_data_processing();
10608
- init_EXT_structural_metadata();
10609
- EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
10610
- name2 = EXT_MESH_FEATURES_NAME;
10727
+ name2 = EXT_STRUCTURAL_METADATA_NAME;
10611
10728
  }
10612
10729
  });
10613
10730
 
@@ -10615,12 +10732,45 @@
10615
10732
  var EXT_feature_metadata_exports = {};
10616
10733
  __export(EXT_feature_metadata_exports, {
10617
10734
  decode: () => decode3,
10735
+ getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
10618
10736
  name: () => name3
10619
10737
  });
10620
10738
  async function decode3(gltfData, options) {
10621
10739
  const scenegraph = new GLTFScenegraph(gltfData);
10622
10740
  decodeExtFeatureMetadata(scenegraph, options);
10623
10741
  }
10742
+ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
10743
+ if (extension.featureTables) {
10744
+ const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
10745
+ if (firstFeatureTableName) {
10746
+ const featureTable = extension.featureTables[firstFeatureTableName];
10747
+ const propertyTable = {};
10748
+ for (const propertyName in featureTable.properties) {
10749
+ propertyTable[propertyName] = featureTable.properties[propertyName].data;
10750
+ }
10751
+ return propertyTable;
10752
+ }
10753
+ }
10754
+ if (extension.featureTextures) {
10755
+ let featureTexture;
10756
+ for (const textureKey in extension.featureTextures) {
10757
+ const texture = extension.featureTextures[textureKey];
10758
+ if (texture.class === metadataClass) {
10759
+ featureTexture = textureKey;
10760
+ }
10761
+ }
10762
+ if (typeof featureTexture === "string") {
10763
+ const featureTable = extension.featureTextures[featureTexture];
10764
+ const propertyTable = {};
10765
+ for (const propertyName in featureTable.properties) {
10766
+ propertyTable[propertyName] = featureTable.properties[propertyName].data;
10767
+ }
10768
+ return propertyTable;
10769
+ }
10770
+ }
10771
+ console.warn("Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.");
10772
+ return null;
10773
+ }
10624
10774
  function decodeExtFeatureMetadata(scenegraph, options) {
10625
10775
  const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
10626
10776
  if (!extension)
@@ -10671,16 +10821,43 @@
10671
10821
  function getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
10672
10822
  const bufferView = featureTableProperty.bufferView;
10673
10823
  const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
10674
- switch (schemaProperty.type) {
10675
- case "STRING": {
10676
- const stringOffsetBufferView = featureTableProperty.stringOffsetBufferView;
10677
- const offsetsData = scenegraph.getTypedArrayForBufferView(stringOffsetBufferView);
10678
- return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
10824
+ if (schemaProperty.type === "STRING") {
10825
+ const offsetsData = getStringOffsets(scenegraph, featureTableProperty, numberOfFeatures);
10826
+ if (!offsetsData) {
10827
+ return [];
10679
10828
  }
10680
- default:
10829
+ return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
10830
+ } else if (isNumericProperty(schemaProperty.type)) {
10831
+ return getNumericAttributes(dataArray, schemaProperty.type, numberOfFeatures);
10681
10832
  }
10682
10833
  return dataArray;
10683
10834
  }
10835
+ function isNumericProperty(schemaPropertyType) {
10836
+ return [
10837
+ "UINT8",
10838
+ "INT16",
10839
+ "UINT16",
10840
+ "INT32",
10841
+ "UINT32",
10842
+ "INT64",
10843
+ "UINT64",
10844
+ "FLOAT32",
10845
+ "FLOAT64"
10846
+ ].includes(schemaPropertyType);
10847
+ }
10848
+ function getStringOffsets(scenegraph, featureTableProperty, numberOfElements) {
10849
+ if (typeof featureTableProperty.stringOffsetBufferView !== "undefined") {
10850
+ return getOffsetsForProperty(scenegraph, featureTableProperty.stringOffsetBufferView, featureTableProperty.offsetType || "UINT32", numberOfElements);
10851
+ }
10852
+ return null;
10853
+ }
10854
+ function getNumericAttributes(valuesDataBytes, propertyType, elementCount) {
10855
+ let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, "SCALAR", propertyType, elementCount);
10856
+ if (!valuesData) {
10857
+ valuesData = valuesDataBytes;
10858
+ }
10859
+ return valuesData;
10860
+ }
10684
10861
  function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
10685
10862
  const json = scenegraph.gltf.json;
10686
10863
  if (!json.meshes) {
@@ -10699,9 +10876,10 @@
10699
10876
  const textureData = [];
10700
10877
  const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
10701
10878
  const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
10702
- const texCoordBufferView = scenegraph.getBufferView(texCoordAccessorIndex);
10703
- const texCoordArray = scenegraph.getTypedArrayForBufferView(texCoordBufferView);
10704
- const textureCoordinates = new Float32Array(texCoordArray.buffer, texCoordArray.byteOffset, texCoordArray.length / 4);
10879
+ const textureCoordinates = getFloat32ArrayForAccessor(scenegraph.gltf, texCoordAccessorIndex);
10880
+ if (!textureCoordinates) {
10881
+ return;
10882
+ }
10705
10883
  const textureIndex = featureTextureProperty.texture.index;
10706
10884
  const texture = json.textures?.[textureIndex];
10707
10885
  const imageIndex = texture?.source;
@@ -10798,14 +10976,10 @@
10798
10976
  function getStringAttributes(data, offsetsData, stringsCount) {
10799
10977
  const stringsArray = [];
10800
10978
  const textDecoder = new TextDecoder("utf8");
10801
- let stringOffset = 0;
10802
- const bytesPerStringSize = 4;
10803
10979
  for (let index = 0; index < stringsCount; index++) {
10804
- const stringByteSize = offsetsData[(index + 1) * bytesPerStringSize] - offsetsData[index * bytesPerStringSize];
10805
- const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
10980
+ const stringData = data.slice(offsetsData[index], offsetsData[index + 1]);
10806
10981
  const stringAttribute = textDecoder.decode(stringData);
10807
10982
  stringsArray.push(stringAttribute);
10808
- stringOffset += stringByteSize;
10809
10983
  }
10810
10984
  return stringsArray;
10811
10985
  }
@@ -10816,24 +10990,25 @@
10816
10990
  init_src8();
10817
10991
  init_gltf_utils();
10818
10992
  init_src7();
10993
+ init_d_tiles_utils();
10819
10994
  EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
10820
10995
  name3 = EXT_FEATURE_METADATA_NAME;
10821
10996
  }
10822
10997
  });
10823
10998
 
10824
10999
  // ../gltf/src/lib/utils/version.ts
10825
- var VERSION7;
11000
+ var VERSION6;
10826
11001
  var init_version5 = __esm({
10827
11002
  "../gltf/src/lib/utils/version.ts"() {
10828
- VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
11003
+ VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
10829
11004
  }
10830
11005
  });
10831
11006
 
10832
11007
  // ../textures/src/lib/utils/version.ts
10833
- var VERSION8;
11008
+ var VERSION7;
10834
11009
  var init_version6 = __esm({
10835
11010
  "../textures/src/lib/utils/version.ts"() {
10836
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
11011
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
10837
11012
  }
10838
11013
  });
10839
11014
 
@@ -11272,7 +11447,7 @@
11272
11447
  name: "Basis",
11273
11448
  id: "basis",
11274
11449
  module: "textures",
11275
- version: VERSION8,
11450
+ version: VERSION7,
11276
11451
  worker: true,
11277
11452
  extensions: ["basis", "ktx2"],
11278
11453
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -11917,30 +12092,6 @@
11917
12092
  }
11918
12093
  });
11919
12094
 
11920
- // ../gltf/src/lib/gltf-utils/gltf-constants.ts
11921
- var COMPONENTS, BYTES;
11922
- var init_gltf_constants = __esm({
11923
- "../gltf/src/lib/gltf-utils/gltf-constants.ts"() {
11924
- COMPONENTS = {
11925
- SCALAR: 1,
11926
- VEC2: 2,
11927
- VEC3: 3,
11928
- VEC4: 4,
11929
- MAT2: 4,
11930
- MAT3: 9,
11931
- MAT4: 16
11932
- };
11933
- BYTES = {
11934
- 5120: 1,
11935
- 5121: 1,
11936
- 5122: 2,
11937
- 5123: 2,
11938
- 5125: 4,
11939
- 5126: 4
11940
- };
11941
- }
11942
- });
11943
-
11944
12095
  // ../gltf/src/lib/extensions/KHR_texture_transform.ts
11945
12096
  var KHR_texture_transform_exports = {};
11946
12097
  __export(KHR_texture_transform_exports, {
@@ -12296,8 +12447,8 @@
12296
12447
  init_KHR_techniques_webgl();
12297
12448
  init_EXT_feature_metadata();
12298
12449
  EXTENSIONS2 = [
12299
- EXT_mesh_features_exports,
12300
12450
  EXT_structural_metadata_exports,
12451
+ EXT_mesh_features_exports,
12301
12452
  EXT_meshopt_compression_exports,
12302
12453
  EXT_texture_webp_exports,
12303
12454
  KHR_texture_basisu_exports,
@@ -12689,7 +12840,7 @@
12689
12840
  name: "glTF",
12690
12841
  id: "gltf",
12691
12842
  module: "gltf",
12692
- version: VERSION7,
12843
+ version: VERSION6,
12693
12844
  extensions: ["gltf", "glb"],
12694
12845
  mimeTypes: ["model/gltf+json", "model/gltf-binary"],
12695
12846
  text: true,
@@ -13495,7 +13646,7 @@
13495
13646
  id: "3d-tiles-subtree",
13496
13647
  name: "3D Tiles Subtree",
13497
13648
  module: "3d-tiles",
13498
- version: VERSION4,
13649
+ version: VERSION3,
13499
13650
  extensions: ["subtree"],
13500
13651
  mimeTypes: ["application/octet-stream"],
13501
13652
  tests: ["subtree"],
@@ -13550,11 +13701,11 @@
13550
13701
  });
13551
13702
 
13552
13703
  // node_modules/@probe.gl/env/dist/utils/globals.js
13553
- var VERSION9, isBrowser6;
13704
+ var VERSION8, isBrowser6;
13554
13705
  var init_globals6 = __esm({
13555
13706
  "node_modules/@probe.gl/env/dist/utils/globals.js"() {
13556
13707
  init_is_browser2();
13557
- VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
13708
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
13558
13709
  isBrowser6 = isBrowser5();
13559
13710
  }
13560
13711
  });
@@ -13889,7 +14040,7 @@
13889
14040
  id: ""
13890
14041
  };
13891
14042
  this.id = void 0;
13892
- this.VERSION = VERSION9;
14043
+ this.VERSION = VERSION8;
13893
14044
  this._startTs = getHiResTimestamp2();
13894
14045
  this._deltaTs = getHiResTimestamp2();
13895
14046
  this._storage = void 0;
@@ -14092,7 +14243,7 @@
14092
14243
  return noop2;
14093
14244
  }
14094
14245
  };
14095
- Log2.VERSION = VERSION9;
14246
+ Log2.VERSION = VERSION8;
14096
14247
  }
14097
14248
  });
14098
14249
 
@@ -15800,7 +15951,7 @@
15800
15951
  id: "3d-tiles",
15801
15952
  name: "3D Tiles",
15802
15953
  module: "3d-tiles",
15803
- version: VERSION4,
15954
+ version: VERSION3,
15804
15955
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
15805
15956
  mimeTypes: ["application/octet-stream"],
15806
15957
  tests: ["cmpt", "pnts", "b3dm", "i3dm"],
@@ -20870,17 +21021,17 @@
20870
21021
  const archive = await parse3DTilesArchive(new DataViewFile(new DataView(data)));
20871
21022
  return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
20872
21023
  }
20873
- var VERSION10, Tiles3DArchiveFileLoader;
21024
+ var VERSION9, Tiles3DArchiveFileLoader;
20874
21025
  var init_d_tiles_archive_loader = __esm({
20875
21026
  "src/3d-tiles-archive-loader.ts"() {
20876
21027
  init_src2();
20877
21028
  init_d_tiles_archive_parser();
20878
- VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
21029
+ VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
20879
21030
  Tiles3DArchiveFileLoader = {
20880
21031
  name: "3tz",
20881
21032
  id: "3tz",
20882
21033
  module: "3d-tiles",
20883
- version: VERSION10,
21034
+ version: VERSION9,
20884
21035
  mimeTypes: ["application/octet-stream", "application/vnd.maxar.archive.3tz+zip"],
20885
21036
  parse: parse3DTilesArchive2,
20886
21037
  extensions: ["3tz"],
@@ -21149,7 +21300,7 @@
21149
21300
  name: "3D Tile",
21150
21301
  id: "3d-tiles",
21151
21302
  module: "3d-tiles",
21152
- version: VERSION4,
21303
+ version: VERSION3,
21153
21304
  extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
21154
21305
  mimeTypes: ["application/octet-stream"],
21155
21306
  encodeSync,