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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/constants.d.ts +2 -0
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +3 -1
  5. package/dist/converter-cli.js +10 -2
  6. package/dist/converter.min.js +172 -103
  7. package/dist/deps-installer/deps-installer.d.ts +3 -2
  8. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  9. package/dist/deps-installer/deps-installer.js +36 -10
  10. package/dist/dist.min.js +226 -151
  11. package/dist/es5/constants.js +5 -1
  12. package/dist/es5/constants.js.map +1 -1
  13. package/dist/es5/converter-cli.js +7 -2
  14. package/dist/es5/converter-cli.js.map +1 -1
  15. package/dist/es5/deps-installer/deps-installer.js +112 -38
  16. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
  18. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
  20. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/geometry-converter.js +78 -67
  22. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
  24. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  25. package/dist/es5/i3s-converter/i3s-converter.js +86 -99
  26. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  27. package/dist/es5/i3s-converter/types.js +11 -11
  28. package/dist/es5/i3s-converter/types.js.map +1 -1
  29. package/dist/es5/i3s-server/controllers/slpk-controller.js +1 -1
  30. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  31. package/dist/es5/index.js +3 -3
  32. package/dist/es5/index.js.map +1 -1
  33. package/dist/es5/pgm-loader.js +1 -1
  34. package/dist/es5/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +9 -9
  35. package/dist/es5/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  36. package/dist/es5/slpk-extractor/slpk-extractor.js +5 -5
  37. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  38. package/dist/esm/constants.js +2 -0
  39. package/dist/esm/constants.js.map +1 -1
  40. package/dist/esm/converter-cli.js +7 -2
  41. package/dist/esm/converter-cli.js.map +1 -1
  42. package/dist/esm/deps-installer/deps-installer.js +37 -11
  43. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  44. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
  45. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  46. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
  47. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  48. package/dist/esm/i3s-converter/helpers/geometry-converter.js +37 -25
  49. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  50. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
  51. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  52. package/dist/esm/i3s-converter/i3s-converter.js +49 -36
  53. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  54. package/dist/esm/i3s-converter/types.js +9 -9
  55. package/dist/esm/i3s-converter/types.js.map +1 -1
  56. package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
  57. package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
  58. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  59. package/dist/esm/index.js +1 -1
  60. package/dist/esm/index.js.map +1 -1
  61. package/dist/esm/pgm-loader.js +1 -1
  62. package/dist/esm/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +3 -3
  63. package/dist/esm/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  64. package/dist/esm/slpk-extractor/slpk-extractor.js +3 -3
  65. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  66. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
  67. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  68. package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
  69. package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
  70. package/dist/i3s-converter/helpers/geometry-converter.d.ts +7 -6
  71. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  72. package/dist/i3s-converter/helpers/geometry-converter.js +59 -47
  73. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
  74. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  75. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
  76. package/dist/i3s-converter/i3s-converter.d.ts +2 -1
  77. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  78. package/dist/i3s-converter/i3s-converter.js +49 -31
  79. package/dist/i3s-converter/types.d.ts +4 -2
  80. package/dist/i3s-converter/types.d.ts.map +1 -1
  81. package/dist/i3s-converter/types.js +11 -11
  82. package/dist/i3s-server/controllers/slpk-controller.js +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +3 -3
  86. package/dist/slpk-extractor/helpers/{file-handle-provider.d.ts → file-handle-file.d.ts} +5 -5
  87. package/dist/slpk-extractor/helpers/file-handle-file.d.ts.map +1 -0
  88. package/dist/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +5 -5
  89. package/dist/slpk-extractor/slpk-extractor.js +5 -5
  90. package/dist/slpk-extractor.min.js +32 -32
  91. package/package.json +15 -14
  92. package/src/constants.ts +3 -0
  93. package/src/converter-cli.ts +9 -2
  94. package/src/deps-installer/deps-installer.ts +55 -10
  95. package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
  96. package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
  97. package/src/i3s-converter/helpers/geometry-converter.ts +84 -48
  98. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
  99. package/src/i3s-converter/i3s-converter.ts +65 -39
  100. package/src/i3s-converter/types.ts +4 -2
  101. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  102. package/src/index.ts +1 -1
  103. package/src/slpk-extractor/helpers/{file-handle-provider.ts → file-handle-file.ts} +5 -5
  104. package/src/slpk-extractor/slpk-extractor.ts +3 -3
  105. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  106. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  107. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  var _process$env;
