@loaders.gl/i3s 3.1.0-beta.7 → 3.1.0

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 (86) hide show
  1. package/dist/bundle.js +126 -139
  2. package/dist/es5/bundle.js +1 -1
  3. package/dist/es5/bundle.js.map +1 -1
  4. package/dist/es5/i3s-attribute-loader.js +147 -62
  5. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  6. package/dist/es5/i3s-building-scene-layer-loader.js +36 -8
  7. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
  8. package/dist/es5/i3s-content-loader.js +36 -10
  9. package/dist/es5/i3s-content-loader.js.map +1 -1
  10. package/dist/es5/i3s-loader.js +175 -51
  11. package/dist/es5/i3s-loader.js.map +1 -1
  12. package/dist/es5/i3s-node-page-loader.js +51 -8
  13. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  14. package/dist/es5/index.js +6 -6
  15. package/dist/es5/index.js.map +1 -1
  16. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +328 -173
  17. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  18. package/dist/es5/lib/parsers/constants.js +9 -28
  19. package/dist/es5/lib/parsers/constants.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-i3s-attribute.js +69 -27
  21. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
  22. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +62 -28
  23. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +416 -314
  25. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  26. package/dist/es5/lib/parsers/parse-i3s.js +109 -49
  27. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
  28. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +8 -4
  29. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
  30. package/dist/es5/lib/utils/url-utils.js +14 -17
  31. package/dist/es5/lib/utils/url-utils.js.map +1 -1
  32. package/dist/es5/types.js +10 -2
  33. package/dist/es5/types.js.map +1 -1
  34. package/dist/esm/i3s-attribute-loader.js +1 -1
  35. package/dist/esm/i3s-attribute-loader.js.map +1 -1
  36. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  37. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
  38. package/dist/esm/i3s-content-loader.js +1 -1
  39. package/dist/esm/i3s-content-loader.js.map +1 -1
  40. package/dist/esm/i3s-loader.js +1 -1
  41. package/dist/esm/i3s-loader.js.map +1 -1
  42. package/dist/esm/i3s-node-page-loader.js +1 -1
  43. package/dist/esm/i3s-node-page-loader.js.map +1 -1
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +33 -23
  46. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  47. package/dist/esm/lib/parsers/constants.js +2 -18
  48. package/dist/esm/lib/parsers/constants.js.map +1 -1
  49. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +44 -61
  50. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  51. package/dist/esm/lib/parsers/parse-i3s.js +40 -25
  52. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
  53. package/dist/esm/lib/utils/url-utils.js +2 -3
  54. package/dist/esm/lib/utils/url-utils.js.map +1 -1
  55. package/dist/esm/types.js +7 -0
  56. package/dist/esm/types.js.map +1 -1
  57. package/dist/i3s-content-worker.js +62 -81
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +20 -20
  61. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  62. package/dist/lib/helpers/i3s-nodepages-tiles.js +33 -32
  63. package/dist/lib/parsers/constants.d.ts +1 -17
  64. package/dist/lib/parsers/constants.d.ts.map +1 -1
  65. package/dist/lib/parsers/constants.js +3 -21
  66. package/dist/lib/parsers/parse-i3s-attribute.d.ts +1 -1
  67. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
  68. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  69. package/dist/lib/parsers/parse-i3s-tile-content.js +35 -61
  70. package/dist/lib/parsers/parse-i3s.d.ts +5 -3
  71. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
  72. package/dist/lib/parsers/parse-i3s.js +37 -32
  73. package/dist/lib/utils/url-utils.d.ts +6 -6
  74. package/dist/lib/utils/url-utils.d.ts.map +1 -1
  75. package/dist/lib/utils/url-utils.js +5 -5
  76. package/dist/types.d.ts +289 -74
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/types.js +6 -1
  79. package/package.json +8 -8
  80. package/src/index.ts +3 -3
  81. package/src/lib/helpers/i3s-nodepages-tiles.ts +71 -55
  82. package/src/lib/parsers/constants.ts +2 -22
  83. package/src/lib/parsers/parse-i3s-tile-content.ts +74 -103
  84. package/src/lib/parsers/parse-i3s.ts +48 -37
  85. package/src/lib/utils/url-utils.ts +7 -7
  86. package/src/types.ts +302 -93
