@loaders.gl/tile-converter 4.0.0-beta.8 → 4.0.1

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 (39) hide show
  1. package/dist/converter.min.cjs +109 -109
  2. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +74 -0
  3. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -0
  4. package/dist/i3s-converter/helpers/attribute-metadata-info.js +157 -0
  5. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -0
  6. package/dist/i3s-converter/helpers/feature-attributes.d.ts +3 -28
  7. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  8. package/dist/i3s-converter/helpers/feature-attributes.js +16 -125
  9. package/dist/i3s-converter/helpers/feature-attributes.js.map +1 -1
  10. package/dist/i3s-converter/i3s-converter.d.ts +11 -5
  11. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  12. package/dist/i3s-converter/i3s-converter.js +31 -44
  13. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  14. package/dist/i3s-converter/types.d.ts +15 -0
  15. package/dist/i3s-converter/types.d.ts.map +1 -1
  16. package/dist/i3s-converter/types.js +6 -0
  17. package/dist/i3s-converter/types.js.map +1 -1
  18. package/dist/i3s-server/app.d.ts.map +1 -1
  19. package/dist/i3s-server/app.js +3 -6
  20. package/dist/i3s-server/app.js.map +1 -1
  21. package/dist/i3s-server/bin/i3s-server.min.cjs +86 -86
  22. package/dist/i3s-server/bin/www.js.map +1 -1
  23. package/dist/i3s-server/routes/index.d.ts +1 -1
  24. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  25. package/dist/i3s-server/routes/index.js +2 -5
  26. package/dist/i3s-server/routes/index.js.map +1 -1
  27. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  28. package/dist/i3s-server/routes/slpk-router.js +3 -3
  29. package/dist/i3s-server/routes/slpk-router.js.map +1 -1
  30. package/dist/index.cjs +269 -173
  31. package/package.json +15 -15
  32. package/src/i3s-converter/helpers/attribute-metadata-info.ts +246 -0
  33. package/src/i3s-converter/helpers/feature-attributes.ts +18 -180
  34. package/src/i3s-converter/i3s-converter.ts +46 -65
  35. package/src/i3s-converter/types.ts +16 -0
  36. package/src/i3s-server/app.ts +9 -4
  37. package/src/i3s-server/bin/www.ts +6 -0
  38. package/src/i3s-server/routes/index.ts +2 -4
  39. package/src/i3s-server/routes/slpk-router.ts +4 -3
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAEf,MAAM,SAAS,CAAC;AAEjB,OAAO,UAAU,MAAM,0BAA0B,CAAC;AA+BlD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;IAC7C,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,EAAE;QAAC,UAAU,EAAE,OAAO,CAAC;QA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iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -1,4 +1,5 @@
1
1
  var _process$env;
2
+ import { AttributeMetadataInfo } from "./helpers/attribute-metadata-info.js";
2
3
  import { load, encode, isBrowser } from '@loaders.gl/core';
3
4
  import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
4
5
  import { join } from 'path';
@@ -25,7 +26,7 @@ import { GLTFPrimitiveModeString } from "./types.js";
25
26
  import { WorkerFarm } from '@loaders.gl/worker-utils';
26
27
  import WriteQueue from "../lib/utils/write-queue.js";
27
28
  import { BROWSER_ERROR_MESSAGE } from "../constants.js";
28
- import { getAttributeTypesFromPropertyTable, getAttributeTypesFromSchema, createdStorageAttribute, getFieldAttributeType, createFieldAttribute, createPopupInfo } from "./helpers/feature-attributes.js";
29
+ import { getAttributeTypesMapFromPropertyTable, getAttributeTypesMapFromSchema } from "./helpers/feature-attributes.js";
29
30
  import { NodeIndexDocument } from "./helpers/node-index-document.js";
30
31
  import { isNestedTileset, loadNestedTileset, loadTile3DContent, loadFromArchive } from "./helpers/load-3d-tiles.js";
31
32
  import { Matrix4 } from '@math.gl/core';
@@ -40,6 +41,7 @@ const REFRESH_TOKEN_TIMEOUT = 1800;
40
41
  const CESIUM_DATASET_PREFIX = 'https://';