3
- import { load, encode, fetchFile, getLoaderOptions, isBrowser } from '@loaders.gl/core';
3
+ import { load, encode, isBrowser } from '@loaders.gl/core';
4
4
  import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
5
5
  import { join } from 'path';
6
6
  import { v4 as uuidv4 } from 'uuid';
@@ -22,9 +22,8 @@ import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/sh
22
22
  import { validateNodeBoundingVolumes } from './helpers/node-debug';
23
23
  import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
24
24
  import { ImageWriter } from '@loaders.gl/images';
25
- import { GltfPrimitiveModeString } from './types';
26
- import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
27
- import { DracoWriterWorker } from '@loaders.gl/draco';
25
+ import { GLTFPrimitiveModeString } from './types';
26
+ import { WorkerFarm } from '@loaders.gl/worker-utils';
28
27
  import WriteQueue from '../lib/utils/write-queue';
29
28
  import { BROWSER_ERROR_MESSAGE } from '../constants';
30
29
  import { createdStorageAttribute, createFieldAttribute, createPopupInfo, getAttributeType, getFieldAttributeType } from './helpers/feature-attributes';
@@ -34,7 +33,7 @@ import { Matrix4 } from '@math.gl/core';
34
33
  import { createBoundingVolume } from '@loaders.gl/tiles';
35
34
  import { traverseDatasetWith } from './helpers/tileset-traversal';
36
35
  import { analyzeTileContent, mergePreprocessData } from './helpers/preprocess-3d-tiles';
37
- const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
36
+ const ION_DEFAULT_TOKEN = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken;
38
37
  const HARDCODED_NODES_PER_PAGE = 64;
39
38
  const _3D_TILES = '3DTILES';
40
39
  const _3D_OBJECT_LAYER_TYPE = '3DObject';
