@loaders.gl/i3s 3.1.7 → 3.2.0-alpha.2

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 (57) hide show
  1. package/dist/dist.min.js +118 -62
  2. package/dist/es5/i3s-attribute-loader.js +1 -1
  3. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  4. package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
  5. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
  6. package/dist/es5/i3s-content-loader.js +1 -1
  7. package/dist/es5/i3s-content-loader.js.map +1 -1
  8. package/dist/es5/i3s-loader.js +1 -1
  9. package/dist/es5/i3s-loader.js.map +1 -1
  10. package/dist/es5/i3s-node-page-loader.js +1 -1
  11. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  12. package/dist/es5/index.js.map +1 -1
  13. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +43 -52
  14. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +46 -42
  16. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  17. package/dist/es5/lib/parsers/parse-i3s.js +8 -12
  18. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
  19. package/dist/es5/types.js.map +1 -1
  20. package/dist/esm/i3s-attribute-loader.js +1 -1
  21. package/dist/esm/i3s-attribute-loader.js.map +1 -1
  22. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  23. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
  24. package/dist/esm/i3s-content-loader.js +1 -1
  25. package/dist/esm/i3s-content-loader.js.map +1 -1
  26. package/dist/esm/i3s-loader.js +1 -1
  27. package/dist/esm/i3s-loader.js.map +1 -1
  28. package/dist/esm/i3s-node-page-loader.js +1 -1
  29. package/dist/esm/i3s-node-page-loader.js.map +1 -1
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +8 -2
  32. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  33. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +33 -29
  34. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  35. package/dist/esm/lib/parsers/parse-i3s.js +1 -1
  36. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
  37. package/dist/esm/types.js.map +1 -1
  38. package/dist/i3s-building-scene-layer-loader.js +1 -1
  39. package/dist/i3s-content-loader.js +1 -1
  40. package/dist/i3s-content-worker.js +141 -68
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -1
  44. package/dist/lib/helpers/i3s-nodepages-tiles.js +7 -3
  45. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
  46. package/dist/lib/parsers/parse-i3s-tile-content.js +33 -29
  47. package/dist/lib/parsers/parse-i3s.js +1 -1
  48. package/dist/types.d.ts +100 -34
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +9 -9
  51. package/src/i3s-building-scene-layer-loader.ts +1 -1
  52. package/src/i3s-content-loader.ts +1 -1
  53. package/src/index.ts +4 -1
  54. package/src/lib/helpers/i3s-nodepages-tiles.ts +8 -3
  55. package/src/lib/parsers/parse-i3s-tile-content.ts +37 -32
  56. package/src/lib/parsers/parse-i3s.ts +1 -1
  57. package/src/types.ts +97 -34
@@ -120,7 +120,7 @@ var I3SNodePagesTiles = function () {
120
120
  key: "formTileFromNodePages",
121
121
  value: function () {
122
122
  var _formTileFromNodePages = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(id) {
123
- var node, children, _iterator, _step, child, childNode, contentUrl, textureUrl, materialDefinition, textureFormat, attributeUrls, isDracoGeometry, _ref, url, isDracoGeometryResult, _this$getInformationF, textureData, nodeMaterialDefinition, lodSelection;
123
+ var node, children, childNodesPromises, _iterator, _step, child, childNodes, _iterator2, _step2, childNode, contentUrl, textureUrl, materialDefinition, textureFormat, attributeUrls, isDracoGeometry, _ref, url, isDracoGeometryResult, _this$getInformationF, textureData, nodeMaterialDefinition, lodSelection;
124
124
 
125
125
  return _regenerator.default.wrap(function _callee2$(_context2) {
126
126
  while (1) {
@@ -132,50 +132,41 @@ var I3SNodePagesTiles = function () {
132
132
  case 2:
133
133
  node = _context2.sent;
134
134
  children = [];
135
+ childNodesPromises = [];
135
136
  _iterator = _createForOfIteratorHelper(node.children || []);
136
- _context2.prev = 5;
137
137
 
138
- _iterator.s();
139
-
140
- case 7:
141
- if ((_step = _iterator.n()).done) {
142
- _context2.next = 15;
143
- break;
138
+ try {
139
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
140
+ child = _step.value;
141
+ childNodesPromises.push(this.getNodeById(child));
142
+ }
143
+ } catch (err) {
144
+ _iterator.e(err);
145
+ } finally {
146
+ _iterator.f();
144
147
  }
145
148
 
146
- child = _step.value;
147
- _context2.next = 11;
148
- return this.getNodeById(child);
149
-
150
- case 11:
151
- childNode = _context2.sent;
152
- children.push({
153
- id: child.toString(),
154
- obb: childNode.obb
155
- });
156
-
157
- case 13:
158
- _context2.next = 7;
159
- break;
149
+ _context2.next = 9;
150
+ return Promise.all(childNodesPromises);
160
151
 
161
- case 15:
162
- _context2.next = 20;
163
- break;
152
+ case 9:
153
+ childNodes = _context2.sent;
154
+ _iterator2 = _createForOfIteratorHelper(childNodes);
164
155
 
165
- case 17:
166
- _context2.prev = 17;
167
- _context2.t0 = _context2["catch"](5);
168
-
169
- _iterator.e(_context2.t0);
170
-
171
- case 20:
172
- _context2.prev = 20;
173
-
174
- _iterator.f();
175
-
176
- return _context2.finish(20);
156
+ try {
157
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
158
+ childNode = _step2.value;
159
+ children.push({
160
+ id: childNode.index.toString(),
161
+ obb: childNode.obb
162
+ });
163
+ }
164
+ } catch (err) {
165
+ _iterator2.e(err);
166
+ } finally {
167
+ _iterator2.f();
168
+ }
177
169
 
178
- case 23:
179
170
  textureFormat = 'jpg';
180
171
  attributeUrls = [];
181
172
  isDracoGeometry = false;
@@ -214,12 +205,12 @@ var I3SNodePagesTiles = function () {
214
205
  isDracoGeometry: isDracoGeometry
215
206
  }));
216
207
 
217
- case 29:
208
+ case 18:
218
209
  case "end":
219
210
  return _context2.stop();
220
211
  }
221
212
  }
222
- }, _callee2, this, [[5, 17, 20, 23]]);
213
+ }, _callee2, this);
223
214
  }));