41
42
  export default class I3SConverter {
42
43
  constructor() {
44
+ this.attributeMetadataInfo = void 0;
43
45
  this.nodePages = void 0;
44
46
  this.options = void 0;
45
47
  this.layers0Path = void 0;
@@ -82,6 +84,10 @@ export default class I3SConverter {
82
84
  meshTopologyTypes: new Set(),
83
85
  metadataClasses: new Set()
84
86
  };
87
+ this.tileCountTotal = 0;
88
+ this.tileCountCurrentlyConverting = 0;
89
+ this.numberOfDigitsInPercentage = 0;
90
+ this.attributeMetadataInfo = new AttributeMetadataInfo();
85
91
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
86
92
  this.options = {};
87
93
  this.layers0Path = '';
@@ -194,8 +200,10 @@ export default class I3SConverter {
194
200
  meshTopologyTypes,
195
201
  metadataClasses
196
202
  } = this.preprocessData;
203
+ this.numberOfDigitsInPercentage = this.tileCountTotal > 100 ? Math.ceil(Math.log10(this.tileCountTotal)) - 2 : 0;
197
204
  console.log(`------------------------------------------------`);
198
205
  console.log(`Preprocess results:`);
206
+ console.log(`Tile count: ${this.tileCountTotal}`);
199
207
  console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);
200
208
  if (metadataClasses.size) {
201
209
  console.log(`Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`);
@@ -217,6 +225,7 @@ export default class I3SConverter {
217
225
  return null;
218
226
  }
219
227
  if (sourceTile.id) {
228
+ this.tileCountTotal++;
220
229
  console.log(`[analyze]: ${sourceTile.id}`);
221
230
  }
222
231
  let tileContent = null;
@@ -284,6 +293,12 @@ export default class I3SConverter {
284
293
  transform: new Matrix4(sourceRootTile.transform),
285
294
  parentNodes: [rootNode]
286
295
  }, this.convertTile.bind(this), this.finalizeTile.bind(this), this.options.maxDepth);
296
+ this.layers0.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;
297
+ this.layers0.fields = this.attributeMetadataInfo.fields;
298
+ this.layers0.popupInfo = this.attributeMetadataInfo.popupInfo;
299
+ if (this.attributeMetadataInfo.attributeStorageInfo.length) {
300
+ this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
301
+ }
287
302
  this.layers0.materialDefinitions = this.materialDefinitions;
288
303
  this.layers0.geometryDefinitions = transform(this.geometryConfigs.map(config => ({
289
304
  geometryConfig: {
@@ -366,7 +381,13 @@ export default class I3SConverter {
366
381
  return traversalProps;
367
382
  }
368
383
  if (sourceTile.id) {
369
- console.log(`[convert]: ${sourceTile.id}`);
384
+ this.tileCountCurrentlyConverting++;
385
+ let percentString = '';
386
+ if (this.tileCountTotal) {
387
+ const percent = this.tileCountCurrentlyConverting / this.tileCountTotal * 100;
388
+ percentString = ' ' + percent.toFixed(this.numberOfDigitsInPercentage);
389
+ }
390
+ console.log(`[convert${percentString}%]: ${sourceTile.id}`);
370
391
  }
371
392
  const {
372
393
  parentNodes,
@@ -452,7 +473,6 @@ export default class I3SConverter {
452
473
  return nodes;
453
474
  }
454
475
  async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
455
- var _this$layers;
456
476
  if (!this.isContentSupported(sourceTile) || !tileContent) {
457
477
  return null;
458
478
  }
@@ -464,7 +484,7 @@ export default class I3SConverter {
464
484
  const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({
465
485
  index: 0,
466
486
  obb: draftObb
467
- }, parentId)).index, propertyTable, this.featuresHashArray, (_this$layers = this.layers0) === null || _this$layers === void 0 ? void 0 : _this$layers.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
487
+ }, parentId)).index, propertyTable, this.featuresHashArray, this.attributeMetadataInfo.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
468
488
  return resourcesData;
469
489
  }
470
490
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
@@ -669,14 +689,13 @@ export default class I3SConverter {
669
689
  }
670
690
  }
671
691
  async _writeAttributes() {
672
- var _this$layers2, _this$layers2$attribu;
673
692
  let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
674
693
  let childPath = arguments.length > 1 ? arguments[1] : undefined;
675
694
  let slpkChildPath = arguments.length > 2 ? arguments[2] : undefined;
676
- if (attributes !== null && attributes !== void 0 && attributes.length && (_this$layers2 = this.layers0) !== null && _this$layers2 !== void 0 && (_this$layers2$attribu = _this$layers2.attributeStorageInfo) !== null && _this$layers2$attribu !== void 0 && _this$layers2$attribu.length) {
677
- const minimumLength = attributes.length < this.layers0.attributeStorageInfo.length ? attributes.length : this.layers0.attributeStorageInfo.length;
695
+ if (attributes !== null && attributes !== void 0 && attributes.length && this.attributeMetadataInfo.attributeStorageInfo.length) {
696
+ const minimumLength = attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length ? attributes.length : this.attributeMetadataInfo.attributeStorageInfo.length;
678
697
  for (let index = 0; index < minimumLength; index++) {
679
- const folderName = this.layers0.attributeStorageInfo[index].key;
698
+ const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
680
699
  const fileBuffer = new Uint8Array(attributes[index]);
681
700
  if (this.options.slpk) {
682
701
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
@@ -730,46 +749,14 @@ export default class I3SConverter {
730
749
  createAttributeStorageInfo(tileContent, propertyTable) {
731
750
  let attributeTypesMap = null;
732
751
  if (this.options.metadataClass) {
733
- if (!this.layers0.attributeStorageInfo.length && tileContent !== null && tileContent !== void 0 && tileContent.gltf) {
734
- attributeTypesMap = getAttributeTypesFromSchema(tileContent.gltf, this.options.metadataClass);
752
+ if (!this.attributeMetadataInfo.attributeStorageInfo.length && tileContent !== null && tileContent !== void 0 && tileContent.gltf) {
753
+ attributeTypesMap = getAttributeTypesMapFromSchema(tileContent.gltf, this.options.metadataClass);
735
754
  }
736
755
  } else if (propertyTable) {
737
- attributeTypesMap = getAttributeTypesFromPropertyTable(propertyTable);
756
+ attributeTypesMap = getAttributeTypesMapFromPropertyTable(propertyTable);
738
757
  }
739
758
  if (attributeTypesMap) {
740
- this.createStorageAttributes(attributeTypesMap);
741
- }
742
- }
743
- createStorageAttributes(attributeTypesMap) {
744
- if (!Object.keys(attributeTypesMap).length) {
745
- return;
746
- }
747
- const attributeTypes = {
748
- OBJECTID: 'OBJECTID',
749
- ...attributeTypesMap
750
- };
751
- let isUpdated = false;
752
- let attributeIndex = this.layers0.attributeStorageInfo.length;
753
- for (const key in attributeTypes) {
754
- const elementFound = this.layers0.attributeStorageInfo.find(element => element.name === key);
755
- if (!elementFound) {
756
- const attributeType = attributeTypes[key];
757
- const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
758
- const fieldAttributeType = getFieldAttributeType(attributeType);
759
- const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
760
- this.layers0.attributeStorageInfo.push(storageAttribute);
761
- this.layers0.fields.push(fieldAttribute);
762
- attributeIndex += 1;
763
- isUpdated = true;
764
- }
765
- }
766
- if (isUpdated) {
767
- const attributeNames = [];
768
- for (let info of this.layers0.attributeStorageInfo) {
769
- attributeNames.push(info.name);
770
- }
771
- this.layers0.popupInfo = createPopupInfo(attributeNames);
772
- this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
759
+ this.attributeMetadataInfo.addMetadataInfo(attributeTypesMap);
773
760
  }
774
761
  }
775
762
  async _finishConversion(params) {
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.js","names":["load","encode","isBrowser","CesiumIonLoader","Tiles3DLoader","join","v4","uuidv4","process","transform","md5","NodePages","writeFile","removeDir","writeFileForSlpk","removeFile","compressFileWithGzip","compressWithChildProcess","calculateFilesSize","timeConverter","convertB3dmToI3sGeometry","getPropertyTable","createBoundingVolumes","convertBoundingVolumeToI3SFullExtent","createSceneServerPath","convertGeometricErrorToScreenThreshold","PGMLoader","LAYERS","layersTemplate","GEOMETRY_DEFINITION","geometryDefinitionTemlate","SHARED_RESOURCES","sharedResourcesTemplate","validateNodeBoundingVolumes","KTX2BasisWriterWorker","ImageWriter","GLTFPrimitiveModeString","WorkerFarm","WriteQueue","BROWSER_ERROR_MESSAGE","getAttributeTypesFromPropertyTable","getAttributeTypesFromSchema","createdStorageAttribute","getFieldAttributeType","createFieldAttribute","createPopupInfo","NodeIndexDocument","isNestedTileset","loadNestedTileset","loadTile3DContent","loadFromArchive","Matrix4","createBoundingVolume","traverseDatasetWith","analyzeTileContent","mergePreprocessData","ION_DEFAULT_TOKEN","_process$env","env","IonToken","HARDCODED_NODES_PER_PAGE","_3D_TILES","_3D_OBJECT_LAYER_TYPE","REFRESH_TOKEN_TIMEOUT","CESIUM_DATASET_PREFIX","I3SConverter","constructor","nodePages","options","layers0Path","materialMap","materialDefinitions","geometryMap","geometryConfigs","vertexCounter","layers0","featuresHashArray","refinementCounter","validate","boundingVolumeWarnings","conversionStartTime","refreshTokenTime","sourceTileset","loadOptions","_nodeWorkers","reuseWorkers","useLocalLibraries","basis","format","workerUrl","draco","fetch","modules","geoidHeightModel","Loader","generateTextures","generateBoundingVolumes","layersHasTexture","workerSource","writeQueue","compressList","preprocessData","meshTopologyTypes","Set","metadataClasses","Map","tilesCount","tilesWithAddRefineCount","convert","console","log","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","sevenZipExe","maxDepth","token","instantNodeWriting","mergeMaterials","inquirer","metadataClass","analyze","Boolean","indexOf","startListening","useWriteFunction","preloadOptions","_fetchPreloadOptions","tilesetUrl","url","headers","preprocessResult","preprocessConversion","selectMetadataClassResult","selectMetadataClass","_createAndSaveTileset","_finishConversion","error","finalize","workerFarm","getWorkerFarm","destroy","sourceRootTile","root","analyzeTile","bind","undefined","Array","from","size","has","TRIANGLES","TRIANGLE_STRIP","sourceTile","traversalProps","isTileset","id","tileContent","loadGLTF","contentUrl","tilePreprocessData","_this$options$metadat","length","result","prompt","name","type","message","choices","_this$sourceTileset","_this$sourceTileset$r","_this$sourceTileset$r2","tilesetPath","e","sourceBoundingVolume","boundingVolume","_formLayers0","region","boundingVolumes","push","index","lodThreshold","obb","children","rootNode","createRootNode","parentNodes","convertTile","finalizeTile","geometryDefinitions","map","config","geometryConfig","store","defaultGeometrySchema","ordering","filter","attribute","_writeLayers0","filePath","save","_createSlpk","boundingVolumeRegion","_this$sourceTileset2","fullExtent","zmin","zmax","extent","xmin","ymin","xmax","ymax","layers0data","version","toUpperCase","href","nodesPerPage","compressGeometry","enqueue","archiveKey","writePromise","JSON","stringify","slpkTilesetPath","slpkFileName","transformationMatrix","clone","multiplyRight","parentNode","childNodes","_createNode","addChildren","newTraversalProps","conversionResults","currentTraversalProps","node","addNeighbors","_checkAddRefinementTypeForTile","_updateTilesetOptions","propertyTable","createAttributeStorageInfo","resourcesData","_convertResources","inPageId","nodes","nodeIds","nodesInPage","emptyResources","geometry","compressedGeometry","texture","hasUvRegions","sharedResources","meshMaterial","vertexCount","attributes","featureCount","resources","lodSelection","maxScreenThresholdSQ","find","val","metricType","maxError","nodeInPage","_updateNodeInNodePages","nodeData","createNodeIndexDocument","addData","mesh","_writeResources","warn","parentId","_this$layers","isContentSupported","draftObb","center","halfSize","quaternion","attributeStorageInfo","definition","findOrCreateGeometryDefinition","resource","material","nodeId","getNodeById","updateAll","updateMaterialByNodeId","_findOrCreateMaterial","texelCountHint","image","height","width","updateTexelCountHintByNodeId","updateVertexCountByNodeId","updateNodeAttributeByNodeId","updateFeatureCountByNodeId","saveNode","nodePath","geometryBuffer","childPath","slpkChildPath","_writeGeometries","_writeShared","_writeTexture","_writeAttributes","slpkGeometryPath","geometryPath","slpkCompressedGeometryPath","compressedGeometryPath","sharedData","sharedDataStr","slpkSharedPath","sharedPath","_getFormatByMimeType","mimeType","formats","textureData","bufferView","data","writeTextureFile","copyArrayBuffer","subarray","arrayToEncode","Uint8Array","ktx2TextureData","decodedFromKTX2TextureData","textureSetDefinitions","atlas","slpkTexturePath","compress","texturePath","_this$layers2","_this$layers2$attribu","arguments","minimumLength","folderName","key","fileBuffer","slpkAttributesPath","attributesPath","hash","get","newMaterialId","set","hasTexture","newGeometryId","attributeTypesMap","gltf","createStorageAttributes","Object","keys","attributeTypes","OBJECTID","isUpdated","attributeIndex","elementFound","element","attributeType","storageAttribute","fieldAttributeType","fieldAttribute","fields","attributeNames","info","popupInfo","layerType","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","tile","ADD_TILE_REFINEMENT","refine","includes"],"sources":["../../src/i3s-converter/i3s-converter.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n FeatureTableJson,\n Tiles3DLoaderOptions,\n Tiles3DTileContent,\n Tiles3DTileJSONPostprocessed,\n Tiles3DTilesetJSONPostprocessed\n} from '@loaders.gl/3d-tiles';\nimport type {WriteQueueItem} from '../lib/utils/write-queue';\nimport type {\n SceneLayer3D,\n BoundingVolumes,\n MaxScreenThresholdSQ,\n NodeInPage,\n Attribute\n} from '@loaders.gl/i3s';\nimport {load, encode, isBrowser} from '@loaders.gl/core';\nimport {CesiumIonLoader, Tiles3DLoader} from '@loaders.gl/3d-tiles';\nimport {Geoid} from '@math.gl/geoid';\nimport {join} from 'path';\nimport {v4 as uuidv4} from 'uuid';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport md5 from 'md5';\n\nimport NodePages from './helpers/node-pages';\nimport {writeFile, removeDir, writeFileForSlpk, removeFile} from '../lib/utils/file-utils';\nimport {\n compressFileWithGzip,\n compressWithChildProcess\n // generateHash128FromZip,\n // addFileToZip\n} from '../lib/utils/compress-util';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport convertB3dmToI3sGeometry, {getPropertyTable} from './helpers/geometry-converter';\nimport {\n createBoundingVolumes,\n convertBoundingVolumeToI3SFullExtent\n} from './helpers/coordinate-converter';\nimport {createSceneServerPath} from './helpers/create-scene-server-path';\nimport {convertGeometricErrorToScreenThreshold} from '../lib/utils/lod-conversion-utils';\nimport {PGMLoader} from '../pgm-loader';\n\nimport {LAYERS as layersTemplate} from './json-templates/layers';\nimport {GEOMETRY_DEFINITION as geometryDefinitionTemlate} from './json-templates/geometry-definitions';\nimport {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';\nimport {validateNodeBoundingVolumes} from './helpers/node-debug';\nimport {KTX2BasisWriterWorker} from '@loaders.gl/textures';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s';\nimport {ImageWriter} from '@loaders.gl/images';\nimport {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {\n GLTFPrimitiveModeString,\n I3SConvertedResources,\n PreprocessData,\n SharedResourcesArrays\n} from './types';\nimport {WorkerFarm} from '@loaders.gl/worker-utils';\nimport WriteQueue from '../lib/utils/write-queue';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {\n getAttributeTypesFromPropertyTable,\n getAttributeTypesFromSchema,\n createdStorageAttribute,\n getFieldAttributeType,\n createFieldAttribute,\n createPopupInfo\n} from './helpers/feature-attributes';\nimport {NodeIndexDocument} from './helpers/node-index-document';\nimport {\n isNestedTileset,\n loadNestedTileset,\n loadTile3DContent,\n loadFromArchive\n} from './helpers/load-3d-tiles';\nimport {Matrix4} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {createBoundingVolume} from '@loaders.gl/tiles';\nimport {TraversalConversionProps, traverseDatasetWith} from './helpers/tileset-traversal';\nimport {analyzeTileContent, mergePreprocessData} from './helpers/preprocess-3d-tiles';\n\nconst ION_DEFAULT_TOKEN = process.env?.IonToken;\nconst HARDCODED_NODES_PER_PAGE = 64;\nconst _3D_TILES = '3DTILES';\nconst _3D_OBJECT_LAYER_TYPE = '3DObject';\nconst REFRESH_TOKEN_TIMEOUT = 1800; // 30 minutes in seconds\nconst CESIUM_DATASET_PREFIX = 'https://';\n// const FS_FILE_TOO_LARGE = 'ERR_FS_FILE_TOO_LARGE';\n\n/**\n * Converter from 3d-tiles tileset to i3s layer\n */\nexport default class I3SConverter {\n nodePages: NodePages;\n options: any;\n layers0Path: string;\n materialMap: Map<string, number>;\n materialDefinitions: I3SMaterialDefinition[];\n geometryMap: Map<string, number>;\n geometryConfigs: {hasTexture: boolean; hasUvRegions: boolean}[];\n vertexCounter: number;\n layers0: SceneLayer3D | null;\n featuresHashArray: string[];\n refinementCounter: {\n tilesCount: number;\n tilesWithAddRefineCount: number;\n };\n validate: boolean;\n boundingVolumeWarnings?: string[] = [];\n conversionStartTime: [number, number] = [0, 0];\n refreshTokenTime: [number, number] = [0, 0];\n sourceTileset: Tiles3DTilesetJSONPostprocessed | null = null;\n loadOptions: Tiles3DLoaderOptions = {\n _nodeWorkers: true,\n reuseWorkers: true,\n useLocalLibraries: true,\n basis: {\n format: 'rgba32',\n // We need to load local fs workers because nodejs can't load workers from the Internet\n workerUrl: './modules/textures/dist/basis-worker-node.js'\n },\n // We need to load local fs workers because nodejs can't load workers from the Internet\n draco: {workerUrl: './modules/draco/dist/draco-worker-node.js'},\n fetch: {},\n modules: {}\n };\n geoidHeightModel: Geoid | null = null;\n Loader: LoaderWithParser = Tiles3DLoader;\n generateTextures: boolean;\n generateBoundingVolumes: boolean;\n layersHasTexture: boolean;\n workerSource: {[key: string]: string} = {};\n writeQueue: WriteQueue<WriteQueueItem> = new WriteQueue();\n compressList: string[] | null = null;\n preprocessData: PreprocessData = {\n meshTopologyTypes: new Set(),\n metadataClasses: new Set()\n };\n\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);\n this.options = {};\n this.layers0Path = '';\n this.materialMap = new Map();\n this.materialDefinitions = [];\n this.geometryMap = new Map();\n this.geometryConfigs = [];\n this.vertexCounter = 0;\n this.layers0 = null;\n this.featuresHashArray = [];\n this.refinementCounter = {\n tilesCount: 0,\n tilesWithAddRefineCount: 0\n };\n this.validate = false;\n this.generateTextures = false;\n this.generateBoundingVolumes = false;\n this.layersHasTexture = false;\n this.compressList = null;\n }\n\n /**\n * Convert a 3d tileset\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.maxDepth The max tree depth of conversion\n * @param options.slpk Generate slpk (Scene Layer Packages) output file\n * @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.token Token for Cesium ION tilesets authentication\n * @param options.draco Generate I3S 1.7 draco compressed geometries\n * @param options.validate -enable validation\n * @param options.generateTextures - generate alternative type of textures (to have non-compressed jpeg/png and compressed ktx2)\n * @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes\n * @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed\n */\n async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n sevenZipExe: string;\n egmFilePath: string;\n maxDepth?: number;\n slpk?: boolean;\n token?: string;\n draco?: boolean;\n mergeMaterials?: boolean;\n validate?: boolean;\n generateTextures?: boolean;\n generateBoundingVolumes?: boolean;\n instantNodeWriting?: boolean;\n inquirer?: Promise<unknown>;\n metadataClass?: string;\n analyze?: boolean;\n }): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n this.conversionStartTime = process.hrtime();\n const {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n validate,\n outputPath,\n draco = true,\n sevenZipExe,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n instantNodeWriting = false,\n mergeMaterials = true,\n inquirer,\n metadataClass,\n analyze = false\n } = options;\n this.options = {\n maxDepth,\n slpk,\n sevenZipExe,\n egmFilePath,\n draco,\n token,\n inputUrl,\n instantNodeWriting,\n mergeMaterials,\n inquirer,\n metadataClass\n };\n this.compressList = (this.options.instantNodeWriting && []) || null;\n this.validate = Boolean(validate);\n this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;\n this.generateTextures = Boolean(generateTextures);\n this.generateBoundingVolumes = Boolean(generateBoundingVolumes);\n\n this.writeQueue = new WriteQueue();\n this.writeQueue.startListening();\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n if (slpk) {\n this.nodePages.useWriteFunction(writeFileForSlpk);\n }\n\n try {\n const preloadOptions = await this._fetchPreloadOptions();\n let tilesetUrl = inputUrl;\n if (preloadOptions.url) {\n tilesetUrl = preloadOptions.url;\n }\n if (preloadOptions.headers) {\n this.loadOptions.fetch = {headers: preloadOptions.headers};\n }\n this.sourceTileset = await loadFromArchive(tilesetUrl, this.Loader, this.loadOptions);\n\n const preprocessResult =\n this.Loader === Tiles3DLoader || analyze ? await this.preprocessConversion() : true;\n\n if (preprocessResult && !analyze) {\n const selectMetadataClassResult = await this.selectMetadataClass();\n if (selectMetadataClassResult) {\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\n }\n }\n } catch (error) {\n throw error;\n } finally {\n await this.writeQueue.finalize();\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n return 'success';\n }\n\n /**\n * Preprocess stage of the tile converter. Traverse all the tiles tree and\n * check a tile content to be sure that the data is supported\n * @returns true - the conversion is possible, false - the tileset's content is not supported\n */\n private async preprocessConversion(): Promise<boolean> {\n console.log(`Analyze source tileset`);\n const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;\n await traverseDatasetWith<null>(\n sourceRootTile,\n null,\n this.analyzeTile.bind(this),\n undefined,\n this.options.maxDepth\n );\n const {meshTopologyTypes, metadataClasses} = this.preprocessData;\n\n console.log(`------------------------------------------------`);\n console.log(`Preprocess results:`);\n console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);\n\n if (metadataClasses.size) {\n console.log(\n `Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`\n );\n } else {\n console.log('Feature metadata classes have not been found');\n }\n\n console.log(`------------------------------------------------`);\n if (\n !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) &&\n !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)\n ) {\n console.log(\n 'The tileset is of unsupported mesh topology types. The conversion will be interrupted.'\n );\n console.log(`------------------------------------------------`);\n return false;\n }\n\n return true;\n }\n\n /**\n * Analyze a tile content. The callback for preprocess stage.\n * @param sourceTile - 3DTiles tile JSON metadata\n * @param traversalProps - mandatory argument but it is not used for the preprocess stage\n * @returns - nothing\n */\n private async analyzeTile(\n sourceTile: Tiles3DTileJSONPostprocessed,\n traversalProps: null\n ): Promise<null> {\n const isTileset = isNestedTileset(sourceTile);\n if (isTileset) {\n await loadNestedTileset(this.sourceTileset, sourceTile, this.loadOptions);\n return null;\n }\n if (sourceTile.id) {\n console.log(`[analyze]: ${sourceTile.id}`); // eslint-disable-line\n }\n\n let tileContent: Tiles3DTileContent | null = null;\n try {\n tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, {\n ...this.loadOptions,\n '3d-tiles': {...this.loadOptions['3d-tiles'], loadGLTF: false}\n });\n } catch (error) {\n console.log(\n `[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`\n );\n }\n const tilePreprocessData = await analyzeTileContent(tileContent);\n mergePreprocessData(this.preprocessData, tilePreprocessData);\n\n return null;\n }\n\n /**\n * Select metadata class associated with the set of feature attributes\n * @returns true if the metadata class has been successfully selected\n */\n private async selectMetadataClass() {\n const {metadataClasses} = this.preprocessData;\n if (metadataClasses.size > 1) {\n if (this.options.metadataClass?.length) {\n console.log(`${this.options.metadataClass} has been selected`);\n } else if (this.options.inquirer) {\n const result = await this.options.inquirer.prompt([\n {\n name: 'metadataClass',\n type: 'list',\n message: 'Select feature metadata data class to convert...',\n choices: Array.from(metadataClasses)\n }\n ]);\n this.options.metadataClass = result.metadataClass;\n console.log(`${result.metadataClass} has been selected`);\n } else {\n console.log(\n `A feature metadata class has not been selected. Start the converter with option \"--metadata-class\". For example, \"npx tile-converter ... --metadata-class ${\n Array.from(metadataClasses)[0]\n }\"`\n );\n console.log(`------------------------------------------------`);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Convert and save the layer and embedded tiles\n * @param outputPath - path to save output data\n * @param tilesetName - new tileset path\n */\n private async _createAndSaveTileset(outputPath: string, tilesetName: string): Promise<void> {\n const tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');\n\n this.materialDefinitions = [];\n this.materialMap = new Map();\n\n const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;\n const sourceBoundingVolume = createBoundingVolume(\n sourceRootTile.boundingVolume,\n new Matrix4(sourceRootTile.transform),\n null\n );\n\n this._formLayers0(\n tilesetName,\n sourceBoundingVolume,\n this.sourceTileset?.root?.boundingVolume?.region\n );\n\n const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);\n\n await this.nodePages.push({\n index: 0,\n lodThreshold: 0,\n obb: boundingVolumes.obb,\n children: []\n });\n\n const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);\n await traverseDatasetWith<TraversalConversionProps>(\n sourceRootTile,\n {\n transform: new Matrix4(sourceRootTile.transform),\n parentNodes: [rootNode]\n },\n this.convertTile.bind(this),\n this.finalizeTile.bind(this),\n this.options.maxDepth\n );\n\n this.layers0!.materialDefinitions = this.materialDefinitions;\n // @ts-ignore\n this.layers0.geometryDefinitions = transform(\n this.geometryConfigs.map((config) => ({\n geometryConfig: {...config, draco: this.options.draco}\n })),\n geometryDefinitionTemlate()\n );\n\n if (this.layersHasTexture === false) {\n this.layers0!.store.defaultGeometrySchema.ordering =\n this.layers0!.store.defaultGeometrySchema.ordering.filter(\n (attribute) => attribute !== 'uv0'\n );\n }\n\n await this._writeLayers0();\n createSceneServerPath(tilesetName, this.layers0!, tilesetPath);\n for (const filePath of this.compressList || []) {\n await compressFileWithGzip(filePath);\n await removeFile(filePath);\n }\n await this.nodePages.save();\n await this.writeQueue.finalize();\n await this._createSlpk(tilesetPath);\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param tilesetName - Name of layer\n * @param sourceBoundingVolume - initialized bounding volume of the source root tile\n * @param boundingVolumeRegion - region bounding volume of the source root tile\n */\n private _formLayers0(\n tilesetName: string,\n sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,\n boundingVolumeRegion?: number[]\n ): void {\n if (!this.sourceTileset?.root) {\n return;\n }\n const fullExtent = convertBoundingVolumeToI3SFullExtent(sourceBoundingVolume);\n if (boundingVolumeRegion) {\n fullExtent.zmin = boundingVolumeRegion[4];\n fullExtent.zmax = boundingVolumeRegion[5];\n }\n const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];\n const layers0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 0,\n name: tilesetName,\n href: './layers/0',\n store: {\n id: `{${uuidv4().toUpperCase()}}`,\n extent\n },\n nodePages: {\n nodesPerPage: HARDCODED_NODES_PER_PAGE\n },\n compressGeometry: this.options.draco,\n fullExtent\n };\n this.layers0 = transform(layers0data, layersTemplate());\n }\n\n /**\n * Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file\n */\n private async _writeLayers0(): Promise<void> {\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: '3dSceneLayer.json.gz',\n writePromise: () =>\n writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')\n });\n } else {\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(this.layers0Path, JSON.stringify(this.layers0))\n });\n }\n }\n\n /**\n * Pack files into *.slpk archive\n * @param tilesetPath - Path to save file\n */\n private async _createSlpk(tilesetPath: string): Promise<void> {\n if (this.options.slpk) {\n const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');\n const slpkFileName = `${tilesetPath}.slpk`;\n await compressWithChildProcess(\n slpkTilesetPath,\n slpkFileName,\n 0,\n '.',\n this.options.sevenZipExe\n );\n\n // TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe\n // const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;\n // try {\n // await generateHash128FromZip(slpkFileName, fileHash128Path);\n // await addFileToZip(\n // tilesetPath,\n // '@specialIndexFileHASH128@',\n // slpkFileName,\n // this.options.sevenZipExe\n // );\n // } catch (error) {\n // if (error.code === FS_FILE_TOO_LARGE) {\n // console.warn(`${slpkFileName} file is too big to generate a hash`); // eslint-disable-line\n // } else {\n // console.error(error); // eslint-disable-line\n // }\n // }\n // All converted files are contained in slpk now they can be deleted\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n }\n }\n\n /**\n * Convert the specific 3DTiles tile to I3S nodes.\n * This is callback function for the traversal generic function\n * @param sourceTile - current 3DTiles tile JSON metadata\n * @param traversalProps - traversal properties calculated recursively\n * @returns - traversal properties for the child tiles\n */\n private async convertTile(\n sourceTile: Tiles3DTileJSONPostprocessed,\n traversalProps: TraversalConversionProps\n ): Promise<TraversalConversionProps> {\n const isTileset = isNestedTileset(sourceTile);\n if (isTileset || sourceTile.type === 'empty') {\n if (isTileset) {\n if (sourceTile.id) {\n console.log(`[load]: ${sourceTile.id}`); // eslint-disable-line\n }\n await loadNestedTileset(this.sourceTileset, sourceTile, this.loadOptions);\n }\n return traversalProps;\n }\n if (sourceTile.id) {\n console.log(`[convert]: ${sourceTile.id}`); // eslint-disable-line\n }\n\n const {parentNodes, transform} = traversalProps;\n let transformationMatrix: Matrix4 = transform.clone();\n if (sourceTile.transform) {\n transformationMatrix = transformationMatrix.multiplyRight(sourceTile.transform);\n }\n const parentNode = parentNodes[0];\n const childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);\n await parentNode.addChildren(childNodes);\n\n const newTraversalProps: TraversalConversionProps = {\n transform: transformationMatrix,\n parentNodes: childNodes\n };\n return newTraversalProps;\n }\n\n /**\n * Do final action with nodes after the current node and all child nodes been converted.\n * @param conversionResults - array of conversion results of the current node\n * @param currentTraversalProps - traversal properties of the current node\n */\n private async finalizeTile(\n conversionResults: TraversalConversionProps[],\n currentTraversalProps: TraversalConversionProps\n ): Promise<void> {\n for (const result of conversionResults) {\n for (const node of result.parentNodes) {\n await node.addNeighbors();\n }\n }\n for (const node of currentTraversalProps.parentNodes) {\n await node.save();\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param parentNode - 3DNodeIndexDocument of parent node\n * @param sourceTile - source 3DTile data\n * @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param level - tree level\n */\n private async _createNode(\n parentNode: NodeIndexDocument,\n sourceTile: Tiles3DTileJSONPostprocessed,\n transformationMatrix: Matrix4\n ): Promise<NodeIndexDocument[]> {\n this._checkAddRefinementTypeForTile(sourceTile);\n\n await this._updateTilesetOptions();\n\n let tileContent: Tiles3DTileContent | null = null;\n try {\n tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, this.loadOptions);\n } catch (error) {\n console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);\n }\n const sourceBoundingVolume = createBoundingVolume(\n sourceTile.boundingVolume,\n transformationMatrix,\n null\n );\n let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);\n\n const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);\n this.createAttributeStorageInfo(tileContent, propertyTable);\n\n const resourcesData = await this._convertResources(\n sourceTile,\n transformationMatrix,\n sourceBoundingVolume,\n tileContent,\n parentNode.inPageId,\n propertyTable\n );\n\n const nodes: NodeIndexDocument[] = [];\n const nodeIds: number[] = [];\n const nodesInPage: NodeInPage[] = [];\n const emptyResources = {\n geometry: null,\n compressedGeometry: null,\n texture: null,\n hasUvRegions: false,\n sharedResources: null,\n meshMaterial: null,\n vertexCount: null,\n attributes: null,\n featureCount: null,\n boundingVolumes: null\n };\n\n for (const resources of resourcesData || [emptyResources]) {\n this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);\n\n if (this.generateBoundingVolumes && resources.boundingVolumes) {\n boundingVolumes = resources.boundingVolumes;\n }\n\n const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);\n const maxScreenThresholdSQ = lodSelection.find(\n (val) => val.metricType === 'maxScreenThresholdSQ'\n ) || {maxError: 0};\n\n const nodeInPage = await this._updateNodeInNodePages(\n maxScreenThresholdSQ,\n boundingVolumes,\n sourceTile,\n parentNode.inPageId,\n resources\n );\n\n const nodeData = await NodeIndexDocument.createNodeIndexDocument(\n parentNode,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);\n nodes.push(node);\n\n if (nodeInPage.mesh) {\n await this._writeResources(resources, node.id);\n }\n\n if (this.validate) {\n this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);\n\n if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {\n console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings); //eslint-disable-line\n }\n }\n\n nodeIds.push(nodeInPage.index);\n nodesInPage.push(nodeInPage);\n }\n\n return nodes;\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param sourceTile - source tile (3DTile)\n * @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @param tileContent - content of the source tile\n * @param parentId - id of parent node in node pages\n * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA\n * @returns - converted node resources\n */\n private async _convertResources(\n sourceTile: Tiles3DTileJSONPostprocessed,\n transformationMatrix: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere,\n tileContent: Tiles3DTileContent | null,\n parentId: number,\n propertyTable: FeatureTableJson | null\n ): Promise<I3SConvertedResources[] | null> {\n if (!this.isContentSupported(sourceTile) || !tileContent) {\n return null;\n }\n const draftObb = {\n center: [],\n halfSize: [],\n quaternion: []\n };\n const resourcesData = await convertB3dmToI3sGeometry(\n tileContent,\n transformationMatrix,\n boundingVolume,\n async () => (await this.nodePages.push({index: 0, obb: draftObb}, parentId)).index,\n propertyTable,\n this.featuresHashArray,\n this.layers0?.attributeStorageInfo,\n this.options.draco,\n this.generateBoundingVolumes,\n this.options.mergeMaterials,\n this.geoidHeightModel!,\n this.loadOptions.modules as Record<string, string>,\n this.options.metadataClass\n );\n return resourcesData;\n }\n\n /**\n * Update node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)\n * in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)\n * @param maxScreenThresholdSQ - Level of Details (LOD) metric\n * @param boundingVolumes - Bounding volumes\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param resources - the node resources data\n * @param resources.meshMaterial - PBR-like material object\n * @param resources.texture - texture image\n * @param resources.vertexCount - number of vertices in geometry\n * @param resources.featureCount - number of features\n * @param resources.geometry - Uint8Array with geometry attributes\n * @return the node object in node pages\n */\n private async _updateNodeInNodePages(\n maxScreenThresholdSQ: MaxScreenThresholdSQ,\n boundingVolumes: BoundingVolumes,\n sourceTile: Tiles3DTileJSONPostprocessed,\n parentId: number,\n resources: I3SConvertedResources\n ): Promise<NodeInPage> {\n const {meshMaterial, texture, vertexCount, featureCount, geometry, hasUvRegions} = resources;\n const nodeInPage: NodeInPage = {\n index: 0,\n lodThreshold: maxScreenThresholdSQ.maxError,\n obb: boundingVolumes.obb,\n children: []\n };\n if (geometry && this.isContentSupported(sourceTile)) {\n nodeInPage.mesh = {\n geometry: {\n definition: this.findOrCreateGeometryDefinition(Boolean(texture), hasUvRegions),\n resource: 0\n },\n attribute: {\n resource: 0\n },\n material: {\n definition: 0\n }\n };\n }\n\n let nodeId = resources.nodeId;\n let node: NodeInPage;\n if (!nodeId) {\n node = await this.nodePages.push(nodeInPage, parentId);\n } else {\n node = await this.nodePages.getNodeById(nodeId);\n }\n\n if (!nodeInPage.mesh) {\n console.log(`[warning]: node ${node.index} is created with empty content`);\n }\n\n NodePages.updateAll(node, nodeInPage);\n if (meshMaterial) {\n NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));\n }\n if (texture) {\n const texelCountHint = texture.image.height * texture.image.width;\n NodePages.updateTexelCountHintByNodeId(node, texelCountHint);\n }\n if (vertexCount) {\n this.vertexCounter += vertexCount;\n NodePages.updateVertexCountByNodeId(node, vertexCount);\n }\n NodePages.updateNodeAttributeByNodeId(node);\n if (featureCount) {\n NodePages.updateFeatureCountByNodeId(node, featureCount);\n }\n\n this.nodePages.saveNode(node);\n\n return node;\n }\n\n /**\n * Write node resources in files\n * @param resources - source tile (3DTile)\n * @param resources.geometry - Uint8Array with geometry attributes\n * @param resources.compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param resources.texture - texture image\n * @param resources.sharedResources - shared resource data object\n * @param resources.attributes - feature attributes\n * @return {Promise<void>}\n */\n private async _writeResources(resources: I3SConvertedResources, nodePath: string): Promise<void> {\n const {\n geometry: geometryBuffer,\n compressedGeometry,\n texture,\n sharedResources,\n attributes\n } = resources;\n const childPath = join(this.layers0Path, 'nodes', nodePath);\n const slpkChildPath = join('nodes', nodePath);\n\n await this._writeGeometries(geometryBuffer!, compressedGeometry!, childPath, slpkChildPath);\n await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);\n await this._writeTexture(texture, childPath, slpkChildPath);\n await this._writeAttributes(attributes, childPath, slpkChildPath);\n }\n\n /**\n * Write non-compressed and compressed geometries in files\n * @param geometryBuffer - Uint8Array with geometry attributes\n * @param compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n */\n private async _writeGeometries(\n geometryBuffer: ArrayBuffer,\n compressedGeometry: Promise<ArrayBuffer>,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkGeometryPath = join(childPath, 'geometries');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,\n writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')\n });\n } else {\n const geometryPath = join(childPath, 'geometries/0/');\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')\n });\n }\n\n if (this.options.draco) {\n if (this.options.slpk) {\n const slpkCompressedGeometryPath = join(childPath, 'geometries');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,\n writePromise: () =>\n writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')\n });\n } else {\n const compressedGeometryPath = join(childPath, 'geometries/1/');\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')\n });\n }\n }\n }\n\n /**\n * Write shared resources in a file\n * @param sharedResources - shared resource data object\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n * @param nodePath - a node path\n */\n private async _writeShared(\n sharedResources: SharedResourcesArrays | null,\n childPath: string,\n slpkChildPath: string,\n nodePath: string\n ): Promise<void> {\n if (!sharedResources) {\n return;\n }\n sharedResources.nodePath = nodePath;\n const sharedData = transform(sharedResources, sharedResourcesTemplate());\n const sharedDataStr = JSON.stringify(sharedData);\n if (this.options.slpk) {\n const slpkSharedPath = join(childPath, 'shared');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,\n writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')\n });\n } else {\n const sharedPath = join(childPath, 'shared/');\n await this.writeQueue.enqueue({writePromise: () => writeFile(sharedPath, sharedDataStr)});\n }\n }\n\n /**\n * Generates textures based on texture mime type and fill in textureSetDefinitions data.\n * @param texture - the texture image\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeTexture(\n texture: GLTFImagePostprocessed,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (texture) {\n const format = this._getFormatByMimeType(texture?.mimeType);\n const formats: TextureSetDefinitionFormats = [];\n const textureData = texture.bufferView!.data;\n\n switch (format) {\n case 'jpg':\n case 'png': {\n formats.push({name: '0', format});\n await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '1', format: 'ktx2'});\n // For Node.js texture.image.data is type of Buffer\n const copyArrayBuffer = texture.image.data.subarray();\n const arrayToEncode = new Uint8Array(copyArrayBuffer);\n const ktx2TextureData = encode(\n {...texture.image, data: arrayToEncode},\n KTX2BasisWriterWorker,\n {\n ...KTX2BasisWriterWorker.options,\n ['ktx2-basis-writer']: {\n // We need to load local fs workers because nodejs can't load workers from the Internet\n workerUrl: './modules/textures/dist/ktx2-basis-writer-worker-node.js'\n },\n reuseWorkers: true,\n _nodeWorkers: true,\n useLocalLibraries: true\n }\n );\n\n await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);\n }\n\n break;\n }\n\n case 'ktx2': {\n formats.push({name: '1', format});\n await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '0', format: 'jpg'});\n const decodedFromKTX2TextureData = encode(texture.image!.data[0], ImageWriter);\n await this.writeTextureFile(\n decodedFromKTX2TextureData,\n '0',\n 'jpg',\n childPath,\n slpkChildPath\n );\n }\n }\n }\n\n if (!this.layers0!.textureSetDefinitions!.length) {\n this.layers0!.textureSetDefinitions!.push({formats});\n this.layers0!.textureSetDefinitions!.push({formats, atlas: true});\n }\n }\n }\n\n /**\n * Write the texture image in a file\n * @param textureData\n * @param name\n * @param format\n * @param childPath\n * @param slpkChildPath\n */\n private async writeTextureFile(\n textureData: Uint8Array | Promise<ArrayBuffer>,\n name: string,\n format: 'jpg' | 'png' | 'ktx2',\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkTexturePath = join(childPath, 'textures');\n const compress = false;\n\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/textures/${name}.${format}`,\n writePromise: () =>\n writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)\n });\n } else {\n const texturePath = join(childPath, `textures/${name}/`);\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(texturePath, textureData, `index.${format}`)\n });\n }\n }\n\n /**\n * Write feature attributes in files\n * @param attributes - feature attributes\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeAttributes(\n attributes: ArrayBuffer[] | null = [],\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (attributes?.length && this.layers0?.attributeStorageInfo?.length) {\n const minimumLength =\n attributes.length < this.layers0.attributeStorageInfo.length\n ? attributes.length\n : this.layers0.attributeStorageInfo.length;\n\n for (let index = 0; index < minimumLength; index++) {\n const folderName = this.layers0.attributeStorageInfo[index].key;\n const fileBuffer = new Uint8Array(attributes[index]);\n\n if (this.options.slpk) {\n const slpkAttributesPath = join(childPath, 'attributes', folderName);\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,\n writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')\n });\n } else {\n const attributesPath = join(childPath, `attributes/${folderName}/0`);\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')\n });\n }\n }\n }\n }\n\n /**\n * Return file format by its MIME type\n * @param mimeType - feature attributes\n */\n private _getFormatByMimeType(mimeType: string | undefined): 'jpg' | 'png' | 'ktx2' {\n switch (mimeType) {\n case 'image/jpeg':\n return 'jpg';\n case 'image/png':\n return 'png';\n case 'image/ktx2':\n return 'ktx2';\n default:\n return 'jpg';\n }\n }\n\n /**\n * Find or create material in materialDefinitions array\n * @param material - end-to-end index of the node\n * @return material id\n */\n private _findOrCreateMaterial(material: I3SMaterialDefinition): number {\n const hash = md5(JSON.stringify(material));\n if (this.materialMap.has(hash)) {\n return this.materialMap.get(hash) || 0;\n }\n const newMaterialId = this.materialDefinitions.push(material) - 1;\n this.materialMap.set(hash, newMaterialId);\n return newMaterialId;\n }\n\n /**\n * Get unique geometry configuration index\n * In the end of conversion configurations will be transformed to geometryDefinitions array\n * @param hasTexture\n * @param hasUvRegions\n * @returns\n */\n private findOrCreateGeometryDefinition(hasTexture: boolean, hasUvRegions: boolean): number {\n const geometryConfig = {hasTexture, hasUvRegions};\n const hash = md5(JSON.stringify(geometryConfig));\n if (this.geometryMap.has(hash)) {\n return this.geometryMap.get(hash) || 0;\n }\n const newGeometryId = this.geometryConfigs.push(geometryConfig) - 1;\n this.geometryMap.set(hash, newGeometryId);\n return newGeometryId;\n }\n\n /**\n * Creates attribute storage info based on either extension schema or property table.\n * @param tileContent - content of the source tile\n * @param propertyTable - feature properties from EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA\n */\n private createAttributeStorageInfo(\n tileContent: Tiles3DTileContent | null,\n propertyTable: FeatureTableJson | null\n ): void {\n /*\n In case the tileset doesn't have either EXT_structural_metadata or EXT_feature_metadata\n that can be a source of attribute information so metadataClass is not specified\n we will collect attribute information for node attributes from the property table\n taken from each tile.\n */\n let attributeTypesMap: Record<string, Attribute> | null = null;\n if (this.options.metadataClass) {\n if (!this.layers0!.attributeStorageInfo!.length && tileContent?.gltf) {\n attributeTypesMap = getAttributeTypesFromSchema(\n tileContent.gltf,\n this.options.metadataClass\n );\n }\n } else if (propertyTable) {\n attributeTypesMap = getAttributeTypesFromPropertyTable(propertyTable);\n }\n\n if (attributeTypesMap) {\n this.createStorageAttributes(attributeTypesMap);\n }\n }\n\n /**\n * Creates Attribute Storage Info objects based on attribute's types\n * @param attributeTypesMap - set of attribute's types\n */\n private createStorageAttributes(attributeTypesMap: Record<string, Attribute>): void {\n if (!Object.keys(attributeTypesMap).length) {\n return;\n }\n const attributeTypes: Record<string, Attribute> = {\n OBJECTID: 'OBJECTID',\n ...attributeTypesMap\n };\n\n let isUpdated = false;\n let attributeIndex = this.layers0!.attributeStorageInfo!.length;\n for (const key in attributeTypes) {\n /*\n We will append a new attribute only in case it has not been added to the attribute storage info yet.\n */\n const elementFound = this.layers0!.attributeStorageInfo!.find(\n (element) => element.name === key\n );\n if (!elementFound) {\n const attributeType = attributeTypes[key];\n\n const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = getFieldAttributeType(attributeType);\n const fieldAttribute = createFieldAttribute(key, fieldAttributeType);\n\n this.layers0!.attributeStorageInfo!.push(storageAttribute);\n this.layers0!.fields!.push(fieldAttribute);\n attributeIndex += 1;\n isUpdated = true;\n }\n }\n if (isUpdated) {\n /*\n The attributeStorageInfo is updated. So, popupInfo should be recreated.\n Use attributeStorageInfo as a source of attribute names to create the popupInfo.\n */\n const attributeNames: string[] = [];\n for (let info of this.layers0!.attributeStorageInfo!) {\n attributeNames.push(info.name);\n }\n this.layers0!.popupInfo = createPopupInfo(attributeNames);\n this.layers0!.layerType = _3D_OBJECT_LAYER_TYPE;\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const {tilesCount, tilesWithAddRefineCount} = this.refinementCounter;\n const addRefinementPercentage = tilesWithAddRefineCount\n ? (tilesWithAddRefineCount / tilesCount) * 100\n : 0;\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n console.log(`Finishing conversion of ${_3D_TILES}`); // eslint-disable-line no-undef, no-console\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line no-undef, no-console\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line no-undef, no-console\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line no-undef, no-console\n console.log(`Percentage of tiles with \"ADD\" refinement type:`, addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n }\n\n /**\n * Fetch preload options for ION tileset\n */\n private async _fetchPreloadOptions(): Promise<any> {\n if (!this.Loader.preload) {\n return {};\n }\n const options = {\n 'cesium-ion': {accessToken: this.options.token || ION_DEFAULT_TOKEN}\n };\n const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);\n this.refreshTokenTime = process.hrtime();\n return {...options, ...preloadOptions};\n }\n\n /**\n * Update options of source tileset\n */\n private async _updateTilesetOptions(): Promise<void> {\n const diff = process.hrtime(this.refreshTokenTime);\n if (diff[0] < REFRESH_TOKEN_TIMEOUT) {\n return;\n }\n this.refreshTokenTime = process.hrtime();\n\n const preloadOptions = await this._fetchPreloadOptions();\n if (preloadOptions.headers) {\n this.loadOptions.fetch = {\n ...this.loadOptions.fetch,\n headers: preloadOptions.headers\n };\n console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console\n }\n }\n\n /** Do calculations of all tiles and tiles with \"ADD\" type of refinement.\n * @param tile\n */\n private _checkAddRefinementTypeForTile(tile: Tiles3DTileJSONPostprocessed): void {\n const ADD_TILE_REFINEMENT = 1;\n\n if (tile.refine === ADD_TILE_REFINEMENT) {\n this.refinementCounter.tilesWithAddRefineCount += 1;\n console.warn('This tile uses \"ADD\" type of refinement'); // eslint-disable-line\n }\n\n this.refinementCounter.tilesCount += 1;\n }\n\n /**\n * Check if the tile's content format is supported by the converter\n * @param sourceTile\n * @returns\n */\n private isContentSupported(sourceTile: Tiles3DTileJSONPostprocessed): boolean {\n return ['b3dm', 'glTF', 'scenegraph'].includes(sourceTile.type || '');\n }\n}\n"],"mappings":";AAkBA,SAAQA,IAAI,EAAEC,MAAM,EAAEC,SAAS,QAAO,kBAAkB;AACxD,SAAQC,eAAe,EAAEC,aAAa,QAAO,sBAAsB;AAEn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AAoB,CAAC,CAAC;IACxD,IAAID,cAAc,CAACI,OAAO,EAAE;MAC1B,IAAI,CAAClD,WAAW,CAACQ,KAAK,GAAG;QACvB,GAAG,IAAI,CAACR,WAAW,CAACQ,KAAK;QACzB0C,OAAO,EAAEJ,cAAc,CAACI;MAC1B,CAAC;MACDxB,OAAO,CAACC,GAAG,CAAC,6CAA6C,CAAC;IAC5D;EACF;EAKQkI,8BAA8BA,CAACyI,IAAkC,EAAQ;IAC/E,MAAMC,mBAAmB,GAAG,CAAC;IAE7B,IAAID,IAAI,CAACE,MAAM,KAAKD,mBAAmB,EAAE;MACvC,IAAI,CAAC7S,iBAAiB,CAAC8B,uBAAuB,IAAI,CAAC;MACnDE,OAAO,CAACqK,IAAI,CAAC,yCAAyC,CAAC;IACzD;IAEA,IAAI,CAACrM,iBAAiB,CAAC6B,UAAU,IAAI,CAAC;EACxC;EAOQ2K,kBAAkBA,CAACzH,UAAwC,EAAW;IAC5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAACgO,QAAQ,CAAChO,UAAU,CAACa,IAAI,IAAI,EAAE,CAAC;EACvE;AACF"}
1
+ {"version":3,"file":"i3s-converter.js","names":["AttributeMetadataInfo","load","encode","isBrowser","CesiumIonLoader","Tiles3DLoader","join","v4","uuidv4","process","transform","md5","NodePages","writeFile","removeDir","writeFileForSlpk","removeFile","compressFileWithGzip","compressWithChildProcess","calculateFilesSize","timeConverter","convertB3dmToI3sGeometry","getPropertyTable","createBoundingVolumes","convertBoundingVolumeToI3SFullExtent","createSceneServerPath","convertGeometricErrorToScreenThreshold","PGMLoader","LAYERS","layersTemplate","GEOMETRY_DEFINITION","geometryDefinitionTemlate","SHARED_RESOURCES","sharedResourcesTemplate","validateNodeBoundingVolumes","KTX2BasisWriterWorker","ImageWriter","GLTFPrimitiveModeString","WorkerFarm","WriteQueue","BROWSER_ERROR_MESSAGE","getAttributeTypesMapFromPropertyTable","getAttributeTypesMapFromSchema","NodeIndexDocument","isNestedTileset","loadNestedTileset","loadTile3DContent","loadFromArchive","Matrix4","createBoundingVolume","traverseDatasetWith","analyzeTileContent","mergePreprocessData","ION_DEFAULT_TOKEN","_process$env","env","IonToken","HARDCODED_NODES_PER_PAGE","_3D_TILES","_3D_OBJECT_LAYER_TYPE","REFRESH_TOKEN_TIMEOUT","CESIUM_DATASET_PREFIX","I3SConverter","constructor","attributeMetadataInfo","nodePages","options","layers0Path","materialMap","materialDefinitions","geometryMap","geometryConfigs","vertexCounter","layers0","featuresHashArray","refinementCounter","validate","boundingVolumeWarnings","conversionStartTime","refreshTokenTime","sourceTileset","loadOptions","_nodeWorkers","reuseWorkers","useLocalLibraries","basis","format","workerUrl","draco","fetch","modules","geoidHeightModel","Loader","generateTextures","generateBoundingVolumes","layersHasTexture","workerSource","writeQueue","compressList","preprocessData","meshTopologyTypes","Set","metadataClasses","tileCountTotal","tileCountCurrentlyConverting","numberOfDigitsInPercentage","Map","tilesCount","tilesWithAddRefineCount","convert","console","log","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","sevenZipExe","maxDepth","token","instantNodeWriting","mergeMaterials","inquirer","metadataClass","analyze","Boolean","indexOf","startListening","useWriteFunction","preloadOptions","_fetchPreloadOptions","tilesetUrl","url","headers","preprocessResult","preprocessConversion","selectMetadataClassResult","selectMetadataClass","_createAndSaveTileset","_finishConversion","error","finalize","workerFarm","getWorkerFarm","destroy","sourceRootTile","root","analyzeTile","bind","undefined","Math","ceil","log10","Array","from","size","has","TRIANGLES","TRIANGLE_STRIP","sourceTile","traversalProps","isTileset","id","tileContent","loadGLTF","contentUrl","tilePreprocessData","_this$options$metadat","length","result","prompt","name","type","message","choices","_this$sourceTileset","_this$sourceTileset$r","_this$sourceTileset$r2","tilesetPath","e","sourceBoundingVolume","boundingVolume","_formLayers0","region","boundingVolumes","push","index","lodThreshold","obb","children","rootNode","createRootNode","parentNodes","convertTile","finalizeTile","attributeStorageInfo","fields","popupInfo","layerType","geometryDefinitions","map","config","geometryConfig","store","defaultGeometrySchema","ordering","filter","attribute","_writeLayers0","filePath","save","_createSlpk","boundingVolumeRegion","_this$sourceTileset2","fullExtent","zmin","zmax","extent","xmin","ymin","xmax","ymax","layers0data","version","toUpperCase","href","nodesPerPage","compressGeometry","enqueue","archiveKey","writePromise","JSON","stringify","slpkTilesetPath","slpkFileName","percentString","percent","toFixed","transformationMatrix","clone","multiplyRight","parentNode","childNodes","_createNode","addChildren","newTraversalProps","conversionResults","currentTraversalProps","node","addNeighbors","_checkAddRefinementTypeForTile","_updateTilesetOptions","propertyTable","createAttributeStorageInfo","resourcesData","_convertResources","inPageId","nodes","nodeIds","nodesInPage","emptyResources","geometry","compressedGeometry","texture","hasUvRegions","sharedResources","meshMaterial","vertexCount","attributes","featureCount","resources","lodSelection","maxScreenThresholdSQ","find","val","metricType","maxError","nodeInPage","_updateNodeInNodePages","nodeData","createNodeIndexDocument","addData","mesh","_writeResources","warn","parentId","isContentSupported","draftObb","center","halfSize","quaternion","definition","findOrCreateGeometryDefinition","resource","material","nodeId","getNodeById","updateAll","updateMaterialByNodeId","_findOrCreateMaterial","texelCountHint","image","height","width","updateTexelCountHintByNodeId","updateVertexCountByNodeId","updateNodeAttributeByNodeId","updateFeatureCountByNodeId","saveNode","nodePath","geometryBuffer","childPath","slpkChildPath","_writeGeometries","_writeShared","_writeTexture","_writeAttributes","slpkGeometryPath","geometryPath","slpkCompressedGeometryPath","compressedGeometryPath","sharedData","sharedDataStr","slpkSharedPath","sharedPath","_getFormatByMimeType","mimeType","formats","textureData","bufferView","data","writeTextureFile","copyArrayBuffer","subarray","arrayToEncode","Uint8Array","ktx2TextureData","decodedFromKTX2TextureData","textureSetDefinitions","atlas","slpkTexturePath","compress","texturePath","arguments","minimumLength","folderName","key","fileBuffer","slpkAttributesPath","attributesPath","hash","get","newMaterialId","set","hasTexture","newGeometryId","attributeTypesMap","gltf","addMetadataInfo","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","tile","ADD_TILE_REFINEMENT","refine","includes"],"sources":["../../src/i3s-converter/i3s-converter.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport {AttributeMetadataInfo} from './helpers/attribute-metadata-info';\n\nimport type {\n FeatureTableJson,\n Tiles3DLoaderOptions,\n Tiles3DTileContent,\n Tiles3DTileJSONPostprocessed,\n Tiles3DTilesetJSONPostprocessed\n} from '@loaders.gl/3d-tiles';\nimport type {WriteQueueItem} from '../lib/utils/write-queue';\nimport type {\n SceneLayer3D,\n BoundingVolumes,\n MaxScreenThresholdSQ,\n NodeInPage,\n Attribute\n} from '@loaders.gl/i3s';\nimport {load, encode, isBrowser} from '@loaders.gl/core';\nimport {CesiumIonLoader, Tiles3DLoader} from '@loaders.gl/3d-tiles';\nimport {Geoid} from '@math.gl/geoid';\nimport {join} from 'path';\nimport {v4 as uuidv4} from 'uuid';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport md5 from 'md5';\n\nimport NodePages from './helpers/node-pages';\nimport {writeFile, removeDir, writeFileForSlpk, removeFile} from '../lib/utils/file-utils';\nimport {\n compressFileWithGzip,\n compressWithChildProcess\n // generateHash128FromZip,\n // addFileToZip\n} from '../lib/utils/compress-util';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport convertB3dmToI3sGeometry, {getPropertyTable} from './helpers/geometry-converter';\nimport {\n createBoundingVolumes,\n convertBoundingVolumeToI3SFullExtent\n} from './helpers/coordinate-converter';\nimport {createSceneServerPath} from './helpers/create-scene-server-path';\nimport {convertGeometricErrorToScreenThreshold} from '../lib/utils/lod-conversion-utils';\nimport {PGMLoader} from '../pgm-loader';\n\nimport {LAYERS as layersTemplate} from './json-templates/layers';\nimport {GEOMETRY_DEFINITION as geometryDefinitionTemlate} from './json-templates/geometry-definitions';\nimport {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';\nimport {validateNodeBoundingVolumes} from './helpers/node-debug';\nimport {KTX2BasisWriterWorker} from '@loaders.gl/textures';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s';\nimport {ImageWriter} from '@loaders.gl/images';\nimport {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {\n GLTFPrimitiveModeString,\n I3SConvertedResources,\n PreprocessData,\n SharedResourcesArrays\n} from './types';\nimport {WorkerFarm} from '@loaders.gl/worker-utils';\nimport WriteQueue from '../lib/utils/write-queue';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {\n getAttributeTypesMapFromPropertyTable,\n getAttributeTypesMapFromSchema\n} from './helpers/feature-attributes';\nimport {NodeIndexDocument} from './helpers/node-index-document';\nimport {\n isNestedTileset,\n loadNestedTileset,\n loadTile3DContent,\n loadFromArchive\n} from './helpers/load-3d-tiles';\nimport {Matrix4} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {createBoundingVolume} from '@loaders.gl/tiles';\nimport {TraversalConversionProps, traverseDatasetWith} from './helpers/tileset-traversal';\nimport {analyzeTileContent, mergePreprocessData} from './helpers/preprocess-3d-tiles';\n\nconst ION_DEFAULT_TOKEN = process.env?.IonToken;\nconst HARDCODED_NODES_PER_PAGE = 64;\nconst _3D_TILES = '3DTILES';\nconst _3D_OBJECT_LAYER_TYPE = '3DObject';\nconst REFRESH_TOKEN_TIMEOUT = 1800; // 30 minutes in seconds\nconst CESIUM_DATASET_PREFIX = 'https://';\n// const FS_FILE_TOO_LARGE = 'ERR_FS_FILE_TOO_LARGE';\n\n/**\n * Converter from 3d-tiles tileset to i3s layer\n */\nexport default class I3SConverter {\n attributeMetadataInfo: AttributeMetadataInfo;\n nodePages: NodePages;\n options: any;\n layers0Path: string;\n materialMap: Map<string, number>;\n materialDefinitions: I3SMaterialDefinition[];\n geometryMap: Map<string, number>;\n geometryConfigs: {hasTexture: boolean; hasUvRegions: boolean}[];\n vertexCounter: number;\n layers0: SceneLayer3D | null;\n featuresHashArray: string[];\n refinementCounter: {\n tilesCount: number;\n tilesWithAddRefineCount: number;\n };\n validate: boolean;\n boundingVolumeWarnings?: string[] = [];\n conversionStartTime: [number, number] = [0, 0];\n refreshTokenTime: [number, number] = [0, 0];\n sourceTileset: Tiles3DTilesetJSONPostprocessed | null = null;\n loadOptions: Tiles3DLoaderOptions = {\n _nodeWorkers: true,\n reuseWorkers: true,\n useLocalLibraries: true,\n basis: {\n format: 'rgba32',\n // We need to load local fs workers because nodejs can't load workers from the Internet\n workerUrl: './modules/textures/dist/basis-worker-node.js'\n },\n // We need to load local fs workers because nodejs can't load workers from the Internet\n draco: {workerUrl: './modules/draco/dist/draco-worker-node.js'},\n fetch: {},\n modules: {}\n };\n geoidHeightModel: Geoid | null = null;\n Loader: LoaderWithParser = Tiles3DLoader;\n generateTextures: boolean;\n generateBoundingVolumes: boolean;\n layersHasTexture: boolean;\n workerSource: {[key: string]: string} = {};\n writeQueue: WriteQueue<WriteQueueItem> = new WriteQueue();\n compressList: string[] | null = null;\n preprocessData: PreprocessData = {\n meshTopologyTypes: new Set(),\n metadataClasses: new Set()\n };\n /** Total count of tiles in tileset */\n tileCountTotal: number = 0;\n /** Count of tiles already converted plus one (refers to the tile currently being converted) */\n tileCountCurrentlyConverting: number = 0;\n /**\n * The number of digits to appear after decimal point in the string representation of the tile count.\n * It's calculated based on the total count of tiles.\n */\n numberOfDigitsInPercentage: number = 0;\n\n constructor() {\n this.attributeMetadataInfo = new AttributeMetadataInfo();\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);\n this.options = {};\n this.layers0Path = '';\n this.materialMap = new Map();\n this.materialDefinitions = [];\n this.geometryMap = new Map();\n this.geometryConfigs = [];\n this.vertexCounter = 0;\n this.layers0 = null;\n this.featuresHashArray = [];\n this.refinementCounter = {\n tilesCount: 0,\n tilesWithAddRefineCount: 0\n };\n this.validate = false;\n this.generateTextures = false;\n this.generateBoundingVolumes = false;\n this.layersHasTexture = false;\n this.compressList = null;\n }\n\n /**\n * Convert a 3d tileset\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.maxDepth The max tree depth of conversion\n * @param options.slpk Generate slpk (Scene Layer Packages) output file\n * @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.token Token for Cesium ION tilesets authentication\n * @param options.draco Generate I3S 1.7 draco compressed geometries\n * @param options.validate -enable validation\n * @param options.generateTextures - generate alternative type of textures (to have non-compressed jpeg/png and compressed ktx2)\n * @param options.generateBoundingVolumes - generate bounding volumes from vertices coordinates instead of source tiles bounding volumes\n * @param options.instantNodeWriting - Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed\n */\n async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n sevenZipExe: string;\n egmFilePath: string;\n maxDepth?: number;\n slpk?: boolean;\n token?: string;\n draco?: boolean;\n mergeMaterials?: boolean;\n validate?: boolean;\n generateTextures?: boolean;\n generateBoundingVolumes?: boolean;\n instantNodeWriting?: boolean;\n inquirer?: Promise<unknown>;\n metadataClass?: string;\n analyze?: boolean;\n }): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n this.conversionStartTime = process.hrtime();\n const {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n validate,\n outputPath,\n draco = true,\n sevenZipExe,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n instantNodeWriting = false,\n mergeMaterials = true,\n inquirer,\n metadataClass,\n analyze = false\n } = options;\n this.options = {\n maxDepth,\n slpk,\n sevenZipExe,\n egmFilePath,\n draco,\n token,\n inputUrl,\n instantNodeWriting,\n mergeMaterials,\n inquirer,\n metadataClass\n };\n this.compressList = (this.options.instantNodeWriting && []) || null;\n this.validate = Boolean(validate);\n this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;\n this.generateTextures = Boolean(generateTextures);\n this.generateBoundingVolumes = Boolean(generateBoundingVolumes);\n\n this.writeQueue = new WriteQueue();\n this.writeQueue.startListening();\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n if (slpk) {\n this.nodePages.useWriteFunction(writeFileForSlpk);\n }\n\n try {\n const preloadOptions = await this._fetchPreloadOptions();\n let tilesetUrl = inputUrl;\n if (preloadOptions.url) {\n tilesetUrl = preloadOptions.url;\n }\n if (preloadOptions.headers) {\n this.loadOptions.fetch = {headers: preloadOptions.headers};\n }\n this.sourceTileset = await loadFromArchive(tilesetUrl, this.Loader, this.loadOptions);\n\n const preprocessResult =\n this.Loader === Tiles3DLoader || analyze ? await this.preprocessConversion() : true;\n\n if (preprocessResult && !analyze) {\n const selectMetadataClassResult = await this.selectMetadataClass();\n if (selectMetadataClassResult) {\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\n }\n }\n } catch (error) {\n throw error;\n } finally {\n await this.writeQueue.finalize();\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n return 'success';\n }\n\n /**\n * Preprocess stage of the tile converter. Traverse all the tiles tree and\n * check a tile content to be sure that the data is supported\n * @returns true - the conversion is possible, false - the tileset's content is not supported\n */\n private async preprocessConversion(): Promise<boolean> {\n console.log(`Analyze source tileset`);\n const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;\n await traverseDatasetWith<null>(\n sourceRootTile,\n null,\n this.analyzeTile.bind(this),\n undefined,\n this.options.maxDepth\n );\n const {meshTopologyTypes, metadataClasses} = this.preprocessData;\n\n this.numberOfDigitsInPercentage =\n this.tileCountTotal > 100 ? Math.ceil(Math.log10(this.tileCountTotal)) - 2 : 0;\n\n console.log(`------------------------------------------------`);\n console.log(`Preprocess results:`);\n console.log(`Tile count: ${this.tileCountTotal}`);\n console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);\n\n if (metadataClasses.size) {\n console.log(\n `Feature metadata classes have been found: ${Array.from(metadataClasses).join(', ')}`\n );\n } else {\n console.log('Feature metadata classes have not been found');\n }\n\n console.log(`------------------------------------------------`);\n if (\n !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) &&\n !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)\n ) {\n console.log(\n 'The tileset is of unsupported mesh topology types. The conversion will be interrupted.'\n );\n console.log(`------------------------------------------------`);\n return false;\n }\n\n return true;\n }\n\n /**\n * Analyze a tile content. The callback for preprocess stage.\n * @param sourceTile - 3DTiles tile JSON metadata\n * @param traversalProps - mandatory argument but it is not used for the preprocess stage\n * @returns - nothing\n */\n private async analyzeTile(\n sourceTile: Tiles3DTileJSONPostprocessed,\n traversalProps: null\n ): Promise<null> {\n const isTileset = isNestedTileset(sourceTile);\n if (isTileset) {\n await loadNestedTileset(this.sourceTileset, sourceTile, this.loadOptions);\n return null;\n }\n if (sourceTile.id) {\n this.tileCountTotal++;\n console.log(`[analyze]: ${sourceTile.id}`); // eslint-disable-line\n }\n\n let tileContent: Tiles3DTileContent | null = null;\n try {\n tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, {\n ...this.loadOptions,\n '3d-tiles': {...this.loadOptions['3d-tiles'], loadGLTF: false}\n });\n } catch (error) {\n console.log(\n `[warning]: Failed to load ${sourceTile.contentUrl}. An I3S tile with empty content will be added to the output tileset`\n );\n }\n const tilePreprocessData = await analyzeTileContent(tileContent);\n mergePreprocessData(this.preprocessData, tilePreprocessData);\n\n return null;\n }\n\n /**\n * Select metadata class associated with the set of feature attributes\n * @returns true if the metadata class has been successfully selected\n */\n private async selectMetadataClass() {\n const {metadataClasses} = this.preprocessData;\n if (metadataClasses.size > 1) {\n if (this.options.metadataClass?.length) {\n console.log(`${this.options.metadataClass} has been selected`);\n } else if (this.options.inquirer) {\n const result = await this.options.inquirer.prompt([\n {\n name: 'metadataClass',\n type: 'list',\n message: 'Select feature metadata data class to convert...',\n choices: Array.from(metadataClasses)\n }\n ]);\n this.options.metadataClass = result.metadataClass;\n console.log(`${result.metadataClass} has been selected`);\n } else {\n console.log(\n `A feature metadata class has not been selected. Start the converter with option \"--metadata-class\". For example, \"npx tile-converter ... --metadata-class ${\n Array.from(metadataClasses)[0]\n }\"`\n );\n console.log(`------------------------------------------------`);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Convert and save the layer and embedded tiles\n * @param outputPath - path to save output data\n * @param tilesetName - new tileset path\n */\n private async _createAndSaveTileset(outputPath: string, tilesetName: string): Promise<void> {\n const tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');\n\n this.materialDefinitions = [];\n this.materialMap = new Map();\n\n const sourceRootTile: Tiles3DTileJSONPostprocessed = this.sourceTileset!.root!;\n const sourceBoundingVolume = createBoundingVolume(\n sourceRootTile.boundingVolume,\n new Matrix4(sourceRootTile.transform),\n null\n );\n\n this._formLayers0(\n tilesetName,\n sourceBoundingVolume,\n this.sourceTileset?.root?.boundingVolume?.region\n );\n\n const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);\n\n await this.nodePages.push({\n index: 0,\n lodThreshold: 0,\n obb: boundingVolumes.obb,\n children: []\n });\n\n const rootNode = await NodeIndexDocument.createRootNode(boundingVolumes, this);\n await traverseDatasetWith<TraversalConversionProps>(\n sourceRootTile,\n {\n transform: new Matrix4(sourceRootTile.transform),\n parentNodes: [rootNode]\n },\n this.convertTile.bind(this),\n this.finalizeTile.bind(this),\n this.options.maxDepth\n );\n\n this.layers0!.attributeStorageInfo = this.attributeMetadataInfo.attributeStorageInfo;\n this.layers0!.fields = this.attributeMetadataInfo.fields;\n this.layers0!.popupInfo = this.attributeMetadataInfo.popupInfo;\n\n if (this.attributeMetadataInfo.attributeStorageInfo.length) {\n this.layers0!.layerType = _3D_OBJECT_LAYER_TYPE;\n }\n\n this.layers0!.materialDefinitions = this.materialDefinitions;\n // @ts-ignore\n this.layers0.geometryDefinitions = transform(\n this.geometryConfigs.map((config) => ({\n geometryConfig: {...config, draco: this.options.draco}\n })),\n geometryDefinitionTemlate()\n );\n\n if (this.layersHasTexture === false) {\n this.layers0!.store.defaultGeometrySchema.ordering =\n this.layers0!.store.defaultGeometrySchema.ordering.filter(\n (attribute) => attribute !== 'uv0'\n );\n }\n\n await this._writeLayers0();\n createSceneServerPath(tilesetName, this.layers0!, tilesetPath);\n for (const filePath of this.compressList || []) {\n await compressFileWithGzip(filePath);\n await removeFile(filePath);\n }\n await this.nodePages.save();\n await this.writeQueue.finalize();\n await this._createSlpk(tilesetPath);\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param tilesetName - Name of layer\n * @param sourceBoundingVolume - initialized bounding volume of the source root tile\n * @param boundingVolumeRegion - region bounding volume of the source root tile\n */\n private _formLayers0(\n tilesetName: string,\n sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,\n boundingVolumeRegion?: number[]\n ): void {\n if (!this.sourceTileset?.root) {\n return;\n }\n const fullExtent = convertBoundingVolumeToI3SFullExtent(sourceBoundingVolume);\n if (boundingVolumeRegion) {\n fullExtent.zmin = boundingVolumeRegion[4];\n fullExtent.zmax = boundingVolumeRegion[5];\n }\n const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];\n const layers0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 0,\n name: tilesetName,\n href: './layers/0',\n store: {\n id: `{${uuidv4().toUpperCase()}}`,\n extent\n },\n nodePages: {\n nodesPerPage: HARDCODED_NODES_PER_PAGE\n },\n compressGeometry: this.options.draco,\n fullExtent\n };\n this.layers0 = transform(layers0data, layersTemplate());\n }\n\n /**\n * Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file\n */\n private async _writeLayers0(): Promise<void> {\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: '3dSceneLayer.json.gz',\n writePromise: () =>\n writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')\n });\n } else {\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(this.layers0Path, JSON.stringify(this.layers0))\n });\n }\n }\n\n /**\n * Pack files into *.slpk archive\n * @param tilesetPath - Path to save file\n */\n private async _createSlpk(tilesetPath: string): Promise<void> {\n if (this.options.slpk) {\n const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');\n const slpkFileName = `${tilesetPath}.slpk`;\n await compressWithChildProcess(\n slpkTilesetPath,\n slpkFileName,\n 0,\n '.',\n this.options.sevenZipExe\n );\n\n // TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe\n // const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;\n // try {\n // await generateHash128FromZip(slpkFileName, fileHash128Path);\n // await addFileToZip(\n // tilesetPath,\n // '@specialIndexFileHASH128@',\n // slpkFileName,\n // this.options.sevenZipExe\n // );\n // } catch (error) {\n // if (error.code === FS_FILE_TOO_LARGE) {\n // console.warn(`${slpkFileName} file is too big to generate a hash`); // eslint-disable-line\n // } else {\n // console.error(error); // eslint-disable-line\n // }\n // }\n // All converted files are contained in slpk now they can be deleted\n try {\n await removeDir(tilesetPath);\n } catch (e) {\n // do nothing\n }\n }\n }\n\n /**\n * Convert the specific 3DTiles tile to I3S nodes.\n * This is callback function for the traversal generic function\n * @param sourceTile - current 3DTiles tile JSON metadata\n * @param traversalProps - traversal properties calculated recursively\n * @returns - traversal properties for the child tiles\n */\n private async convertTile(\n sourceTile: Tiles3DTileJSONPostprocessed,\n traversalProps: TraversalConversionProps\n ): Promise<TraversalConversionProps> {\n const isTileset = isNestedTileset(sourceTile);\n if (isTileset || sourceTile.type === 'empty') {\n if (isTileset) {\n if (sourceTile.id) {\n console.log(`[load]: ${sourceTile.id}`); // eslint-disable-line\n }\n await loadNestedTileset(this.sourceTileset, sourceTile, this.loadOptions);\n }\n return traversalProps;\n }\n if (sourceTile.id) {\n // Print the tile number that is currently being converted.\n this.tileCountCurrentlyConverting++;\n let percentString = '';\n if (this.tileCountTotal) {\n const percent = (this.tileCountCurrentlyConverting / this.tileCountTotal) * 100;\n percentString = ' ' + percent.toFixed(this.numberOfDigitsInPercentage);\n }\n console.log(`[convert${percentString}%]: ${sourceTile.id}`); // eslint-disable-line\n }\n\n const {parentNodes, transform} = traversalProps;\n let transformationMatrix: Matrix4 = transform.clone();\n if (sourceTile.transform) {\n transformationMatrix = transformationMatrix.multiplyRight(sourceTile.transform);\n }\n const parentNode = parentNodes[0];\n const childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);\n await parentNode.addChildren(childNodes);\n\n const newTraversalProps: TraversalConversionProps = {\n transform: transformationMatrix,\n parentNodes: childNodes\n };\n return newTraversalProps;\n }\n\n /**\n * Do final action with nodes after the current node and all child nodes been converted.\n * @param conversionResults - array of conversion results of the current node\n * @param currentTraversalProps - traversal properties of the current node\n */\n private async finalizeTile(\n conversionResults: TraversalConversionProps[],\n currentTraversalProps: TraversalConversionProps\n ): Promise<void> {\n for (const result of conversionResults) {\n for (const node of result.parentNodes) {\n await node.addNeighbors();\n }\n }\n for (const node of currentTraversalProps.parentNodes) {\n await node.save();\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param parentNode - 3DNodeIndexDocument of parent node\n * @param sourceTile - source 3DTile data\n * @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param level - tree level\n */\n private async _createNode(\n parentNode: NodeIndexDocument,\n sourceTile: Tiles3DTileJSONPostprocessed,\n transformationMatrix: Matrix4\n ): Promise<NodeIndexDocument[]> {\n this._checkAddRefinementTypeForTile(sourceTile);\n\n await this._updateTilesetOptions();\n\n let tileContent: Tiles3DTileContent | null = null;\n try {\n tileContent = await loadTile3DContent(this.sourceTileset, sourceTile, this.loadOptions);\n } catch (error) {\n console.log(`[warning]: Failed to load ${sourceTile.contentUrl}`);\n }\n const sourceBoundingVolume = createBoundingVolume(\n sourceTile.boundingVolume,\n transformationMatrix,\n null\n );\n let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel!);\n\n const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);\n this.createAttributeStorageInfo(tileContent, propertyTable);\n\n const resourcesData = await this._convertResources(\n sourceTile,\n transformationMatrix,\n sourceBoundingVolume,\n tileContent,\n parentNode.inPageId,\n propertyTable\n );\n\n const nodes: NodeIndexDocument[] = [];\n const nodeIds: number[] = [];\n const nodesInPage: NodeInPage[] = [];\n const emptyResources = {\n geometry: null,\n compressedGeometry: null,\n texture: null,\n hasUvRegions: false,\n sharedResources: null,\n meshMaterial: null,\n vertexCount: null,\n attributes: null,\n featureCount: null,\n boundingVolumes: null\n };\n\n for (const resources of resourcesData || [emptyResources]) {\n this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);\n\n if (this.generateBoundingVolumes && resources.boundingVolumes) {\n boundingVolumes = resources.boundingVolumes;\n }\n\n const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);\n const maxScreenThresholdSQ = lodSelection.find(\n (val) => val.metricType === 'maxScreenThresholdSQ'\n ) || {maxError: 0};\n\n const nodeInPage = await this._updateNodeInNodePages(\n maxScreenThresholdSQ,\n boundingVolumes,\n sourceTile,\n parentNode.inPageId,\n resources\n );\n\n const nodeData = await NodeIndexDocument.createNodeIndexDocument(\n parentNode,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);\n nodes.push(node);\n\n if (nodeInPage.mesh) {\n await this._writeResources(resources, node.id);\n }\n\n if (this.validate) {\n this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);\n\n if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {\n console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings); //eslint-disable-line\n }\n }\n\n nodeIds.push(nodeInPage.index);\n nodesInPage.push(nodeInPage);\n }\n\n return nodes;\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param sourceTile - source tile (3DTile)\n * @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @param tileContent - content of the source tile\n * @param parentId - id of parent node in node pages\n * @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA, EXT_MESH_FEATURES or EXT_STRUCTURAL_METADATA\n * @returns - converted node resources\n */\n private async _convertResources(\n sourceTile: Tiles3DTileJSONPostprocessed,\n transformationMatrix: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere,\n tileContent: Tiles3DTileContent | null,\n parentId: number,\n propertyTable: FeatureTableJson | null\n ): Promise<I3SConvertedResources[] | null> {\n if (!this.isContentSupported(sourceTile) || !tileContent) {\n return null;\n }\n const draftObb = {\n center: [],\n halfSize: [],\n quaternion: []\n };\n const resourcesData = await convertB3dmToI3sGeometry(\n tileContent,\n transformationMatrix,\n boundingVolume,\n async () => (await this.nodePages.push({index: 0, obb: draftObb}, parentId)).index,\n propertyTable,\n this.featuresHashArray,\n this.attributeMetadataInfo.attributeStorageInfo,\n this.options.draco,\n this.generateBoundingVolumes,\n this.options.mergeMaterials,\n this.geoidHeightModel!,\n this.loadOptions.modules as Record<string, string>,\n this.options.metadataClass\n );\n return resourcesData;\n }\n\n /**\n * Update node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)\n * in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)\n * @param maxScreenThresholdSQ - Level of Details (LOD) metric\n * @param boundingVolumes - Bounding volumes\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param resources - the node resources data\n * @param resources.meshMaterial - PBR-like material object\n * @param resources.texture - texture image\n * @param resources.vertexCount - number of vertices in geometry\n * @param resources.featureCount - number of features\n * @param resources.geometry - Uint8Array with geometry attributes\n * @return the node object in node pages\n */\n private async _updateNodeInNodePages(\n maxScreenThresholdSQ: MaxScreenThresholdSQ,\n boundingVolumes: BoundingVolumes,\n sourceTile: Tiles3DTileJSONPostprocessed,\n parentId: number,\n resources: I3SConvertedResources\n ): Promise<NodeInPage> {\n const {meshMaterial, texture, vertexCount, featureCount, geometry, hasUvRegions} = resources;\n const nodeInPage: NodeInPage = {\n index: 0,\n lodThreshold: maxScreenThresholdSQ.maxError,\n obb: boundingVolumes.obb,\n children: []\n };\n if (geometry && this.isContentSupported(sourceTile)) {\n nodeInPage.mesh = {\n geometry: {\n definition: this.findOrCreateGeometryDefinition(Boolean(texture), hasUvRegions),\n resource: 0\n },\n attribute: {\n resource: 0\n },\n material: {\n definition: 0\n }\n };\n }\n\n let nodeId = resources.nodeId;\n let node: NodeInPage;\n if (!nodeId) {\n node = await this.nodePages.push(nodeInPage, parentId);\n } else {\n node = await this.nodePages.getNodeById(nodeId);\n }\n\n if (!nodeInPage.mesh) {\n console.log(`[warning]: node ${node.index} is created with empty content`);\n }\n\n NodePages.updateAll(node, nodeInPage);\n if (meshMaterial) {\n NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));\n }\n if (texture) {\n const texelCountHint = texture.image.height * texture.image.width;\n NodePages.updateTexelCountHintByNodeId(node, texelCountHint);\n }\n if (vertexCount) {\n this.vertexCounter += vertexCount;\n NodePages.updateVertexCountByNodeId(node, vertexCount);\n }\n NodePages.updateNodeAttributeByNodeId(node);\n if (featureCount) {\n NodePages.updateFeatureCountByNodeId(node, featureCount);\n }\n\n this.nodePages.saveNode(node);\n\n return node;\n }\n\n /**\n * Write node resources in files\n * @param resources - source tile (3DTile)\n * @param resources.geometry - Uint8Array with geometry attributes\n * @param resources.compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param resources.texture - texture image\n * @param resources.sharedResources - shared resource data object\n * @param resources.attributes - feature attributes\n * @return {Promise<void>}\n */\n private async _writeResources(resources: I3SConvertedResources, nodePath: string): Promise<void> {\n const {\n geometry: geometryBuffer,\n compressedGeometry,\n texture,\n sharedResources,\n attributes\n } = resources;\n const childPath = join(this.layers0Path, 'nodes', nodePath);\n const slpkChildPath = join('nodes', nodePath);\n\n await this._writeGeometries(geometryBuffer!, compressedGeometry!, childPath, slpkChildPath);\n await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);\n await this._writeTexture(texture, childPath, slpkChildPath);\n await this._writeAttributes(attributes, childPath, slpkChildPath);\n }\n\n /**\n * Write non-compressed and compressed geometries in files\n * @param geometryBuffer - Uint8Array with geometry attributes\n * @param compressedGeometry - Uint8Array with compressed (draco) geometry\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n */\n private async _writeGeometries(\n geometryBuffer: ArrayBuffer,\n compressedGeometry: Promise<ArrayBuffer>,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkGeometryPath = join(childPath, 'geometries');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,\n writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')\n });\n } else {\n const geometryPath = join(childPath, 'geometries/0/');\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')\n });\n }\n\n if (this.options.draco) {\n if (this.options.slpk) {\n const slpkCompressedGeometryPath = join(childPath, 'geometries');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,\n writePromise: () =>\n writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')\n });\n } else {\n const compressedGeometryPath = join(childPath, 'geometries/1/');\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')\n });\n }\n }\n }\n\n /**\n * Write shared resources in a file\n * @param sharedResources - shared resource data object\n * @param childPath - a child path to write resources\n * @param slpkChildPath - resource path inside *slpk file\n * @param nodePath - a node path\n */\n private async _writeShared(\n sharedResources: SharedResourcesArrays | null,\n childPath: string,\n slpkChildPath: string,\n nodePath: string\n ): Promise<void> {\n if (!sharedResources) {\n return;\n }\n sharedResources.nodePath = nodePath;\n const sharedData = transform(sharedResources, sharedResourcesTemplate());\n const sharedDataStr = JSON.stringify(sharedData);\n if (this.options.slpk) {\n const slpkSharedPath = join(childPath, 'shared');\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,\n writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')\n });\n } else {\n const sharedPath = join(childPath, 'shared/');\n await this.writeQueue.enqueue({writePromise: () => writeFile(sharedPath, sharedDataStr)});\n }\n }\n\n /**\n * Generates textures based on texture mime type and fill in textureSetDefinitions data.\n * @param texture - the texture image\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeTexture(\n texture: GLTFImagePostprocessed,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (texture) {\n const format = this._getFormatByMimeType(texture?.mimeType);\n const formats: TextureSetDefinitionFormats = [];\n const textureData = texture.bufferView!.data;\n\n switch (format) {\n case 'jpg':\n case 'png': {\n formats.push({name: '0', format});\n await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '1', format: 'ktx2'});\n // For Node.js texture.image.data is type of Buffer\n const copyArrayBuffer = texture.image.data.subarray();\n const arrayToEncode = new Uint8Array(copyArrayBuffer);\n const ktx2TextureData = encode(\n {...texture.image, data: arrayToEncode},\n KTX2BasisWriterWorker,\n {\n ...KTX2BasisWriterWorker.options,\n ['ktx2-basis-writer']: {\n // We need to load local fs workers because nodejs can't load workers from the Internet\n workerUrl: './modules/textures/dist/ktx2-basis-writer-worker-node.js'\n },\n reuseWorkers: true,\n _nodeWorkers: true,\n useLocalLibraries: true\n }\n );\n\n await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);\n }\n\n break;\n }\n\n case 'ktx2': {\n formats.push({name: '1', format});\n await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);\n\n if (this.generateTextures) {\n formats.push({name: '0', format: 'jpg'});\n const decodedFromKTX2TextureData = encode(texture.image!.data[0], ImageWriter);\n await this.writeTextureFile(\n decodedFromKTX2TextureData,\n '0',\n 'jpg',\n childPath,\n slpkChildPath\n );\n }\n }\n }\n\n if (!this.layers0!.textureSetDefinitions!.length) {\n this.layers0!.textureSetDefinitions!.push({formats});\n this.layers0!.textureSetDefinitions!.push({formats, atlas: true});\n }\n }\n }\n\n /**\n * Write the texture image in a file\n * @param textureData\n * @param name\n * @param format\n * @param childPath\n * @param slpkChildPath\n */\n private async writeTextureFile(\n textureData: Uint8Array | Promise<ArrayBuffer>,\n name: string,\n format: 'jpg' | 'png' | 'ktx2',\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkTexturePath = join(childPath, 'textures');\n const compress = false;\n\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/textures/${name}.${format}`,\n writePromise: () =>\n writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)\n });\n } else {\n const texturePath = join(childPath, `textures/${name}/`);\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(texturePath, textureData, `index.${format}`)\n });\n }\n }\n\n /**\n * Write feature attributes in files\n * @param attributes - feature attributes\n * @param childPath - a child path to write resources\n * @param slpkChildPath - the resource path inside *slpk file\n */\n private async _writeAttributes(\n attributes: ArrayBuffer[] | null = [],\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (attributes?.length && this.attributeMetadataInfo.attributeStorageInfo.length) {\n const minimumLength =\n attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length\n ? attributes.length\n : this.attributeMetadataInfo.attributeStorageInfo.length;\n\n for (let index = 0; index < minimumLength; index++) {\n const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;\n const fileBuffer = new Uint8Array(attributes[index]);\n\n if (this.options.slpk) {\n const slpkAttributesPath = join(childPath, 'attributes', folderName);\n await this.writeQueue.enqueue({\n archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,\n writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')\n });\n } else {\n const attributesPath = join(childPath, `attributes/${folderName}/0`);\n await this.writeQueue.enqueue({\n writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')\n });\n }\n }\n }\n }\n\n /**\n * Return file format by its MIME type\n * @param mimeType - feature attributes\n */\n private _getFormatByMimeType(mimeType: string | undefined): 'jpg' | 'png' | 'ktx2' {\n switch (mimeType) {\n case 'image/jpeg':\n return 'jpg';\n case 'image/png':\n return 'png';\n case 'image/ktx2':\n return 'ktx2';\n default:\n return 'jpg';\n }\n }\n\n /**\n * Find or create material in materialDefinitions array\n * @param material - end-to-end index of the node\n * @return material id\n */\n private _findOrCreateMaterial(material: I3SMaterialDefinition): number {\n const hash = md5(JSON.stringify(material));\n if (this.materialMap.has(hash)) {\n return this.materialMap.get(hash) || 0;\n }\n const newMaterialId = this.materialDefinitions.push(material) - 1;\n this.materialMap.set(hash, newMaterialId);\n return newMaterialId;\n }\n\n /**\n * Get unique geometry configuration index\n * In the end of conversion configurations will be transformed to geometryDefinitions array\n * @param hasTexture\n * @param hasUvRegions\n * @returns\n */\n private findOrCreateGeometryDefinition(hasTexture: boolean, hasUvRegions: boolean): number {\n const geometryConfig = {hasTexture, hasUvRegions};\n const hash = md5(JSON.stringify(geometryConfig));\n if (this.geometryMap.has(hash)) {\n return this.geometryMap.get(hash) || 0;\n }\n const newGeometryId = this.geometryConfigs.push(geometryConfig) - 1;\n this.geometryMap.set(hash, newGeometryId);\n return newGeometryId;\n }\n\n /**\n * Creates attribute storage info based on either extension schema or property table.\n * @param tileContent - content of the source tile\n * @param propertyTable - feature properties from EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA\n */\n private createAttributeStorageInfo(\n tileContent: Tiles3DTileContent | null,\n propertyTable: FeatureTableJson | null\n ): void {\n /*\n In case the tileset doesn't have either EXT_structural_metadata or EXT_feature_metadata\n that can be a source of attribute information so metadataClass is not specified\n we will collect attribute information for node attributes from the property table\n taken from each tile.\n */\n let attributeTypesMap: Record<string, Attribute> | null = null;\n if (this.options.metadataClass) {\n if (!this.attributeMetadataInfo.attributeStorageInfo.length && tileContent?.gltf) {\n attributeTypesMap = getAttributeTypesMapFromSchema(\n tileContent.gltf,\n this.options.metadataClass\n );\n }\n } else if (propertyTable) {\n attributeTypesMap = getAttributeTypesMapFromPropertyTable(propertyTable);\n }\n\n if (attributeTypesMap) {\n // Add new storage attributes, fields and create popupInfo\n this.attributeMetadataInfo.addMetadataInfo(attributeTypesMap);\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const {tilesCount, tilesWithAddRefineCount} = this.refinementCounter;\n const addRefinementPercentage = tilesWithAddRefineCount\n ? (tilesWithAddRefineCount / tilesCount) * 100\n : 0;\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n console.log(`Finishing conversion of ${_3D_TILES}`); // eslint-disable-line no-undef, no-console\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line no-undef, no-console\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line no-undef, no-console\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line no-undef, no-console\n console.log(`Percentage of tiles with \"ADD\" refinement type:`, addRefinementPercentage, '%'); // eslint-disable-line no-undef, no-console\n console.log(`------------------------------------------------`); // eslint-disable-line no-undef, no-console\n }\n\n /**\n * Fetch preload options for ION tileset\n */\n private async _fetchPreloadOptions(): Promise<any> {\n if (!this.Loader.preload) {\n return {};\n }\n const options = {\n 'cesium-ion': {accessToken: this.options.token || ION_DEFAULT_TOKEN}\n };\n const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);\n this.refreshTokenTime = process.hrtime();\n return {...options, ...preloadOptions};\n }\n\n /**\n * Update options of source tileset\n */\n private async _updateTilesetOptions(): Promise<void> {\n const diff = process.hrtime(this.refreshTokenTime);\n if (diff[0] < REFRESH_TOKEN_TIMEOUT) {\n return;\n }\n this.refreshTokenTime = process.hrtime();\n\n const preloadOptions = await this._fetchPreloadOptions();\n if (preloadOptions.headers) {\n this.loadOptions.fetch = {\n ...this.loadOptions.fetch,\n headers: preloadOptions.headers\n };\n console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console\n }\n }\n\n /** Do calculations of all tiles and tiles with \"ADD\" type of refinement.\n * @param tile\n */\n private _checkAddRefinementTypeForTile(tile: Tiles3DTileJSONPostprocessed): void {\n const ADD_TILE_REFINEMENT = 1;\n\n if (tile.refine === ADD_TILE_REFINEMENT) {\n this.refinementCounter.tilesWithAddRefineCount += 1;\n console.warn('This tile uses \"ADD\" type of refinement'); // eslint-disable-line\n }\n\n this.refinementCounter.tilesCount += 1;\n }\n\n /**\n * Check if the tile's content format is supported by the converter\n * @param sourceTile\n * @returns\n */\n private isContentSupported(sourceTile: Tiles3DTileJSONPostprocessed): boolean {\n return ['b3dm', 'glTF', 'scenegraph'].includes(sourceTile.type || '');\n }\n}\n"],"mappings":";SAGQA,qBAAqB;AAiB7B,SAAQC,IAAI,EAAEC,MAAM,EAAEC,SAAS,QAAO,kBAAkB;AACxD,SAA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