@@ -61,6 +60,7 @@ export default class I3SConverter {
61
60
  _defineProperty(this, "loadOptions", {
62
61
  _nodeWorkers: true,
63
62
  reuseWorkers: true,
63
+ useLocalLibraries: true,
64
64
  basis: {
65
65
  format: 'rgba32',
66
66
  workerUrl: './modules/textures/dist/basis-worker-node.js'
@@ -68,7 +68,8 @@ export default class I3SConverter {
68
68
  draco: {
69
69
  workerUrl: './modules/draco/dist/draco-worker-node.js'
70
70
  },
71
- fetch: {}
71
+ fetch: {},
72
+ modules: {}
72
73
  });
73
74
  _defineProperty(this, "geoidHeightModel", null);
74
75
  _defineProperty(this, "Loader", Tiles3DLoader);
@@ -79,7 +80,8 @@ export default class I3SConverter {
79
80
  _defineProperty(this, "writeQueue", new WriteQueue());
80
81
  _defineProperty(this, "compressList", null);
81
82
  _defineProperty(this, "preprocessData", {
82
- meshTopologyTypes: new Set()
83
+ meshTopologyTypes: new Set(),
84
+ metadataClasses: new Set()
83
85
  });
84
86
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
85
87
  this.options = {};
@@ -121,7 +123,9 @@ export default class I3SConverter {
121
123
  generateTextures,
122
124
  generateBoundingVolumes,
123
125
  instantNodeWriting = false,
124
- mergeMaterials = true
126
+ mergeMaterials = true,
127
+ inquirer,
128
+ metadataClass
125
129
  } = options;
126
130
  this.options = {
127
131
  maxDepth,
@@ -132,7 +136,9 @@ export default class I3SConverter {
132
136
  token,
133
137
  inputUrl,
134
138
  instantNodeWriting,
135
- mergeMaterials
139
+ mergeMaterials,
140
+ inquirer,
141
+ metadataClass
136
142
  };
137
143
  this.compressList = this.options.instantNodeWriting && [] || null;
138
144
  this.validate = Boolean(validate);
@@ -147,7 +153,6 @@ export default class I3SConverter {
147
153
  if (slpk) {
148
154
  this.nodePages.useWriteFunction(writeFileForSlpk);
149
155
  }
150
- await this.loadWorkers();
151
156
  try {
152
157
  const preloadOptions = await this._fetchPreloadOptions();
153
158
  let tilesetUrl = inputUrl;
@@ -183,17 +188,42 @@ export default class I3SConverter {
183
188
  const sourceRootTile = this.sourceTileset.root;
184
189
  await traverseDatasetWith(sourceRootTile, null, this.analyzeTile.bind(this), undefined, this.options.maxDepth);
185
190
  const {
186
- meshTopologyTypes
191
+ meshTopologyTypes,
192
+ metadataClasses
187
193
  } = this.preprocessData;
188
194
  console.log("------------------------------------------------");
189
195
  console.log("Preprocess results:");
190
196
  console.log("glTF mesh topology types: ".concat(Array.from(meshTopologyTypes).join(', ')));
197
+ if (metadataClasses.size) {
198
+ console.log("Feature metadata classes have been found: ".concat(Array.from(metadataClasses).join(', ')));
199
+ } else {
200
+ console.log('Feature metadata classes have not been found');
201
+ }
191
202
  console.log("------------------------------------------------");
192
- if (!meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GltfPrimitiveModeString.TRIANGLE_STRIP)) {
203
+ if (!meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLES) && !meshTopologyTypes.has(GLTFPrimitiveModeString.TRIANGLE_STRIP)) {
193
204
  console.log('The tileset is of unsupported mesh topology types. The conversion will be interrupted.');
194
205
  console.log("------------------------------------------------");
195
206
  return false;
196
207
  }
208
+ if (metadataClasses.size > 1) {
209
+ var _this$options$metadat;
210
+ if ((_this$options$metadat = this.options.metadataClass) !== null && _this$options$metadat !== void 0 && _this$options$metadat.length) {
211
+ console.log("".concat(this.options.metadataClass, " has been selected"));
212
+ } else if (this.options.inquirer) {
213
+ const result = await this.options.inquirer.prompt([{
214
+ name: 'metadataClass',
215
+ type: 'list',
216
+ message: 'Select feature metadata data class to convert...',
217
+ choices: Array.from(metadataClasses)
218
+ }]);
219
+ this.options.metadataClass = result.metadataClass;
220
+ console.log("".concat(result.metadataClass, " has been selected"));
221
+ } else {
222
+ console.log("A feature metadata class has not been selected. Start the converter with option \"--metadata-class\". For example, \"npx tile-converter ... --metadata-class ".concat(Array.from(metadataClasses)[0], "\""));
223
+ console.log("------------------------------------------------");
224
+ return false;
225
+ }
226
+ }
197
227
  return true;
198
228
  }
199
229
  async analyzeTile(sourceTile, traversalProps) {
@@ -366,7 +396,7 @@ export default class I3SConverter {
366
396
  }
367
397
  const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
368
398
  let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
369
- const propertyTable = getPropertyTable(tileContent);
399
+ const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
370
400
  if (propertyTable && !((_this$layers = this.layers0) !== null && _this$layers !== void 0 && (_this$layers$attribut = _this$layers.attributeStorageInfo) !== null && _this$layers$attribut !== void 0 && _this$layers$attribut.length)) {
371
401
  this._convertPropertyTableToNodeAttributes(propertyTable);
372
402
  }
@@ -426,7 +456,7 @@ export default class I3SConverter {
426
456
  const resourcesData = await convertB3dmToI3sGeometry(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({
427
457
  index: 0,
428
458
  obb: draftObb
429
- }, parentId)).index, propertyTable, this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.workerSource);
459
+ }, parentId)).index, propertyTable, this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.loadOptions.modules, this.options.metadataClass);
430
460
  return resourcesData;
431
461
  }
432
462
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
@@ -576,9 +606,12 @@ export default class I3SConverter {
576
606
  data: arrayToEncode
577
607
  }, KTX2BasisWriterWorker, {
578
608
  ...KTX2BasisWriterWorker.options,
579
- source: this.workerSource.ktx2,
609
+ ['ktx2-basis-writer']: {
610
+ workerUrl: './modules/textures/dist/ktx2-basis-writer-worker-node.js'
611
+ },
580
612
  reuseWorkers: true,
581
- _nodeWorkers: true
613
+ _nodeWorkers: true,
614
+ useLocalLibraries: true
582
615
  });
583
616
  await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
584
617
  }