224
215
 
225
216
  function formTileFromNodePages(_x2) {
@@ -310,21 +301,21 @@ var I3SNodePagesTiles = function () {
310
301
  var possibleI3sFormats = this.getSupportedTextureFormats();
311
302
  var textureSetDefinitions = tileset.textureSetDefinitions || [];
312
303
 
313
- var _iterator2 = _createForOfIteratorHelper(textureSetDefinitions),
314
- _step2;
304
+ var _iterator3 = _createForOfIteratorHelper(textureSetDefinitions),
305
+ _step3;
315
306
 
316
307
  try {
317
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
318
- var textureSetDefinition = _step2.value;
308
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
309
+ var textureSetDefinition = _step3.value;
319
310
  var formats = textureSetDefinition && textureSetDefinition.formats || [];
320
311
  var selectedFormat = null;
321
312
 
322
- var _iterator3 = _createForOfIteratorHelper(possibleI3sFormats),
323
- _step3;
313
+ var _iterator4 = _createForOfIteratorHelper(possibleI3sFormats),
314
+ _step4;
324
315
 
325
316
  try {
326
317
  var _loop = function _loop() {
327
- var i3sFormat = _step3.value;
318
+ var i3sFormat = _step4.value;
328
319
  var format = formats.find(function (value) {
329
320
  return value.format === i3sFormat;
330
321
  });
@@ -335,15 +326,15 @@ var I3SNodePagesTiles = function () {
335
326
  }
336
327
  };
337
328
 
338
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
329
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
339
330
  var _ret = _loop();
340
331
 
341
332
  if (_ret === "break") break;
342
333
  }
343
334
  } catch (err) {
344
- _iterator3.e(err);
335
+ _iterator4.e(err);
345
336
  } finally {
346
- _iterator3.f();
337
+ _iterator4.f();
347
338
  }
348
339
 
349
340
  if (selectedFormat && selectedFormat.format === 'ktx2') {
@@ -357,9 +348,9 @@ var I3SNodePagesTiles = function () {
357
348
  this.textureDefinitionsSelectedFormats.push(selectedFormat);
358
349
  }
359
350
  } catch (err) {
360
- _iterator2.e(err);
351
+ _iterator3.e(err);
361
352
  } finally {
362
- _iterator2.f();
353
+ _iterator3.f();
363
354
  }
364
355
  }
365
356
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["I3SNodePagesTiles","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","I3SNodePageLoader","nodeIndex","nodes","getNodeById","node","children","child","childNode","push","toString","obb","textureFormat","attributeUrls","isDracoGeometry","mesh","geometry","getContentUrl","isDracoGeometryResult","contentUrl","getInformationFromMaterial","material","textureData","nodeMaterialDefinition","materialDefinition","format","name","textureUrl","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","informationFromMaterial","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;IAkBqBA,iB;AAgBnB,6BAAYC,OAAZ,EAA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,EAAiE;AAE/D,YAAMC,0BAA0B,GAAG,8CAAnC;;AAGA,YAAIA,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,UAAAA,OAAO,CAACtD,IAAR,CAAa,UAAb;AACD;;AACD,YAAI+D,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,UAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACD;;AAIDsD,QAAAA,OAAO,CAACtD,IAAR,CAAa,MAAb;AACD;;AAEDsD,MAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACAsD,MAAAA,OAAO,CAACtD,IAAR,CAAa,KAAb;AACA,aAAOsD,OAAP;AACD","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {\n I3STilesetHeader,\n LodSelection,\n NodePage,\n NodeInPage,\n Obb,\n MeshMaterial,\n I3SMaterialDefinition,\n I3STextureFormat,\n MeshGeometry,\n I3STileHeader\n} from '../../types';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: I3STilesetHeader;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: LoaderOptions;\n lodSelectionMetricType?: string;\n textureDefinitionsSelectedFormats: ({format: I3STextureFormat; name: string} | null)[] = [];\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: I3STilesetHeader, options: LoaderOptions) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;\n this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;\n this.options = options;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number): Promise<NodeInPage> {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity\n async formTileFromNodePages(id: number): Promise<I3STileHeader> {\n const node: NodeInPage = await this.getNodeById(id);\n const children: {id: string; obb: Obb}[] = [];\n for (const child of node.children || []) {\n const childNode = await this.getNodeById(child);\n children.push({\n id: child.toString(),\n obb: childNode.obb\n });\n }\n\n let contentUrl: string | undefined;\n let textureUrl: string | undefined;\n let materialDefinition: I3SMaterialDefinition | undefined;\n let textureFormat: I3STextureFormat = 'jpg';\n let attributeUrls: string[] = [];\n let isDracoGeometry: boolean = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {isDracoGeometry: false};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const {textureData, materialDefinition: nodeMaterialDefinition} =\n this.getInformationFromMaterial(node.mesh.material);\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id: id.toString(),\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param - data about the node's mesh from the nodepage\n * @returns -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData: MeshGeometry) {\n let result: {url: string; isDracoGeometry: boolean} | null = null;\n // @ts-ignore\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param node - a node from nodepage\n * @returns- Array of LodSelection\n */\n private getLodSelection(node: NodeInPage): LodSelection[] {\n const lodSelection: LodSelection[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n // @ts-ignore\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n // @ts-ignore\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param material - material data from nodepage\n * @returns - Couple {textureData, materialDefinition}\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material: MeshMaterial) {\n const informationFromMaterial: {\n textureData: {name: string | null; format?: I3STextureFormat};\n materialDefinition?: I3SMaterialDefinition;\n } = {textureData: {name: null}};\n\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions?.[material.definition];\n if (materialDefinition) {\n informationFromMaterial.materialDefinition = materialDefinition;\n const textureSetDefinitionIndex =\n materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;\n\n if (typeof textureSetDefinitionIndex === 'number') {\n informationFromMaterial.textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||\n informationFromMaterial.textureData;\n }\n }\n }\n return informationFromMaterial;\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param tileset - I3S layer data\n * @returns\n */\n private initSelectedFormatsForTextureDefinitions(tileset: I3STilesetHeader): void {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {name: string; format: I3STextureFormat} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): I3STextureFormat[] {\n const formats: I3STextureFormat[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
1
+ {"version":3,"sources":["../../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":["I3SNodePagesTiles","tileset","options","nodesPerPage","nodePages","lodSelectionMetricType","initSelectedFormatsForTextureDefinitions","id","pageIndex","Math","floor","pendingNodePages","nodePageUrl","url","i3s","token","status","promise","I3SNodePageLoader","nodeIndex","nodes","getNodeById","node","children","childNodesPromises","child","push","Promise","all","childNodes","childNode","index","toString","obb","textureFormat","attributeUrls","isDracoGeometry","mesh","geometry","getContentUrl","isDracoGeometryResult","contentUrl","getInformationFromMaterial","material","textureData","nodeMaterialDefinition","materialDefinition","format","name","textureUrl","resource","attributeStorageInfo","attribute","lodSelection","getLodSelection","textureLoaderOptions","meshGeometryData","result","geometryDefinition","geometryDefinitions","definition","geometryIndex","useDracoGeometry","geometryBuffers","findIndex","buffer","compressedAttributes","encoding","Boolean","metricType","maxError","sqrt","lodThreshold","PI","informationFromMaterial","materialDefinitions","textureSetDefinitionIndex","pbrMetallicRoughness","baseColorTexture","textureSetDefinitionId","textureDefinitionsSelectedFormats","possibleI3sFormats","getSupportedTextureFormats","textureSetDefinitions","textureSetDefinition","formats","selectedFormat","i3sFormat","find","value","basis","containerFormat","module","useCompressedTextures","supportedCompressedFormats","has"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;IAkBqBA,iB;AAgBnB,6BAAYC,OAAZ,EAAuCC,OAAvC,EAA+D;AAAA;;AAAA;AAAA;AAAA,qDAdvC,EAcuC;AAAA,4DAbgB,EAahB;AAAA;AAAA;AAAA;AAAA,6EAT0B,EAS1B;AAAA,gEARV,EAQU;AAC7D,SAAKD,OAAL,qBAAmBA,OAAnB;AACA,SAAKE,YAAL,GAAoB,uBAAAF,OAAO,CAACG,SAAR,0EAAmBD,YAAnB,KAAmC,EAAvD;AACA,SAAKE,sBAAL,0BAA8BJ,OAAO,CAACG,SAAtC,wDAA8B,oBAAmBC,sBAAjD;AACA,SAAKH,OAAL,GAAeA,OAAf;AAEA,SAAKI,wCAAL,CAA8CL,OAA9C;AACD;;;;;mFAMD,iBAAkBM,EAAlB;AAAA;;AAAA;AAAA;AAAA;AAAA;AACQC,gBAAAA,SADR,GACoBC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKJ,YAArB,CADpB;;AAAA,sBAEM,CAAC,KAAKC,SAAL,CAAeI,SAAf,CAAD,IAA8B,CAAC,KAAKG,gBAAL,CAAsBH,SAAtB,CAFrC;AAAA;AAAA;AAAA;;AAGUI,gBAAAA,WAHV,GAGwB,yCACf,KAAKX,OAAL,CAAaY,GADE,wBACeL,SADf,wBAElB,KAAKN,OAAL,CAAaY,GAFK,sDAElB,kBAAkBC,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A,cAAc,GAAGvC,MAAjB;AACA;AACD;AARqD;;AAGxD,mEAA4C;AAAA;;AAAA,oCAIxC;AAEH;AATuD;AAAA;AAAA;AAAA;AAAA;;AAWxD,cAAIuC,cAAc,IAAIA,cAAc,CAACvC,MAAf,KAA0B,MAAhD,EAAwD;AACtD,iBAAKQ,oBAAL,CAA0BmC,KAA1B,GAAkC;AAChC3C,cAAAA,MAAM,EAAE,2CADwB;AAEhC4C,cAAAA,eAAe,EAAE,MAFe;AAGhCC,cAAAA,MAAM,EAAE;AAHwB,aAAlC;AAKD;;AAED,eAAKZ,iCAAL,CAAuCtD,IAAvC,CAA4C4D,cAA5C;AACD;AAxB+E;AAAA;AAAA;AAAA;AAAA;AAyBjF;;;WAMD,sCAAyD;AACvD,UAAMD,OAA2B,GAAG,EAApC;;AACA,UAAI,CAAC,KAAKnF,OAAL,CAAaY,GAAd,IAAqB,KAAKZ,OAAL,CAAaY,GAAb,CAAiB+E,qBAA1C,EAAiE;AAE/D,YAAMC,0BAA0B,GAAG,8CAAnC;;AAGA,YAAIA,0BAA0B,CAACC,GAA3B,CAA+B,MAA/B,CAAJ,EAA4C;AAC1CV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,UAAb;AACD;;AACD,YAAIoE,0BAA0B,CAACC,GAA3B,CAA+B,KAA/B,CAAJ,EAA2C;AACzCV,UAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACD;;AAID2D,QAAAA,OAAO,CAAC3D,IAAR,CAAa,MAAb;AACD;;AAED2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA2D,MAAAA,OAAO,CAAC3D,IAAR,CAAa,KAAb;AACA,aAAO2D,OAAP;AACD","sourcesContent":["import {load} from '@loaders.gl/core';\nimport {getSupportedGPUTextureFormats, selectSupportedBasisFormat} from '@loaders.gl/textures';\nimport {I3SNodePageLoader} from '../../i3s-node-page-loader';\nimport {normalizeTileNonUrlData} from '../parsers/parse-i3s';\nimport {getUrlWithToken, generateTilesetAttributeUrls} from '../utils/url-utils';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {\n I3STilesetHeader,\n LodSelection,\n NodePage,\n NodeInPage,\n Obb,\n MeshMaterial,\n I3SMaterialDefinition,\n I3STextureFormat,\n MeshGeometry,\n I3STileHeader\n} from '../../types';\n\n/**\n * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them\n */\nexport default class I3SNodePagesTiles {\n tileset: I3STilesetHeader;\n nodePages: NodePage[] = [];\n pendingNodePages: {promise: Promise<NodePage>; status: 'Pending' | 'Done'}[] = [];\n nodesPerPage: number;\n options: LoaderOptions;\n lodSelectionMetricType?: string;\n textureDefinitionsSelectedFormats: ({format: I3STextureFormat; name: string} | null)[] = [];\n private textureLoaderOptions: {[key: string]: any} = {};\n\n /**\n * @constructs\n * Create a I3SNodePagesTiles instance.\n * @param tileset - i3s tileset header ('layers/0')\n * @param options - i3s loader options\n */\n constructor(tileset: I3STilesetHeader, options: LoaderOptions) {\n this.tileset = {...tileset}; // spread the tileset to avoid circular reference\n this.nodesPerPage = tileset.nodePages?.nodesPerPage || 64;\n this.lodSelectionMetricType = tileset.nodePages?.lodSelectionMetricType;\n this.options = options;\n\n this.initSelectedFormatsForTextureDefinitions(tileset);\n }\n\n /**\n * Loads some nodePage and return a particular node from it\n * @param id - id of node through all node pages\n */\n async getNodeById(id: number): Promise<NodeInPage> {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {\n const nodePageUrl = getUrlWithToken(\n `${this.tileset.url}/nodepages/${pageIndex}`,\n this.options.i3s?.token\n );\n this.pendingNodePages[pageIndex] = {\n status: 'Pending',\n promise: load(nodePageUrl, I3SNodePageLoader, this.options)\n };\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n this.pendingNodePages[pageIndex].status = 'Done';\n }\n if (this.pendingNodePages[pageIndex].status === 'Pending') {\n this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;\n }\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Forms tile header using node and tileset data\n * @param id - id of node through all node pages\n */\n // eslint-disable-next-line complexity, max-statements\n async formTileFromNodePages(id: number): Promise<I3STileHeader> {\n const node: NodeInPage = await this.getNodeById(id);\n const children: {id: string; obb: Obb}[] = [];\n const childNodesPromises: Promise<NodeInPage>[] = [];\n for (const child of node.children || []) {\n childNodesPromises.push(this.getNodeById(child));\n }\n\n const childNodes = await Promise.all(childNodesPromises);\n for (const childNode of childNodes) {\n children.push({\n id: childNode.index.toString(),\n obb: childNode.obb\n });\n }\n\n let contentUrl: string | undefined;\n let textureUrl: string | undefined;\n let materialDefinition: I3SMaterialDefinition | undefined;\n let textureFormat: I3STextureFormat = 'jpg';\n let attributeUrls: string[] = [];\n let isDracoGeometry: boolean = false;\n\n if (node && node.mesh) {\n // Get geometry resource URL and type (compressed / non-compressed)\n const {url, isDracoGeometry: isDracoGeometryResult} = (node.mesh.geometry &&\n this.getContentUrl(node.mesh.geometry)) || {isDracoGeometry: false};\n contentUrl = url;\n isDracoGeometry = isDracoGeometryResult;\n\n const {textureData, materialDefinition: nodeMaterialDefinition} =\n this.getInformationFromMaterial(node.mesh.material);\n materialDefinition = nodeMaterialDefinition;\n textureFormat = textureData.format || textureFormat;\n if (textureData.name) {\n textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;\n }\n\n if (this.tileset.attributeStorageInfo) {\n attributeUrls = generateTilesetAttributeUrls(this.tileset, node.mesh.attribute.resource);\n }\n }\n\n const lodSelection = this.getLodSelection(node);\n\n return normalizeTileNonUrlData({\n id: id.toString(),\n lodSelection,\n obb: node.obb,\n contentUrl,\n textureUrl,\n attributeUrls,\n materialDefinition,\n textureFormat,\n textureLoaderOptions: this.textureLoaderOptions,\n children,\n isDracoGeometry\n });\n }\n\n /**\n * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset\n * @param - data about the node's mesh from the nodepage\n * @returns -\n * {string} url - url to the geometry resource\n * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry\n */\n private getContentUrl(meshGeometryData: MeshGeometry) {\n let result: {url: string; isDracoGeometry: boolean} | null = null;\n // @ts-ignore\n const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];\n let geometryIndex = -1;\n // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set\n if (this.options.i3s && this.options.i3s.useDracoGeometry) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco'\n );\n }\n // If DRACO geometry is not applicable try to select non-compressed geometry\n if (geometryIndex === -1) {\n geometryIndex = geometryDefinition.geometryBuffers.findIndex(\n (buffer) => !buffer.compressedAttributes\n );\n }\n if (geometryIndex !== -1) {\n const isDracoGeometry = Boolean(\n geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes\n );\n result = {\n url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,\n isDracoGeometry\n };\n }\n return result;\n }\n\n /**\n * Forms 1.6 compatible LOD selection object from a nodepage's node data\n * @param node - a node from nodepage\n * @returns- Array of LodSelection\n */\n private getLodSelection(node: NodeInPage): LodSelection[] {\n const lodSelection: LodSelection[] = [];\n if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {\n lodSelection.push({\n metricType: 'maxScreenThreshold',\n // @ts-ignore\n maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))\n });\n }\n lodSelection.push({\n metricType: this.lodSelectionMetricType,\n // @ts-ignore\n maxError: node.lodThreshold\n });\n return lodSelection;\n }\n\n /**\n * Returns information about texture and material from `materialDefinitions`\n * @param material - material data from nodepage\n * @returns - Couple {textureData, materialDefinition}\n * {string} textureData.name - path name of the texture\n * {string} textureData.format - format of the texture\n * materialDefinition - PBR-like material definition from `materialDefinitions`\n */\n private getInformationFromMaterial(material: MeshMaterial) {\n const informationFromMaterial: {\n textureData: {name: string | null; format?: I3STextureFormat};\n materialDefinition?: I3SMaterialDefinition;\n } = {textureData: {name: null}};\n\n if (material) {\n const materialDefinition = this.tileset.materialDefinitions?.[material.definition];\n if (materialDefinition) {\n informationFromMaterial.materialDefinition = materialDefinition;\n const textureSetDefinitionIndex =\n materialDefinition?.pbrMetallicRoughness?.baseColorTexture?.textureSetDefinitionId;\n\n if (typeof textureSetDefinitionIndex === 'number') {\n informationFromMaterial.textureData =\n this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] ||\n informationFromMaterial.textureData;\n }\n }\n }\n return informationFromMaterial;\n }\n\n /**\n * Sets preferable and supported format for each textureDefinition of the tileset\n * @param tileset - I3S layer data\n * @returns\n */\n private initSelectedFormatsForTextureDefinitions(tileset: I3STilesetHeader): void {\n this.textureDefinitionsSelectedFormats = [];\n const possibleI3sFormats = this.getSupportedTextureFormats();\n const textureSetDefinitions = tileset.textureSetDefinitions || [];\n for (const textureSetDefinition of textureSetDefinitions) {\n const formats = (textureSetDefinition && textureSetDefinition.formats) || [];\n let selectedFormat: {name: string; format: I3STextureFormat} | null = null;\n for (const i3sFormat of possibleI3sFormats) {\n const format = formats.find((value) => value.format === i3sFormat);\n if (format) {\n selectedFormat = format;\n break;\n }\n }\n // For I3S 1.8 need to define basis target format to decode\n if (selectedFormat && selectedFormat.format === 'ktx2') {\n this.textureLoaderOptions.basis = {\n format: selectSupportedBasisFormat(),\n containerFormat: 'ktx2',\n module: 'encoder'\n };\n }\n\n this.textureDefinitionsSelectedFormats.push(selectedFormat);\n }\n }\n\n /**\n * Returns the array of supported texture format\n * @returns list of format strings\n */\n private getSupportedTextureFormats(): I3STextureFormat[] {\n const formats: I3STextureFormat[] = [];\n if (!this.options.i3s || this.options.i3s.useCompressedTextures) {\n // I3S 1.7 selection\n const supportedCompressedFormats = getSupportedGPUTextureFormats();\n // List of possible in i3s formats:\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n if (supportedCompressedFormats.has('etc2')) {\n formats.push('ktx-etc2');\n }\n if (supportedCompressedFormats.has('dxt')) {\n formats.push('dds');\n }\n\n // I3S 1.8 selection\n // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image\n formats.push('ktx2');\n }\n\n formats.push('jpg');\n formats.push('png');\n return formats;\n }\n}\n"],"file":"i3s-nodepages-tiles.js"}
@@ -80,7 +80,7 @@ function _parseI3STileContent() {
80
80
  tile.content.attributes = {};
81
81
 
82
82
  if (!tile.textureUrl) {
83
- _context.next = 36;
83
+ _context.next = 37;
84
84
  break;
85
85
  }
86
86
 
@@ -98,7 +98,7 @@ function _parseI3STileContent() {
98
98
  _arrayBuffer = _context.sent;
99
99
 
100
100
  if (!(options !== null && options !== void 0 && options.i3s.decodeTextures)) {
101
- _context.next = 35;
101
+ _context.next = 36;
102
102
  break;
103
103
  }
104
104
 
@@ -131,12 +131,12 @@ function _parseI3STileContent() {
131
131
  tile.content.texture = _context.sent;
132
132
 
133
133
  case 26:
134
- _context.next = 33;
134
+ _context.next = 34;
135
135
  break;
136
136
 
137
137
  case 28:
138
138
  if (!(loader === _textures.CompressedTextureLoader || loader === _textures.BasisLoader)) {
139
- _context.next = 33;
139
+ _context.next = 34;
140
140
  break;
141
141
  }
142
142
 
@@ -145,6 +145,11 @@ function _parseI3STileContent() {
145
145
 
146
146
  case 31:
147
147
  texture = _context.sent;
148
+
149
+ if (loader === _textures.BasisLoader) {
150
+ texture = texture[0];
151
+ }
152
+
148
153
  tile.content.texture = {
149
154
  compressed: true,
150
155
  mipmaps: false,
@@ -153,27 +158,27 @@ function _parseI3STileContent() {
153
158
  data: texture
154
159
  };
155
160
 
156
- case 33:
157
- _context.next = 36;
161
+ case 34:
162
+ _context.next = 37;
158
163
  break;
159
164
 
160
- case 35:
165
+ case 36:
161
166
  tile.content.texture = _arrayBuffer;
162
167
 
163
- case 36:
168
+ case 37:
164
169
  tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);
165
170
 
166
171
  if (tile.content.material) {
167
172
  tile.content.texture = null;
168
173
  }
169
174
 
170
- _context.next = 40;
175
+ _context.next = 41;
171
176
  return parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);
172
177
 
173
- case 40:
178
+ case 41:
174
179
  return _context.abrupt("return", _context.sent);
175
180
 
176
- case 41:
181
+ case 42:
177
182
  case "end":
178
183
  return _context.stop();
179
184
  }
@@ -373,7 +378,7 @@ function parseHeaders(tileset, arrayBuffer) {
373
378
  };
374
379
  }
375
380
 
376
- function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder) {
381
+ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attributeCount, attributesOrder) {
377
382
  var attributes = {};
378
383
 
379
384
  var _iterator2 = _createForOfIteratorHelper(attributesOrder),
@@ -387,40 +392,39 @@ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCo
387
392
  var _vertexAttributes$att = vertexAttributes[attribute],
388
393
  valueType = _vertexAttributes$att.valueType,
389
394
  valuesPerElement = _vertexAttributes$att.valuesPerElement;
390
- var count = vertexCount;
391
395
 
392
- if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
393
- break;
394
- }
395
-
396
- var buffer = arrayBuffer.slice(byteOffset);
397
- var value = void 0;
398
-
399
- if (valueType === 'UInt64') {
400
- value = parseUint64Values(buffer, count * valuesPerElement, (0, _constants.sizeOf)(valueType));
401
- } else {
402
- var TypedArrayType = (0, _constants.getConstructorForDataFormat)(valueType);
403
- value = new TypedArrayType(buffer, 0, count * valuesPerElement);
404
- }
405
-
406
- attributes[attribute] = {
407
- value: value,
408
- type: _constants.GL_TYPE_MAP[valueType],
409
- size: valuesPerElement
410
- };
396
+ if (byteOffset + attributeCount * valuesPerElement * (0, _constants.sizeOf)(valueType) <= arrayBuffer.byteLength) {
397
+ var buffer = arrayBuffer.slice(byteOffset);
398
+ var value = void 0;
399
+
400
+ if (valueType === 'UInt64') {
401
+ value = parseUint64Values(buffer, attributeCount * valuesPerElement, (0, _constants.sizeOf)(valueType));
402
+ } else {
403
+ var TypedArrayType = (0, _constants.getConstructorForDataFormat)(valueType);
404
+ value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
405
+ }
406
+
407
+ attributes[attribute] = {
408
+ value: value,
409
+ type: _constants.GL_TYPE_MAP[valueType],
410
+ size: valuesPerElement
411
+ };
412
+
413
+ switch (attribute) {
414
+ case 'color':
415
+ attributes.color.normalized = true;
416
+ break;
411
417
 
412
- switch (attribute) {
413
- case 'color':
414
- attributes.color.normalized = true;
415
- break;
418
+ case 'position':
419
+ case 'region':
420
+ case 'normal':
421
+ default:
422
+ }
416
423
 
417
- case 'position':
418
- case 'region':
419
- case 'normal':
420
- default:
424
+ byteOffset = byteOffset + attributeCount * valuesPerElement * (0, _constants.sizeOf)(valueType);
425
+ } else if (attribute !== 'uv0') {
426
+ break;
421
427
  }
422
-
423
- byteOffset = byteOffset + count * valuesPerElement * (0, _constants.sizeOf)(valueType);
424
428
  }
425
429
  }
426
430
  } catch (err) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":["scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tile","tileset","options","context","content","featureIds","attributes","textureUrl","url","i3s","token","loader","fetch","response","decodeTextures","textureLoaderOptions","image","type","parse","texture","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","byteOffset","featureCount","isDracoGeometry","DracoLoader","draco","attributeNameEntry","decompressedGeometry","vertexCount","header","indices","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","store","defaultGeometrySchema","vertexAttributes","attributesOrder","ordering","featureAttributes","featureAttributeOrder","headers","parseHeaders","normalizeAttributes","normalizedVertexAttributes","offset","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","coordinateSystem","COORDINATE_SYSTEM","METER_OFFSETS","enuMatrix","parsePositions","modelMatrix","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","attributeIndex","byteLength","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","HeaderAttributeProperty","valueType","valuesPerElement","count","buffer","slice","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","Matrix4","cartographicOrigin","cartesianOrigin","Ellipsoid","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","Float64Array","length","scaleX","double","scaleY","i","x","y","z","subarray","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","intArray"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAWA;;AAEA;;;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,IAAIC,cAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAtB;;AAEA,SAASC,yBAAT,CAAmCC,aAAnC,EAAgG;AAC9F,UAAQA,aAAR;AACE,SAAK,UAAL;AACA,SAAK,KAAL;AACE,aAAOC,iCAAP;;AACF,SAAK,MAAL;AACE,aAAOC,qBAAP;;AACF,SAAK,KAAL;AACA,SAAK,KAAL;AACA;AACE,aAAOC,m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D,CAAf,CAA1B;AACD;;AAEDxG,EAAAA,UAAU,CAAC4C,EAAX,CAAcX,KAAd,GAAsBgI,MAAtB;AACD;;AAOD,SAASnH,qCAAT,CACER,YADF,EAE0B;AAAA;;AACxB,SAAOA,YAAP,aAAOA,YAAP,gDAAOA,YAAY,CAAE8C,QAArB,oFAAO,sBAAyB,iBAAzB,CAAP,2DAAO,uBAA6C+E,QAApD;AACD","sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n I3STilesetHeader,\n I3STileHeader,\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions,\n context?: LoaderContext\n) {\n tile.content = tile.content || {};\n tile.content.featureIds = tile.content.featureIds || null;\n\n tile.content.attributes = {};\n\n if (tile.textureUrl) {\n const url = getUrlWithToken(tile.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tile.textureFormat);\n const response = await fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tile.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n tile.content.texture = await context.parse(arrayBuffer, options);\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n tile.content.texture = await parse(arrayBuffer, loader, options);\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n const texture = await load(arrayBuffer, loader, tile.textureLoaderOptions);\n tile.content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n tile.content.texture = arrayBuffer;\n }\n }\n\n tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);\n if (tile.content.material) {\n tile.content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions\n) {\n if (!tile.content) {\n return tile;\n }\n\n const content = tile.content;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tile.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tileset.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(tileset, arrayBuffer);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tile);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n tile.content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = arrayBuffer.byteLength;\n\n return tile;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(tileset: I3STilesetHeader, arrayBuffer: ArrayBuffer) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of tileset.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n vertexCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // update count and byteOffset count by calculating from defaultGeometrySchema + binnary content\n const count = vertexCount;\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {\n break;\n }\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, count * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, count * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + count * valuesPerElement * sizeOf(valueType);\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, tile: I3STileHeader): Matrix4 {\n const mbs = tile.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"file":"parse-i3s-tile-content.js"}
1
+ {"version":3,"sources":["../../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":["scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tile","tileset","options","context","content","featureIds","attributes","textureUrl","url","i3s","token","loader","fetch","response","decodeTextures","textureLoaderOptions","image","type","parse","texture","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","byteOffset","featureCount","isDracoGeometry","DracoLoader","draco","attributeNameEntry","decompressedGeometry","vertexCount","header","indices","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","store","defaultGeometrySchema","vertexAttributes","attributesOrder","ordering","featureAttributes","featureAttributeOrder","headers","parseHeaders","normalizeAttributes","normalizedVertexAttributes","offset","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","coordinateSystem","COORDINATE_SYSTEM","METER_OFFSETS","enuMatrix","parsePositions","modelMatrix","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","attributeIndex","byteLength","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","HeaderAttributeProperty","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","Matrix4","cartographicOrigin","cartesianOrigin","Ellipsoid","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","Float64Array","length","scaleX","double","scaleY","i","x","y","z","subarray","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","intArray"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAW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AAGM,QAAb;AACD;;AAEDlG,EAAAA,2BAA2B,CAAChB,EAA5B,CAA+BX,KAA/B,GAAuCsH,qBAAvC;AACD;;AAQD,SAASxG,iCAAT,CACE/C,UADF,EAEED,UAFF,EAGQ;AACN,MAAMiK,cAAc,GAAGhK,UAAU,CAAC4C,EAAX,CAAcX,KAArC;AACA,MAAMgI,MAAM,GAAG,IAAIC,YAAJ,CAAiBF,cAAc,CAACvC,MAAhC,CAAf;;AAEA,OAAK,IAAIjB,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGwD,cAAc,CAACvC,MAA3C,EAAmDjB,KAAK,EAAxD,EAA4D;AAC1DyD,IAAAA,MAAM,CAACzD,KAAD,CAAN,GAAgBzG,UAAU,CAACiK,cAAc,CAACxD,KAAD,CAAf,CAA1B;AACD;;AAEDxG,EAAAA,UAAU,CAAC4C,EAAX,CAAcX,KAAd,GAAsBgI,MAAtB;AACD;;AAOD,SAASnH,qCAAT,CACER,YADF,EAE0B;AAAA;;AACxB,SAAOA,YAAP,aAAOA,YAAP,gDAAOA,YAAY,CAAE8C,QAArB,oFAAO,sBAAyB,iBAAzB,CAAP,2DAAO,uBAA6C+E,QAApD;AACD","sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n I3STilesetHeader,\n I3STileHeader,\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions,\n context?: LoaderContext\n) {\n tile.content = tile.content || {};\n tile.content.featureIds = tile.content.featureIds || null;\n\n tile.content.attributes = {};\n\n if (tile.textureUrl) {\n const url = getUrlWithToken(tile.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tile.textureFormat);\n const response = await fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tile.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n tile.content.texture = await context.parse(arrayBuffer, options);\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n tile.content.texture = await parse(arrayBuffer, loader, options);\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n let texture = await load(arrayBuffer, loader, tile.textureLoaderOptions);\n if (loader === BasisLoader) {\n texture = texture[0];\n }\n tile.content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n tile.content.texture = arrayBuffer;\n }\n }\n\n tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);\n if (tile.content.material) {\n tile.content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions\n) {\n if (!tile.content) {\n return tile;\n }\n\n const content = tile.content;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tile.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tileset.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(tileset, arrayBuffer);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tile);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n tile.content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = arrayBuffer.byteLength;\n\n return tile;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(tileset: I3STilesetHeader, arrayBuffer: ArrayBuffer) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of tileset.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n attributeCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (\n byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <=\n arrayBuffer.byteLength\n ) {\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);\n } else if (attribute !== 'uv0') {\n break;\n }\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, tile: I3STileHeader): Matrix4 {\n const mbs = tile.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"file":"parse-i3s-tile-content.js"}