package/dist/bundle.js CHANGED
@@ -463,6 +463,9 @@
463
463
  const workerOptions = options[worker.id] || {};
464
464
  const workerFile = `${worker.id}-worker.js`;
465
465
  let url = workerOptions.workerUrl;
466
+ if (!url && worker.id === "compression") {
467
+ url = options.workerUrl;
468
+ }
466
469
  if (options._workerType === "test") {
467
470
  url = `modules/${worker.module}/dist/${workerFile}`;
468
471
  }
@@ -7479,7 +7482,7 @@
7479
7482
  }
7480
7483
  });
7481
7484
 
7482
- // ../textures/src/lib/parsers/parse-basis.js
7485
+ // ../textures/src/lib/parsers/parse-basis.ts
7483
7486
  async function parseBasis(data, options) {
7484
7487
  if (options.basis.containerFormat === "auto") {
7485
7488
  if (isKTX(data)) {
@@ -7615,7 +7618,7 @@
7615
7618
  }
7616
7619
  var OutputFormat;
7617
7620
  var init_parse_basis = __esm({
7618
- "../textures/src/lib/parsers/parse-basis.js"() {
7621
+ "../textures/src/lib/parsers/parse-basis.ts"() {
7619
7622
  init_basis_module_loader();
7620
7623
  init_gl_extensions();
7621
7624
  init_texture_formats();
@@ -8068,12 +8071,34 @@
8068
8071
  }
8069
8072
  });
8070
8073
 
8074
+ // src/types.ts
8075
+ var DATA_TYPE, HeaderAttributeProperty;
8076
+ var init_types = __esm({
8077
+ "src/types.ts"() {
8078
+ (function(DATA_TYPE2) {
8079
+ DATA_TYPE2["UInt8"] = "UInt8";
8080
+ DATA_TYPE2["UInt16"] = "UInt16";
8081
+ DATA_TYPE2["UInt32"] = "UInt32";
8082
+ DATA_TYPE2["UInt64"] = "UInt64";
8083
+ DATA_TYPE2["Int16"] = "Int16";
8084
+ DATA_TYPE2["Int32"] = "Int32";
8085
+ DATA_TYPE2["Int64"] = "Int64";
8086
+ DATA_TYPE2["Float32"] = "Float32";
8087
+ DATA_TYPE2["Float64"] = "Float64";
8088
+ })(DATA_TYPE || (DATA_TYPE = {}));
8089
+ (function(HeaderAttributeProperty2) {
8090
+ HeaderAttributeProperty2["vertexCount"] = "vertexCount";
8091
+ HeaderAttributeProperty2["featureCount"] = "featureCount";
8092
+ })(HeaderAttributeProperty || (HeaderAttributeProperty = {}));
8093
+ }
8094
+ });
8095
+
8071
8096
  // src/lib/utils/url-utils.ts
8072
8097
  function getUrlWithToken(url, token = null) {
8073
8098
  return token ? `${url}?token=${token}` : url;
8074
8099
  }
8075
- function generateTileAttributeUrls(tile) {
8076
- const { url, attributeData } = tile;
8100
+ function generateTileAttributeUrls(url, tile) {
8101
+ const { attributeData = [] } = tile;
8077
8102
  const attributeUrls = [];
8078
8103
  for (let index = 0; index < attributeData.length; index++) {
8079
8104
  const attributeUrl = attributeData[index].href.replace("./", "");
@@ -8718,24 +8743,6 @@
8718
8743
  }
8719
8744
  });
8720
8745
 
8721
- // src/types.ts
8722
- var DATA_TYPE;
8723
- var init_types = __esm({
8724
- "src/types.ts"() {
8725
- (function(DATA_TYPE2) {
8726
- DATA_TYPE2["UInt8"] = "UInt8";
8727
- DATA_TYPE2["UInt16"] = "UInt16";
8728
- DATA_TYPE2["UInt32"] = "UInt32";
8729
- DATA_TYPE2["UInt64"] = "UInt64";
8730
- DATA_TYPE2["Int16"] = "Int16";
8731
- DATA_TYPE2["Int32"] = "Int32";
8732
- DATA_TYPE2["Int64"] = "Int64";
8733
- DATA_TYPE2["Float32"] = "Float32";
8734
- DATA_TYPE2["Float64"] = "Float64";
8735
- })(DATA_TYPE || (DATA_TYPE = {}));
8736
- }
8737
- });
8738
-
8739
8746
  // src/lib/parsers/constants.ts
8740
8747
  function getConstructorForDataFormat(dataType) {
8741
8748
  switch (dataType) {
@@ -8750,7 +8757,7 @@
8750
8757
  case DATA_TYPE.UInt64:
8751
8758
  return Float64Array;
8752
8759
  default:
8753
- return null;
8760
+ throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
8754
8761
  }
8755
8762
  }
8756
8763
  function sizeOf(dataType) {
@@ -8769,10 +8776,10 @@
8769
8776
  case DATA_TYPE.Float64:
8770
8777
  return 8;
8771
8778
  default:
8772
- return NaN;
8779
+ throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
8773
8780
  }
8774
8781
  }
8775
- var GL_TYPE_MAP, I3S_NAMED_VERTEX_ATTRIBUTES, I3S_NAMED_GEOMETRY_ATTRIBUTES, I3S_NAMED_HEADER_ATTRIBUTES, STRING_ATTRIBUTE_TYPE, OBJECT_ID_ATTRIBUTE_TYPE, FLOAT_64_TYPE, INT_16_ATTRIBUTE_TYPE, COORDINATE_SYSTEM;
8782
+ var GL_TYPE_MAP, STRING_ATTRIBUTE_TYPE, OBJECT_ID_ATTRIBUTE_TYPE, FLOAT_64_TYPE, INT_16_ATTRIBUTE_TYPE, COORDINATE_SYSTEM;
8776
8783
  var init_constants2 = __esm({
8777
8784
  "src/lib/parsers/constants.ts"() {
8778
8785
  init_esm5();
@@ -8784,22 +8791,6 @@
8784
8791
  UInt32: esm_default2.UNSIGNED_INT,
8785
8792
  UInt64: esm_default2.DOUBLE
8786
8793
  };
8787
- I3S_NAMED_VERTEX_ATTRIBUTES = {
8788
- position: "position",
8789
- normal: "normal",
8790
- uv0: "uv0",
8791
- color: "color",
8792
- region: "region"
8793
- };
8794
- I3S_NAMED_GEOMETRY_ATTRIBUTES = {
8795
- vertexAttributes: "vertexAttributes",
8796
- featureAttributeOrder: "featureAttributeOrder",
8797
- featureAttributes: "featureAttributes"
8798
- };
8799
- I3S_NAMED_HEADER_ATTRIBUTES = {
8800
- vertexCount: "vertexCount",
8801
- featureCount: "featureCount"
8802
- };
8803
8794
  STRING_ATTRIBUTE_TYPE = "String";
8804
8795
  OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
8805
8796
  FLOAT_64_TYPE = "Float64";
@@ -8817,26 +8808,24 @@
8817
8808
  // src/lib/parsers/parse-i3s-tile-content.ts
8818
8809
  function getLoaderForTextureFormat(textureFormat) {
8819
8810
  switch (textureFormat) {
8820
- case "jpeg":
8821
- case "png":
8822
- return ImageLoader;
8823
8811
  case "ktx-etc2":
8824
8812
  case "dds":
8825
8813
  return CompressedTextureLoader;
8826
8814
  case "ktx2":
8827
8815
  return BasisLoader;
8816
+ case "jpg":
8817
+ case "png":
8828
8818
  default:
8829
- return null;
8819
+ return ImageLoader;
8830
8820
  }
8831
8821
  }
8832
8822
  async function parseI3STileContent(arrayBuffer, tile, tileset, options, context) {
8833
8823
  tile.content = tile.content || {};
8834
8824
  tile.content.featureIds = tile.content.featureIds || null;
8835
- tile.content.featureData = constructFeatureDataStruct(tileset);
8836
8825
  tile.content.attributes = {};
8837
8826
  if (tile.textureUrl) {
8838
8827
  const url = getUrlWithToken(tile.textureUrl, options?.i3s?.token);
8839
- const loader = getLoaderForTextureFormat(tile.textureFormat) || ImageLoader;
8828
+ const loader = getLoaderForTextureFormat(tile.textureFormat);
8840
8829
  const response = await fetch(url);
8841
8830
  const arrayBuffer2 = await response.arrayBuffer();
8842
8831
  if (options?.i3s.decodeTextures) {
@@ -8865,9 +8854,9 @@
8865
8854
  if (tile.content.material) {
8866
8855
  tile.content.texture = null;
8867
8856
  }
8868
- return await parseI3SNodeGeometry(arrayBuffer, tile, options);
8857
+ return await parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);
8869
8858
  }
8870
- async function parseI3SNodeGeometry(arrayBuffer, tile, options) {
8859
+ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
8871
8860
  if (!tile.content) {
8872
8861
  return tile;
8873
8862
  }
@@ -8876,6 +8865,7 @@
8876
8865
  let vertexCount;
8877
8866
  let byteOffset = 0;
8878
8867
  let featureCount = 0;
8868
+ let indices;
8879
8869
  if (tile.isDracoGeometry) {
8880
8870
  const decompressedGeometry = await parse(arrayBuffer, DracoLoader2, {
8881
8871
  draco: {
@@ -8883,7 +8873,7 @@
8883
8873
  }
8884
8874
  });
8885
8875
  vertexCount = decompressedGeometry.header.vertexCount;
8886
- const indices = decompressedGeometry.indices.value;
8876
+ indices = decompressedGeometry.indices?.value;
8887
8877
  const {
8888
8878
  POSITION,
8889
8879
  NORMAL,
@@ -8898,8 +8888,7 @@
8898
8888
  color: COLOR_0,
8899
8889
  uv0: TEXCOORD_0,
8900
8890
  uvRegion,
8901
- id: featureIndex,
8902
- indices
8891
+ id: featureIndex
8903
8892
  };
8904
8893
  updateAttributesMetadata(attributes, decompressedGeometry);
8905
8894
  const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
@@ -8907,8 +8896,13 @@
8907
8896
  flattenFeatureIdsByFeatureIndices(attributes, featureIds);
8908
8897
  }
8909
8898
  } else {
8910
- const { vertexAttributes, attributesOrder, featureAttributes, featureAttributeOrder } = content.featureData;
8911
- const headers = parseHeaders(content, arrayBuffer);
8899
+ const {
8900
+ vertexAttributes,
8901
+ ordering: attributesOrder,
8902
+ featureAttributes,
8903
+ featureAttributeOrder
8904
+ } = tileset.store.defaultGeometrySchema;
8905
+ const headers = parseHeaders(tileset, arrayBuffer);
8912
8906
  byteOffset = headers.byteOffset;
8913
8907
  vertexCount = headers.vertexCount;
8914
8908
  featureCount = headers.featureCount;
@@ -8932,7 +8926,7 @@
8932
8926
  texCoords: attributes.uv0,
8933
8927
  uvRegions: normalizeAttribute(attributes.uvRegion)
8934
8928
  };
8935
- content.indices = attributes.indices || null;
8929
+ content.indices = indices || null;
8936
8930
  if (attributes.id && attributes.id.value) {
8937
8931
  tile.content.featureIds = attributes.id.value;
8938
8932
  }
@@ -8970,41 +8964,25 @@
8970
8964
  attribute.normalized = true;
8971
8965
  return attribute;
8972
8966
  }
8973
- function constructFeatureDataStruct(tileset) {
8974
- const defaultGeometrySchema = tileset.store.defaultGeometrySchema;
8975
- const featureData = defaultGeometrySchema;
8976
- for (const geometryAttribute in I3S_NAMED_GEOMETRY_ATTRIBUTES) {
8977
- for (const namedAttribute in I3S_NAMED_VERTEX_ATTRIBUTES) {
8978
- const attribute = defaultGeometrySchema[geometryAttribute][namedAttribute];
8979
- if (attribute) {
8980
- const { byteOffset = 0, count = 0, valueType, valuesPerElement } = attribute;
8981
- featureData[geometryAttribute][namedAttribute] = {
8982
- valueType,
8983
- valuesPerElement,
8984
- byteOffset,
8985
- count
8986
- };
8987
- }
8988
- }
8989
- }
8990
- featureData.attributesOrder = defaultGeometrySchema.ordering;
8991
- return featureData;
8992
- }
8993
- function parseHeaders(content, arrayBuffer) {
8967
+ function parseHeaders(tileset, arrayBuffer) {
8994
8968
  let byteOffset = 0;
8995
8969
  let vertexCount = 0;
8996
8970
  let featureCount = 0;
8997
- content.featureData.header.forEach(({ property, type }) => {
8971
+ for (const { property, type } of tileset.store.defaultGeometrySchema.header) {
8998
8972
  const TypedArrayTypeHeader = getConstructorForDataFormat(type);
8999
- if (property === I3S_NAMED_HEADER_ATTRIBUTES.vertexCount) {
9000
- vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
9001
- byteOffset += sizeOf(type);
9002
- }
9003
- if (property === I3S_NAMED_HEADER_ATTRIBUTES.featureCount) {
9004
- featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
9005
- byteOffset += sizeOf(type);
8973
+ switch (property) {
8974
+ case HeaderAttributeProperty.vertexCount:
8975
+ vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
8976
+ byteOffset += sizeOf(type);
8977
+ break;
8978
+ case HeaderAttributeProperty.featureCount:
8979
+ featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
8980
+ byteOffset += sizeOf(type);
8981
+ break;
8982
+ default:
8983
+ break;
9006
8984
  }
9007
- });
8985
+ }
9008
8986
  return {
9009
8987
  vertexCount,
9010
8988
  featureCount,
@@ -9021,7 +8999,7 @@
9021
8999
  break;
9022
9000
  }
9023
9001
  const buffer = arrayBuffer.slice(byteOffset);
9024
- let value = [];
9002
+ let value;
9025
9003
  if (valueType === "UInt64") {
9026
9004
  value = parseUint64Values(buffer, count * valuesPerElement, sizeOf(valueType));
9027
9005
  } else {
@@ -9058,7 +9036,7 @@
9058
9036
  values.push(value);
9059
9037
  offset += attributeSize;
9060
9038
  }
9061
- return values;
9039
+ return new Uint32Array(values);
9062
9040
  }
9063
9041
  function parsePositions(attribute, tile) {
9064
9042
  const mbs = tile.mbs;
@@ -9125,7 +9103,9 @@
9125
9103
  if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {
9126
9104
  pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(pbrMaterial.pbrMetallicRoughness.baseColorFactor);
9127
9105
  }
9128
- setMaterialTexture(pbrMaterial, texture);
9106
+ if (texture) {
9107
+ setMaterialTexture(pbrMaterial, texture);
9108
+ }
9129
9109
  return pbrMaterial;
9130
9110
  }
9131
9111
  function convertColorFormat(colorFactor) {
@@ -9187,7 +9167,7 @@
9187
9167
  attributes.id.value = result;
9188
9168
  }
9189
9169
  function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
9190
- return featureIndex && featureIndex.metadata && featureIndex.metadata["i3s-feature-ids"] && featureIndex.metadata["i3s-feature-ids"].intArray;
9170
+ return featureIndex?.metadata?.["i3s-feature-ids"]?.intArray;
9191
9171
  }
9192
9172
  var scratchVector5, I3S_ATTRIBUTE_TYPE;
9193
9173
  var init_parse_i3s_tile_content = __esm({
@@ -9198,6 +9178,7 @@
9198
9178
  init_src4();
9199
9179
  init_src6();
9200
9180
  init_src7();
9181
+ init_types();
9201
9182
  init_url_utils();
9202
9183
  init_constants2();
9203
9184
  scratchVector5 = new Vector3([0, 0, 0]);
@@ -9775,8 +9756,8 @@
9775
9756
  this.textureDefinitionsSelectedFormats = [];
9776
9757
  this.textureLoaderOptions = {};
9777
9758
  this.tileset = { ...tileset };
9778
- this.nodesPerPage = tileset.nodePages.nodesPerPage;
9779
- this.lodSelectionMetricType = tileset.nodePages.lodSelectionMetricType;
9759
+ this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;
9760
+ this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;
9780
9761
  this.options = options;
9781
9762
  this.initSelectedFormatsForTextureDefinitions(tileset);
9782
9763
  }
@@ -9803,21 +9784,21 @@
9803
9784
  for (const child of node2.children || []) {
9804
9785
  const childNode = await this.getNodeById(child);
9805
9786
  children.push({
9806
- id: child,
9787
+ id: child.toString(),
9807
9788
  obb: childNode.obb
9808
9789
  });
9809
9790
  }
9810
- let contentUrl = null;
9811
- let textureUrl = null;
9812
- let materialDefinition = null;
9813
- let textureFormat = "jpeg";
9791
+ let contentUrl;
9792
+ let textureUrl;
9793
+ let materialDefinition;
9794
+ let textureFormat = "jpg";
9814
9795
  let attributeUrls = [];
9815
9796
  let isDracoGeometry = false;
9816
9797
  if (node2 && node2.mesh) {
9817
- const { url, isDracoGeometry: isDracoGeometryResult } = node2.mesh.geometry && this.getContentUrl(node2.mesh.geometry) || { url: null, isDracoGeometry: null };
9798
+ const { url, isDracoGeometry: isDracoGeometryResult } = node2.mesh.geometry && this.getContentUrl(node2.mesh.geometry) || { isDracoGeometry: false };
9818
9799
  contentUrl = url;
9819
9800
  isDracoGeometry = isDracoGeometryResult;
9820
- const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(node2.mesh.material);
9801
+ const { textureData, materialDefinition: nodeMaterialDefinition } = this.getInformationFromMaterial(node2.mesh.material);
9821
9802
  materialDefinition = nodeMaterialDefinition;
9822
9803
  textureFormat = textureData.format || textureFormat;
9823
9804
  if (textureData.name) {
@@ -9829,7 +9810,7 @@
9829
9810
  }
9830
9811
  const lodSelection = this.getLodSelection(node2);
9831
9812
  return normalizeTileNonUrlData({
9832
- id,
9813
+ id: id.toString(),
9833
9814
  lodSelection,
9834
9815
  obb: node2.obb,
9835
9816
  contentUrl,
@@ -9843,7 +9824,7 @@
9843
9824
  });
9844
9825
  }
9845
9826
  getContentUrl(meshGeometryData) {
9846
- let result = {};
9827
+ let result = null;
9847
9828
  const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
9848
9829
  let geometryIndex = -1;
9849
9830
  if (this.options.i3s && this.options.i3s.useDracoGeometry) {
@@ -9876,17 +9857,18 @@
9876
9857
  return lodSelection;
9877
9858
  }
9878
9859
  getInformationFromMaterial(material) {
9879
- const textureDataDefault = { name: null, format: null };
9860
+ const informationFromMaterial = { textureData: { name: null } };
9880
9861
  if (material) {
9881
- const materialDefinition = this.tileset.materialDefinitions[material.definition];
9882
- const textureSetDefinitionIndex = materialDefinition && materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.baseColorTexture && materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;
9883
- if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {
9884
- const textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;
9885
- return [textureData, materialDefinition];
9862
+ const materialDefinition = this.tileset.materialDefinitions?.[material.definition];
9863
+ if (materialDefinition) {
9864
+ informationFromMaterial.materialDefinition = materialDefinition;
9865
+ const textureSetDefinitionIndex = materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;
9866
+ if (typeof textureSetDefinitionIndex === "number") {
9867
+ informationFromMaterial.textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || informationFromMaterial.textureData;
9868
+ }
9886
9869
  }
9887
- return [textureDataDefault, materialDefinition];
9888
9870
  }
9889
- return [textureDataDefault, null];
9871
+ return informationFromMaterial;
9890
9872
  }
9891
9873
  initSelectedFormatsForTextureDefinitions(tileset) {
9892
9874
  this.textureDefinitionsSelectedFormats = [];
@@ -9934,49 +9916,54 @@
9934
9916
 
9935
9917
  // src/lib/parsers/parse-i3s.ts
9936
9918
  function normalizeTileData(tile, options, context) {
9937
- tile.url = context.url;
9938
- if (tile.featureData) {
9939
- tile.featureUrl = `${tile.url}/${tile.featureData[0].href}`;
9940
- }
9919
+ const url = context.url || "";
9920
+ let contentUrl;
9941
9921
  if (tile.geometryData) {
9942
- tile.contentUrl = `${tile.url}/${tile.geometryData[0].href}`;
9922
+ contentUrl = `${url}/${tile.geometryData[0].href}`;
9943
9923
  }
9924
+ let textureUrl;
9944
9925
  if (tile.textureData) {
9945
- tile.textureUrl = `${tile.url}/${tile.textureData[0].href}`;
9926
+ textureUrl = `${url}/${tile.textureData[0].href}`;
9946
9927
  }
9928
+ let attributeUrls;
9947
9929
  if (tile.attributeData) {
9948
- tile.attributeUrls = generateTileAttributeUrls(tile);
9949
- }
9950
- return normalizeTileNonUrlData(tile);
9930
+ attributeUrls = generateTileAttributeUrls(url, tile);
9931
+ }
9932
+ return normalizeTileNonUrlData({
9933
+ ...tile,
9934
+ url,
9935
+ contentUrl,
9936
+ textureUrl,
9937
+ attributeUrls,
9938
+ isDracoGeometry: false
9939
+ });
9951
9940
  }
9952
9941
  function normalizeTileNonUrlData(tile) {
9953
- const box = tile.obb ? [
9954
- ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center),
9955
- ...tile.obb.halfSize,
9956
- ...tile.obb.quaternion
9957
- ] : void 0;
9958
- let sphere;
9942
+ const boundingVolume = {};
9943
+ let mbs = [0, 0, 0, 1];
9959
9944
  if (tile.mbs) {
9960
- sphere = [
9945
+ mbs = tile.mbs;
9946
+ boundingVolume.sphere = [
9961
9947
  ...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)),
9962
9948
  tile.mbs[3]
9963
9949
  ];
9964
- } else if (box) {
9965
- const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
9950
+ } else if (tile.obb) {
9951
+ boundingVolume.box = [
9952
+ ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center),
9953
+ ...tile.obb.halfSize,
9954
+ ...tile.obb.quaternion
9955
+ ];
9956
+ const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
9966
9957
  const boundingSphere = obb.getBoundingSphere();
9967
- sphere = [...boundingSphere.center, boundingSphere.radius];
9968
- tile.mbs = [...tile.obb.center, boundingSphere.radius];
9969
- }
9970
- tile.boundingVolume = {
9971
- sphere,
9972
- box
9973
- };
9974
- tile.lodMetricType = tile.lodSelection[0].metricType;
9975
- tile.lodMetricValue = tile.lodSelection[0].maxError;
9976
- tile.transformMatrix = tile.transform;
9977
- tile.type = TILE_TYPE.MESH;
9978
- tile.refine = TILE_REFINEMENT.REPLACE;
9979
- return tile;
9958
+ boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
9959
+ mbs = [...tile.obb.center, boundingSphere.radius];
9960
+ }
9961
+ const lodMetricType = tile.lodSelection?.[0].metricType;
9962
+ const lodMetricValue = tile.lodSelection?.[0].maxError;
9963
+ const transformMatrix = tile.transform;
9964
+ const type = TILE_TYPE.MESH;
9965
+ const refine = TILE_REFINEMENT.REPLACE;
9966
+ return { ...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine };
9980
9967
  }
9981
9968
  async function normalizeTilesetData(tileset, options, context) {
9982
9969
  tileset.url = context.url;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}