@@ -764,25 +797,5 @@ export default class I3SConverter {
764
797
  isContentSupported(sourceTile) {
765
798
  return ['b3dm', 'glTF', 'scenegraph'].includes(sourceTile.type || '');
766
799
  }
767
- async loadWorkers() {
768
- console.log("Loading workers source...");
769
- if (this.options.draco) {
770
- const url = getWorkerURL(DracoWriterWorker, {
771
- ...getLoaderOptions()
772
- });
773
- const sourceResponse = await fetchFile(url);
774
- const source = await sourceResponse.text();
775
- this.workerSource.draco = source;
776
- }
777
- if (this.generateTextures) {
778
- const url = getWorkerURL(KTX2BasisWriterWorker, {
779
- ...getLoaderOptions()
780
- });
781
- const sourceResponse = await fetchFile(url);
782
- const source = await sourceResponse.text();
783
- this.workerSource.ktx2 = source;
784
- }
785
- console.log("Loading workers source completed!");
786
- }
787
800
  }
788
801
  //# sourceMappingURL=i3s-converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.js","names":["load","encode","fetchFile","getLoaderOptions","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","getWorkerURL","WorkerFarm","DracoWriterWorker","WriteQueue","BROWSER_ERROR_MESSAGE","createdStorageAttribute","createFieldAttribute","createPopupInfo","getAttributeType","getFieldAttributeType","NodeIndexDocument","loadNestedTileset","loadTile3DContent","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","_defineProperty","_nodeWorkers","reuseWorkers","basis","format","workerUrl","draco","fetch","meshTopologyTypes","Set","nodePages","options","layers0Path","materialMap","Map","materialDefinitions","geometryMap","geometryConfigs","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","layersHasTexture","compressList","convert","console","log","conversionStartTime","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","sevenZipExe","maxDepth","token","instantNodeWriting","mergeMaterials","Boolean","Loader","indexOf","writeQueue","startListening","geoidHeightModel","useWriteFunction","loadWorkers","preloadOptions","_fetchPreloadOptions","tilesetUrl","url","headers","loadOptions","sourceTileset","preprocessResult","preprocessConversion","_createAndSaveTileset","_finishConversion","error","finalize","workerFarm","getWorkerFarm","destroy","sourceRootTile","root","analyzeTile","bind","undefined","preprocessData","concat","Array","from","has","TRIANGLES","TRIANGLE_STRIP","sourceTile","traversalProps","type","id","tileContent","loadGLTF","contentUrl","tilePreprocessData","_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","name","href","nodesPerPage","compressGeometry","enqueue","archiveKey","writePromise","JSON","stringify","slpkTilesetPath","slpkFileName","transformationMatrix","clone","multiplyRight","parentNode","childNodes","_createNode","addChildren","newTraversalProps","conversionResults","currentTraversalProps","result","node","addNeighbors","_this$layers","_this$layers$attribut","_checkAddRefinementTypeForTile","_updateTilesetOptions","propertyTable","attributeStorageInfo","length","_convertPropertyTableToNodeAttributes","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","boundingVolumeWarnings","warn","parentId","_this$layers2","isContentSupported","draftObb","center","halfSize","quaternion","workerSource","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","source","ktx2","decodedFromKTX2TextureData","textureSetDefinitions","atlas","slpkTexturePath","compress","texturePath","_this$layers3","_this$layers3$attribu","arguments","folderName","key","fileBuffer","slpkAttributesPath","attributesPath","hash","get","newMaterialId","set","hasTexture","newGeometryId","attributeIndex","propertyTableWithObjectId","OBJECTID","firstAttribute","attributeType","storageAttribute","fieldAttributeType","fieldAttribute","popupInfo","fields","layerType","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","refreshTokenTime","tile","ADD_TILE_REFINEMENT","refine","includes","sourceResponse","text"],"sources":["../../../src/i3s-converter/i3s-converter.ts"],"sourcesContent":["// loaders.gl, MIT license\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} from '@loaders.gl/i3s';\nimport {load, encode, fetchFile, getLoaderOptions, 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 {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\nimport {DracoWriterWorker} from '@loaders.gl/draco';\nimport WriteQueue from '../lib/utils/write-queue';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {\n createdStorageAttribute,\n createFieldAttribute,\n createPopupInfo,\n getAttributeType,\n getFieldAttributeType\n} from './helpers/feature-attributes';\nimport {NodeIndexDocument} from './helpers/node-index-document';\nimport {loadNestedTileset, loadTile3DContent} 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 =\n process.env?.IonToken || // eslint-disable-line\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line\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 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 };\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 };\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 }): 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 } = options;\n this.options = {\n maxDepth,\n slpk,\n sevenZipExe,\n egmFilePath,\n draco,\n token,\n inputUrl,\n instantNodeWriting,\n mergeMaterials\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 await this.loadWorkers();\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 load(tilesetUrl, this.Loader, this.loadOptions);\n\n const preprocessResult = await this.preprocessConversion();\n\n if (preprocessResult) {\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\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} = this.preprocessData;\n console.log(`------------------------------------------------`);\n console.log(`Preprocess results:`);\n console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);\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 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 if (sourceTile.type === 'json') {\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 * 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 if (sourceTile.type === 'json' || sourceTile.type === 'empty') {\n if (sourceTile.type === 'json') {\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);\n\n if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {\n this._convertPropertyTableToNodeAttributes(propertyTable);\n }\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\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.workerSource\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 source: this.workerSource.ktx2,\n reuseWorkers: true,\n _nodeWorkers: 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 for (let index = 0; index < attributes.length; 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 * Do conversion of 3DTiles property table to I3s node attributes.\n * @param propertyTable - Table with layer meta data.\n */\n private _convertPropertyTableToNodeAttributes(propertyTable: FeatureTableJson): void {\n let attributeIndex = 0;\n const propertyTableWithObjectId = {\n OBJECTID: [0],\n ...propertyTable\n };\n\n for (const key in propertyTableWithObjectId) {\n const firstAttribute = propertyTableWithObjectId[key][0];\n const attributeType = getAttributeType(key, firstAttribute);\n\n const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = getFieldAttributeType(attributeType);\n const fieldAttribute = createFieldAttribute(key, fieldAttributeType);\n const popupInfo = createPopupInfo(propertyTableWithObjectId);\n\n this.layers0!.attributeStorageInfo!.push(storageAttribute);\n this.layers0!.fields!.push(fieldAttribute);\n this.layers0!.popupInfo = popupInfo;\n this.layers0!.layerType = _3D_OBJECT_LAYER_TYPE;\n\n attributeIndex += 1;\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 private async loadWorkers(): Promise<void> {\n console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console\n if (this.options.draco) {\n const url = getWorkerURL(DracoWriterWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(url);\n const source = await sourceResponse.text();\n this.workerSource.draco = source;\n }\n\n if (this.generateTextures) {\n const url = getWorkerURL(KTX2BasisWriterWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(url);\n const source = await sourceResponse.text();\n this.workerSource.ktx2 = source;\n }\n\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"mappings":";;AAgBA,SAAQA,IAAI,EAAEC,MAAM,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,SAAS,QAAO,kBAAkB;AACrF,SAAQC,eAAe,EAAEC,aAAa,QAAO,sBAAsB;AAEnE,SAAQC,IAAI,QAAO,MAAM;AACzB,SAAQC,EAAE,IAAIC,MAAM,QAAO,MAAM;AACjC,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,GAAG,MAAM,KAAK;AAErB,OAAOC,SAAS,MAAM,sBAAsB;AAC5C,SAAQC,SAAS,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,UAAU,QAAO,yBAAyB;AAC1F,SACEC,oBAAoB,EACpBC,wBAAwB,QAGnB,4BAA4B;AACnC,SAAQC,kBAAkB,EAAEC,aAAa,QAAO,+BAA+B;AAC/E,OAAOC,wBAAwB,IAAGC,gBAAgB,QAAO,8BAA8B;AACvF,SACEC,qBAAqB,EACrBC,oCAAoC,QAC/B,gCAAgC;AACvC,SAAQC,qBAAqB,QAAO,oCAAoC;AACxE,SAAQC,sCAAsC,QAAO,mCAAmC;AACxF,SAAQC,SAAS,Q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5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAACwN,QAAQ,CAACxN,UAAU,CAACE,IAAI,IAAI,EAAE,CAAC;EACvE;EAEA,MAAc/B,WAAWA,CAAA,EAAkB;IACzCrB,OAAO,CAACC,GAAG,4BAA4B,CAAC;IACxC,IAAI,IAAI,CAACpB,OAAO,CAACL,KAAK,EAAE;MACtB,MAAMiD,GAAG,GAAGpF,YAAY,CAACE,iBAAiB,EAAE;QAAC,GAAGtC,gBAAgB,CAAC;MAAC,CAAC,CAAC;MACpE,MAAM0W,cAAc,GAAG,MAAM3W,SAAS,CAACyH,GAAG,CAAC;MAC3C,MAAMqM,MAAM,GAAG,MAAM6C,cAAc,CAACC,IAAI,CAAC,CAAC;MAC1C,IAAI,CAAC7F,YAAY,CAACvM,KAAK,GAAGsP,MAAM;IAClC;IAEA,IAAI,IAAI,CAACnO,gBAAgB,EAAE;MACzB,MAAM8B,GAAG,GAAGpF,YAAY,CAACH,qBAAqB,EAAE;QAAC,GAAGjC,gBAAgB,CAAC;MAAC,CAAC,CAAC;MACxE,MAAM0W,cAAc,GAAG,MAAM3W,SAAS,CAACyH,GAAG,CAAC;MAC3C,MAAMqM,MAAM,GAAG,MAAM6C,cAAc,CAACC,IAAI,CAAC,CAAC;MAC1C,IAAI,CAAC7F,YAAY,CAACgD,IAAI,GAAGD,MAAM;IACjC;IAEA9N,OAAO,CAACC,GAAG,oCAAoC,CAAC;EAClD;AACF"}
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","createdStorageAttribute","createFieldAttribute","createPopupInfo","getAttributeType","getFieldAttributeType","NodeIndexDocument","loadNestedTileset","loadTile3DContent","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","_defineProperty","_nodeWorkers","reuseWorkers","useLocalLibraries","basis","format","workerUrl","draco","fetch","modules","meshTopologyTypes","Set","metadataClasses","nodePages","options","layers0Path","materialMap","Map","materialDefinitions","geometryMap","geometryConfigs","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","layersHasTexture","compressList","convert","console","log","conversionStartTime","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","sevenZipExe","maxDepth","token","instantNodeWriting","mergeMaterials","inquirer","metadataClass","Boolean","Loader","indexOf","writeQueue","startListening","geoidHeightModel","useWriteFunction","preloadOptions","_fetchPreloadOptions","tilesetUrl","url","headers","loadOptions","sourceTileset","preprocessResult","preprocessConversion","_createAndSaveTileset","_finishConversion","error","finalize","workerFarm","getWorkerFarm","destroy","sourceRootTile","root","analyzeTile","bind","undefined","preprocessData","concat","Array","from","size","has","TRIANGLES","TRIANGLE_STRIP","_this$options$metadat","length","result","prompt","name","type","message","choices","sourceTile","traversalProps","id","tileContent","loadGLTF","contentUrl","tilePreprocessData","_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","_this$layers","_this$layers$attribut","_checkAddRefinementTypeForTile","_updateTilesetOptions","propertyTable","attributeStorageInfo","_convertPropertyTableToNodeAttributes","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","boundingVolumeWarnings","warn","parentId","_this$layers2","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","_this$layers3","_this$layers3$attribu","arguments","folderName","key","fileBuffer","slpkAttributesPath","attributesPath","hash","get","newMaterialId","set","hasTexture","newGeometryId","attributeIndex","propertyTableWithObjectId","OBJECTID","firstAttribute","attributeType","storageAttribute","fieldAttributeType","fieldAttribute","popupInfo","fields","layerType","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","refreshTokenTime","tile","ADD_TILE_REFINEMENT","refine","includes"],"sources":["../../../src/i3s-converter/i3s-converter.ts"],"sourcesContent":["// loaders.gl, MIT license\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} 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 createdStorageAttribute,\n createFieldAttribute,\n createPopupInfo,\n getAttributeType,\n getFieldAttributeType\n} from './helpers/feature-attributes';\nimport {NodeIndexDocument} from './helpers/node-index-document';\nimport {loadNestedTileset, loadTile3DContent} 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 }): 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 } = 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 load(tilesetUrl, this.Loader, this.loadOptions);\n\n const preprocessResult = await this.preprocessConversion();\n\n if (preprocessResult) {\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\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 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\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 if (sourceTile.type === 'json') {\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 * 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 if (sourceTile.type === 'json' || sourceTile.type === 'empty') {\n if (sourceTile.type === 'json') {\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\n if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {\n this._convertPropertyTableToNodeAttributes(propertyTable);\n }\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\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 for (let index = 0; index < attributes.length; 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 * Do conversion of 3DTiles property table to I3s node attributes.\n * @param propertyTable - Table with layer meta data.\n */\n private _convertPropertyTableToNodeAttributes(propertyTable: FeatureTableJson): void {\n let attributeIndex = 0;\n const propertyTableWithObjectId = {\n OBJECTID: [0],\n ...propertyTable\n };\n\n for (const key in propertyTableWithObjectId) {\n const firstAttribute = propertyTableWithObjectId[key][0];\n const attributeType = getAttributeType(key, firstAttribute);\n\n const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = getFieldAttributeType(attributeType);\n const fieldAttribute = createFieldAttribute(key, fieldAttributeType);\n const popupInfo = createPopupInfo(propertyTableWithObjectId);\n\n this.layers0!.attributeStorageInfo!.push(storageAttribute);\n this.layers0!.fields!.push(fieldAttribute);\n this.layers0!.popupInfo = popupInfo;\n this.layers0!.layerType = _3D_OBJECT_LAYER_TYPE;\n\n attributeIndex += 1;\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', '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O,CAAC4F,MAAM,CAAC,IAAI,CAACsQ,gBAAgB,CAAC;IAClD,IAAIJ,IAAI,CAAC,CAAC,CAAC,GAAG1S,qBAAqB,EAAE;MACnC;IACF;IACA,IAAI,CAAC8S,gBAAgB,GAAGlW,OAAO,CAAC4F,MAAM,CAAC,CAAC;IAExC,MAAMoB,cAAc,GAAG,MAAM,IAAI,CAACC,oBAAoB,CAAC,CAAC;IACxD,IAAID,cAAc,CAACI,OAAO,EAAE;MAC1B,IAAI,CAACC,WAAW,CAACrD,KAAK,GAAG;QACvB,GAAG,IAAI,CAACqD,WAAW,CAACrD,KAAK;QACzBoD,OAAO,EAAEJ,cAAc,CAACI;MAC1B,CAAC;MACD3B,OAAO,CAACC,GAAG,CAAC,6CAA6C,CAAC;IAC5D;EACF;EAKQwI,8BAA8BA,CAACiI,IAAkC,EAAQ;IAC/E,MAAMC,mBAAmB,GAAG,CAAC;IAE7B,IAAID,IAAI,CAACE,MAAM,KAAKD,mBAAmB,EAAE;MACvC,IAAI,CAACpR,iBAAiB,CAACE,uBAAuB,IAAI,CAAC;MACnDO,OAAO,CAAC6K,IAAI,CAAC,yCAAyC,CAAC;IACzD;IAEA,IAAI,CAACtL,iBAAiB,CAACC,UAAU,IAAI,CAAC;EACxC;EAOQwL,kBAAkBA,CAACpH,UAAwC,EAAW;IAC5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAACiN,QAAQ,CAACjN,UAAU,CAACH,IAAI,IAAI,EAAE,CAAC;EACvE;AACF"}
@@ -1,11 +1,11 @@
1
- export let GltfPrimitiveModeString = function (GltfPrimitiveModeString) {
2
- GltfPrimitiveModeString["POINTS"] = "POINTS";
3
- GltfPrimitiveModeString["LINES"] = "LINES";
4
- GltfPrimitiveModeString["LINE_LOOP"] = "LINE_LOOP";
5
- GltfPrimitiveModeString["LINE_STRIP"] = "LINE_STRIP";
6
- GltfPrimitiveModeString["TRIANGLES"] = "TRIANGLES";
7
- GltfPrimitiveModeString["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
8
- GltfPrimitiveModeString["TRIANGLE_FAN"] = "TRIANGLE_FAN";
9
- return GltfPrimitiveModeString;
1
+ export let GLTFPrimitiveModeString = function (GLTFPrimitiveModeString) {
2
+ GLTFPrimitiveModeString["POINTS"] = "POINTS";
3
+ GLTFPrimitiveModeString["LINES"] = "LINES";
4
+ GLTFPrimitiveModeString["LINE_LOOP"] = "LINE_LOOP";
5
+ GLTFPrimitiveModeString["LINE_STRIP"] = "LINE_STRIP";
6
+ GLTFPrimitiveModeString["TRIANGLES"] = "TRIANGLES";
7
+ GLTFPrimitiveModeString["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
8
+ GLTFPrimitiveModeString["TRIANGLE_FAN"] = "TRIANGLE_FAN";
9
+ return GLTFPrimitiveModeString;
10
10
  }({});
11
11
  //# sourceMappingURL=types.js.map