@loaders.gl/tile-converter 3.2.6 → 3.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/3d-tiles-attributes-worker.js +3 -3
  2. package/dist/3d-tiles-attributes-worker.js.map +1 -1
  3. package/dist/converter-cli.js +30 -7
  4. package/dist/converter.min.js +1 -1
  5. package/dist/dist.min.js +1123 -624
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  8. package/dist/es5/converter-cli.js +42 -12
  9. package/dist/es5/converter-cli.js.map +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +146 -0
  13. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  14. package/dist/es5/i3s-converter/helpers/feature-attributes.js +60 -0
  15. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  16. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +39 -7
  17. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/geometry-converter.js +177 -59
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  20. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +15 -1
  21. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  22. package/dist/es5/i3s-converter/i3s-converter.js +50 -51
  23. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  24. package/dist/es5/lib/utils/write-queue.js +3 -5
  25. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  26. package/dist/es5/pgm-loader.js +1 -1
  27. package/dist/es5/pgm-loader.js.map +1 -1
  28. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  29. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  30. package/dist/esm/converter-cli.js +37 -7
  31. package/dist/esm/converter-cli.js.map +1 -1
  32. package/dist/esm/i3s-attributes-worker.js +1 -1
  33. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  34. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +128 -0
  35. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  36. package/dist/esm/i3s-converter/helpers/feature-attributes.js +34 -0
  37. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  38. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +23 -7
  39. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-converter.js +145 -38
  41. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +15 -1
  43. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  44. package/dist/esm/i3s-converter/i3s-converter.js +21 -27
  45. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  46. package/dist/esm/lib/utils/write-queue.js +3 -5
  47. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  48. package/dist/esm/pgm-loader.js +1 -1
  49. package/dist/esm/pgm-loader.js.map +1 -1
  50. package/dist/i3s-attributes-worker.js +3 -3
  51. package/dist/i3s-attributes-worker.js.map +3 -3
  52. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +12 -0
  53. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  54. package/dist/i3s-converter/helpers/batch-ids-extensions.js +138 -0
  55. package/dist/i3s-converter/helpers/feature-attributes.d.ts +24 -0
  56. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  57. package/dist/i3s-converter/helpers/feature-attributes.js +55 -0
  58. package/dist/i3s-converter/helpers/geometry-attributes.js +26 -7
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -2
  60. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  61. package/dist/i3s-converter/helpers/geometry-converter.js +140 -44
  62. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  63. package/dist/i3s-converter/helpers/gltf-attributes.js +13 -0
  64. package/dist/i3s-converter/i3s-converter.d.ts +7 -14
  65. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/i3s-converter.js +44 -35
  67. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  68. package/dist/lib/utils/write-queue.js +3 -4
  69. package/package.json +15 -15
  70. package/src/converter-cli.ts +33 -7
  71. package/src/i3s-converter/helpers/batch-ids-extensions.ts +199 -0
  72. package/src/i3s-converter/helpers/feature-attributes.ts +65 -0
  73. package/src/i3s-converter/helpers/geometry-attributes.ts +30 -7
  74. package/src/i3s-converter/helpers/geometry-converter.ts +187 -48
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +15 -0
  76. package/src/i3s-converter/i3s-converter.ts +38 -41
  77. package/src/lib/utils/write-queue.ts +7 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/i3s-converter/i3s-converter.ts"],"names":["ION_DEFAULT_TOKEN","env","IonToken","HARDCODED_NODES_PER_PAGE","_3D_TILES","_3D_OBJECT_LAYER_TYPE","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","REFRESH_TOKEN_TIMEOUT","CESIUM_DATASET_PREFIX","I3SConverter","Tiles3DLoader","WriteQueue","nodePages","NodePages","writeFile","options","layers0Path","materialMap","Map","materialDefinitions","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","layersHasTexture","isBrowser","console","log","BROWSER_ERROR_MESSAGE","conversionStartTime","process","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","sevenZipExe","maxDepth","token","Boolean","Loader","indexOf","CesiumIonLoader","writeQueue","startListening","PGMLoader","geoidHeightModel","useWriteFunction","writeFileForSlpk","loadWorkers","_fetchPreloadOptions","preloadOptions","tilesetOptions","loadOptions","basis","format","headers","fetch","Object","assign","sourceTilesetJson","sourceTileset","Tileset3D","_createAndSaveTileset","_finishConversion","workerFarm","WorkerFarm","getWorkerFarm","destroy","tilesetPath","_formLayers0","sourceRootTile","root","boundingVolumes","parentId","push","index","lodThreshold","obb","children","isCreateSlpk","root0","_formRootNodeIndexDocument","_convertNodesTree","store","defaultGeometrySchema","ordering","filter","attribute","_writeLayers0","_writeNodeIndexDocument","save","finalize","_createSlpk","fullExtent","boundingVolume","extent","xmin","ymin","xmax","ymax","layers0data","version","toUpperCase","id","name","href","nodesPerPage","compressGeometry","root0data","level","lodSelection","metricType","maxError","_loadTile","isContentSupported","_createNode","child","childPath","path","enqueue","archiveKey","writePromise","JSON","stringify","_addChildrenWithNeighborsAndWriteFile","parentNode","sourceTiles","unloadContent","nodePath","rootPath","slpkTilesetPath","slpkFileName","data","childNodes","_addChildren","_addNeighborsAndWriteFile","sourceTile","type","mbs","node","Number","length","neighbor","neighbors","warn","parentTile","_checkAddRefinementTypeForTile","_updateTilesetOptions","batchTable","content","batchTableJson","_convertAttributeStorageInfo","_convertResources","resourcesData","nodes","nodesInPage","emptyResources","geometry","compressedGeometry","texture","sharedResources","meshMaterial","vertexCount","attributes","featureCount","resources","maxScreenThresholdSQ","find","val","nodeInPage","_createNodeInNodePages","_createNodeIndexDocument","mesh","_writeResources","boundingVolumeWarnings","sourceTileContent","attributeStorageInfo","_convertBatchTableInfoToNodeAttributes","nodesCounter","workerSource","definition","resource","material","nodeId","updateMaterialByNodeId","_findOrCreateMaterial","texelCountHint","image","height","width","updateTexelCountHintByNodeId","updateVertexCountByNodeId","updateNodeAttributeByNodeId","updateFeatureCountByNodeId","nodeData","toString","geometryData","sharedResource","textureData","attributeData","folderName","key","geometryBuffer","slpkChildPath","_writeGeometries","_writeShared","_writeTexture","_writeAttributes","slpkGeometryPath","geometryPath","slpkCompressedGeometryPath","compressedGeometryPath","sharedData","sharedDataStr","slpkSharedPath","sharedPath","_getFormatByMimeType","mimeType","formats","bufferView","writeTextureFile","ktx2TextureData","KTX2BasisWriterWorker","source","ktx2","reuseWorkers","_nodeWorkers","decodedFromKTX2TextureData","ImageWriter","textureSetDefinitions","slpkTexturePath","compress","texturePath","fileBuffer","Uint8Array","slpkAttributesPath","attributesPath","hash","has","get","newMaterialId","set","attributeIndex","attributeType","storageAttribute","header","property","valueType","attributeValues","valuesPerElement","_setupIdAttribute","_setupStringAttribute","_setupDoubleAttribute","isInteger","unshift","encoding","attributeByteCounts","fieldAttributeType","alias","batchTableWithObjectId","OBJECTID","firstAttribute","getAttributeType","_createdStorageAttribute","_getFieldAttributeType","fieldAttribute","_createFieldAttribute","popupInfo","_createPopupInfo","fields","layerType","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","refreshTokenTime","tile","ADD_TILE_REFINEMENT","refine","includes","url","DracoWriterWorker","sourceResponse","text","i3sAttributesWorkerUrl","I3SAttributesWorker","I3SAttributes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,iBAAiB,GACrB,kCAAQC,GAAR,8DAAaC,QAAb,KACA,0NAFF;AAGA,IAAMC,wBAAwB,GAAG,EAAjC;AACA,IAAMC,SAAS,GAAG,SAAlB;AACA,IAAMC,qBAAqB,GAAG,UAA9B;AACA,IAAMC,WAAW,GAAG,QAApB;AACA,IAAMC,cAAc,GAAG,OAAvB;AACA,IAAMC,WAAW,GAAG,QAApB;AACA,IAAMC,cAAc,GAAG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gBAAAA,IAVV,GAUgB,+BAAatE,+BAAb,oBAAwC,6BAAxC,EAVhB;AAAA;AAAA,uBAWiC,qBAAUsE,IAAV,CAXjC;;AAAA;AAWUE,gBAAAA,gBAXV;AAAA;AAAA,uBAYyBA,gBAAc,CAACC,IAAf,EAZzB;;AAAA;AAYUxE,gBAAAA,QAZV;AAaI,qBAAK5C,YAAL,CAAkB6C,IAAlB,GAAyBD,QAAzB;;AAbJ;AAgBQyE,gBAAAA,sBAhBR,GAgBiC,+BAAaC,wCAAb,oBAAsC,6BAAtC,EAhBjC;AAAA;AAAA,uBAiB+B,qBAAUD,sBAAV,CAjB/B;;AAAA;AAiBQF,gBAAAA,cAjBR;AAAA;AAAA,uBAkBuBA,cAAc,CAACC,IAAf,EAlBvB;;AAAA;AAkBQxE,gBAAAA,MAlBR;AAmBE,qBAAK5C,YAAL,CAAkBuH,aAAlB,GAAkC3E,MAAlC;AACAxM,gBAAAA,OAAO,CAACC,GAAR;;AApBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';\nimport type {BatchTableJson, B3DMContent} from '@loaders.gl/3d-tiles';\nimport type {WriteQueueItem} from '../lib/utils/write-queue';\nimport type {\n AttributeStorageInfo,\n SceneLayer3D,\n BoundingVolumes,\n Node3DIndexDocument,\n NodeReference,\n MaxScreenThresholdSQ,\n NodeInPage,\n LodSelection,\n Attribute,\n ESRIField,\n Field,\n PopupInfo,\n FieldInfo\n} from '@loaders.gl/i3s';\nimport {load, encode, fetchFile, getLoaderOptions, isBrowser} from '@loaders.gl/core';\nimport {Tileset3D} from '@loaders.gl/tiles';\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} from '../lib/utils/file-utils';\nimport {\n compressWithChildProcess\n // generateHash128FromZip,\n // addFileToZip\n} from '../lib/utils/compress-util';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport convertB3dmToI3sGeometry 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 {NODE as nodeTemplate} from './json-templates/node';\nimport {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';\nimport {validateNodeBoundingVolumes} from './helpers/node-debug';\nimport TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';\nimport {KTX2BasisWriterWorker} from '@loaders.gl/textures';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s/src/types';\nimport {ImageWriter} from '@loaders.gl/images';\nimport {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {I3SConvertedResources, SharedResourcesArrays} from './types';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\nimport {DracoWriterWorker} from '@loaders.gl/draco';\nimport WriteQueue from '../lib/utils/write-queue';\nimport {I3SAttributesWorker} from '../i3s-attributes-worker';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\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 STRING_TYPE = 'string';\nconst SHORT_INT_TYPE = 'Int32';\nconst DOUBLE_TYPE = 'double';\nconst OBJECT_ID_TYPE = 'OBJECTID';\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<any, any>;\n materialDefinitions: I3SMaterialDefinition[];\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: Tileset3D | null = null;\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\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n this.options = {};\n this.layers0Path = '';\n this.materialMap = new Map();\n this.materialDefinitions = [];\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 }\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 */\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 validate?: boolean;\n generateTextures?: boolean;\n generateBoundingVolumes?: boolean;\n }): Promise<any> {\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,\n sevenZipExe,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes\n } = options;\n this.options = {maxDepth, slpk, sevenZipExe, egmFilePath, draco, token, inputUrl};\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 const tilesetOptions: Tileset3DProps = {loadOptions: {basis: {format: 'rgba32'}}};\n if (preloadOptions.headers) {\n tilesetOptions.loadOptions!.fetch = {headers: preloadOptions.headers};\n }\n Object.assign(tilesetOptions, preloadOptions);\n const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);\n // console.log(tilesetJson); // eslint-disable-line\n this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);\n\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\n return sourceTilesetJson;\n } catch (error) {\n throw error;\n } finally {\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\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._formLayers0(tilesetName);\n\n this.materialDefinitions = [];\n this.materialMap = new Map();\n\n const sourceRootTile: TileHeader = this.sourceTileset!.root!;\n const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel!);\n const parentId = this.nodePages.push({\n index: 0,\n lodThreshold: 0,\n obb: boundingVolumes.obb,\n children: []\n });\n\n const isCreateSlpk = this.options.slpk;\n const root0 = this._formRootNodeIndexDocument(boundingVolumes);\n\n await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);\n\n this.layers0!.materialDefinitions = this.materialDefinitions;\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 await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));\n await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);\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 */\n private _formLayers0(tilesetName: string): void {\n const fullExtent = convertBoundingVolumeToI3SFullExtent(\n this.sourceTileset?.boundingVolume || this.sourceTileset?.root?.boundingVolume\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 * Convert and save the layer and embedded tiles\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\n private _formRootNodeIndexDocument(boundingVolumes: BoundingVolumes): Node3DIndexDocument {\n const root0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 'root',\n level: 0,\n lodSelection: [\n {\n metricType: 'maxScreenThresholdSQ',\n maxError: 0\n },\n {\n metricType: 'maxScreenThreshold',\n maxError: 0\n }\n ],\n ...boundingVolumes,\n children: []\n };\n return transform(root0data, nodeTemplate());\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param root0 - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n * @param sourceRootTile - Source (3DTile) tile data\n * @param parentId - node id in node pages\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n */\n private async _convertNodesTree(\n root0: Node3DIndexDocument,\n sourceRootTile: TileHeader,\n parentId: number,\n boundingVolumes: BoundingVolumes\n ): Promise<void> {\n await this.sourceTileset!._loadTile(sourceRootTile);\n if (this.isContentSupported(sourceRootTile)) {\n root0.children = root0.children || [];\n root0.children.push({\n id: '1',\n href: './1',\n ...boundingVolumes\n });\n const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);\n const childPath = join(this.layers0Path, 'nodes', child.path!);\n\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',\n writePromise: writeFileForSlpk(\n childPath,\n JSON.stringify(child),\n '3dNodeIndexDocument.json'\n )\n });\n } else {\n await this.writeQueue.enqueue({writePromise: writeFile(childPath, JSON.stringify(child))});\n }\n } else {\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: root0,\n sourceTiles: sourceRootTile.children,\n parentId,\n level: 1\n });\n }\n await sourceRootTile.unloadContent();\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: writeFileForSlpk(\n this.layers0Path,\n JSON.stringify(this.layers0),\n '3dSceneLayer.json'\n )\n });\n } else {\n await this.writeQueue.enqueue({\n writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))\n });\n }\n }\n\n /**\n * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md in file\n */\n private async _writeNodeIndexDocument(\n root0: Node3DIndexDocument,\n nodePath: string,\n rootPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: `nodes/${nodePath}/3dNodeIndexDocument.json.gz`,\n writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')\n });\n } else {\n await this.writeQueue.enqueue({writePromise: writeFile(rootPath, JSON.stringify(root0))});\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 * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildrenWithNeighborsAndWriteFile(data: {\n parentNode: Node3DIndexDocument;\n sourceTiles: TileHeader[];\n parentId: number;\n level: number;\n }): Promise<void> {\n const childNodes = [];\n await this._addChildren({...data, childNodes});\n await this._addNeighborsAndWriteFile(data.parentNode, childNodes);\n }\n\n /**\n * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.childNodes - array of target child nodes\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildren(data: {\n childNodes: NodeReference[];\n sourceTiles: TileHeader[];\n parentNode: Node3DIndexDocument;\n parentId: number;\n level: number;\n }): Promise<void> {\n const {childNodes, sourceTiles, parentNode, parentId, level} = data;\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const sourceTile of sourceTiles) {\n if (sourceTile.type === 'json') {\n await this.sourceTileset!._loadTile(sourceTile);\n await this._addChildren({\n parentNode,\n sourceTiles: sourceTile.children,\n childNodes,\n parentId,\n level: level + 1\n });\n await sourceTile.unloadContent();\n } else {\n const children = await this._createNode(parentNode, sourceTile, parentId, level);\n parentNode.children = parentNode.children || [];\n for (const child of children) {\n parentNode.children.push({\n id: child.id,\n href: `../${child.path}`,\n obb: child.obb,\n mbs: child.mbs\n });\n childNodes.push(child);\n }\n }\n if (sourceTile.id) {\n console.log(sourceTile.id); // eslint-disable-line\n }\n }\n }\n\n /**\n * Add neightbors to 3DNodeIndexDocument and write it in a file\n * @param parentNode - arguments\n * @param childNodes - array of target child nodes\n */\n private async _addNeighborsAndWriteFile(\n parentNode: Node3DIndexDocument,\n childNodes: Node3DIndexDocument[]\n ): Promise<void> {\n for (const node of childNodes) {\n const childPath = join(this.layers0Path, 'nodes', node.path!);\n const nodePath = node.path;\n delete node.path;\n\n // Don't do large amount of \"neightbors\" to avoid big memory consumption\n if (Number(parentNode?.children?.length) < 1000) {\n for (const neighbor of parentNode.children || []) {\n // eslint-disable-next-line max-depth\n if (node.id === neighbor.id) {\n continue; // eslint-disable-line\n }\n\n if (node.neighbors) {\n node.neighbors.push({...neighbor});\n }\n }\n } else {\n // eslint-disable-next-line no-console, no-undef\n console.warn(\n `Node ${node.id}: neighbors attribute is omited because of large number of neigbors`\n );\n delete node.neighbors;\n }\n await this._writeNodeIndexDocument(node, nodePath!, childPath);\n node.neighbors = [];\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param parentTile - parent 3DNodeIndexDocument\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param level - level of node (distanse to root node in the tree)\n */\n private async _createNode(\n parentTile: Node3DIndexDocument,\n sourceTile: TileHeader,\n parentId: number,\n level: number\n ): Promise<Node3DIndexDocument[]> {\n if (this.validate) {\n this._checkAddRefinementTypeForTile(sourceTile);\n }\n\n await this._updateTilesetOptions();\n await this.sourceTileset!._loadTile(sourceTile);\n\n let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel!);\n\n const batchTable = sourceTile?.content?.batchTableJson;\n\n if (batchTable) {\n this._convertAttributeStorageInfo(sourceTile.content);\n }\n\n const resourcesData = await this._convertResources(sourceTile);\n\n const nodes: Node3DIndexDocument[] = [];\n const nodesInPage: NodeInPage[] = [];\n const emptyResources = {\n geometry: null,\n compressedGeometry: null,\n texture: null,\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 = this._createNodeInNodePages(\n maxScreenThresholdSQ,\n boundingVolumes,\n sourceTile,\n parentId,\n resources\n );\n const node = this._createNodeIndexDocument(\n parentTile,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n\n if (nodeInPage.mesh) {\n await this._writeResources(resources, node.path!);\n }\n\n if (this.validate) {\n this.boundingVolumeWarnings = validateNodeBoundingVolumes(node);\n\n if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {\n console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings); //eslint-disable-line\n }\n }\n\n nodes.push(node);\n nodesInPage.push(nodeInPage);\n }\n\n sourceTile.unloadContent();\n\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: nodes[0],\n sourceTiles: sourceTile.children,\n parentId: nodesInPage[0].index!,\n level: level + 1\n });\n return nodes;\n }\n\n /**\n * Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * from B3DM batch table\n * @param sourceTileContent - tile content of 3DTile\n * @return {void}\n */\n private _convertAttributeStorageInfo(sourceTileContent: B3DMContent): void {\n // In legacy b3dm files sometimes sourceTileContent is null.\n const batchTable = sourceTileContent && sourceTileContent.batchTableJson;\n if (batchTable && !this.layers0?.attributeStorageInfo?.length) {\n this._convertBatchTableInfoToNodeAttributes(batchTable);\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param sourceTile - source tile (3DTile)\n * result.geometry - ArrayBuffer with geometry attributes\n * result.compressedGeometry - ArrayBuffer with compressed (draco) geometry\n * result.texture - texture image\n * result.sharedResources - shared resource data object\n * result.meshMaterial - PBR-like material object\n * result.vertexCount - number of vertices in geometry\n * result.attributes - feature attributes\n * result.featureCount - number of features\n */\n private async _convertResources(sourceTile: TileHeader): Promise<I3SConvertedResources[] | null> {\n if (!this.isContentSupported(sourceTile)) {\n return null;\n }\n const resourcesData = await convertB3dmToI3sGeometry(\n sourceTile.content,\n Number(this.nodePages.nodesCounter),\n this.featuresHashArray,\n this.layers0?.attributeStorageInfo,\n this.options.draco,\n this.generateBoundingVolumes,\n this.geoidHeightModel!,\n this.workerSource\n );\n return resourcesData;\n }\n\n /**\n * Create a new 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 * @return the node object in node pages\n */\n private _createNodeInNodePages(\n maxScreenThresholdSQ: MaxScreenThresholdSQ,\n boundingVolumes: BoundingVolumes,\n sourceTile: TileHeader,\n parentId: number,\n resources: I3SConvertedResources\n ): NodeInPage {\n const {meshMaterial, texture, vertexCount, featureCount, geometry} = 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: texture ? 0 : 1,\n resource: 0\n },\n attribute: {\n resource: 0\n },\n material: {\n definition: 0\n }\n };\n }\n const nodeId = this.nodePages.push(nodeInPage, parentId);\n\n if (meshMaterial) {\n this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));\n }\n\n if (texture) {\n const texelCountHint = texture.image.height * texture.image.width;\n this.nodePages.updateTexelCountHintByNodeId(nodeId, texelCountHint);\n }\n\n if (vertexCount) {\n this.vertexCounter += vertexCount;\n this.nodePages.updateVertexCountByNodeId(nodeId, vertexCount);\n }\n this.nodePages.updateNodeAttributeByNodeId(nodeId);\n if (featureCount) {\n this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);\n }\n\n return nodeInPage;\n }\n\n /**\n * Create a new node page object in node pages\n * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node\n * @param boundingVolumes - Bounding volumes\n * @param lodSelection - Level of Details (LOD) metrics\n * @param nodeInPage - corresponding node object in a node page\n * @param resources - the node resources data\n * @param resources.texture - texture image\n * @param resources.attributes - feature attributes\n * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object\n */\n private _createNodeIndexDocument(\n parentNode: Node3DIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources\n ): Node3DIndexDocument {\n const {texture, attributes} = resources;\n const nodeId = nodeInPage.index!;\n const nodeData = {\n version: parentNode.version,\n id: nodeId.toString(),\n path: nodeId.toString(),\n level: parentNode.level! + 1,\n ...boundingVolumes,\n lodSelection,\n parentNode: {\n id: parentNode.id,\n href: `../${parentNode.id}`,\n mbs: parentNode.mbs,\n obb: parentNode.obb\n },\n children: [],\n neighbors: []\n };\n const node = transform(nodeData, nodeTemplate());\n\n if (nodeInPage.mesh) {\n node.geometryData = [{href: './geometries/0'}];\n node.sharedResource = {href: './shared'};\n\n if (texture) {\n node.textureData = [{href: './textures/0'}, {href: './textures/1'}];\n }\n\n if (attributes && attributes.length && this.layers0?.attributeStorageInfo?.length) {\n node.attributeData = [];\n for (let index = 0; index < attributes.length; index++) {\n const folderName = this.layers0.attributeStorageInfo[index].key;\n node.attributeData.push({href: `./attributes/${folderName}/0`});\n }\n }\n }\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: 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 const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, {\n ...KTX2BasisWriterWorker.options,\n source: this.workerSource.ktx2,\n reuseWorkers: true,\n _nodeWorkers: true\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 }\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: 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: 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);\n }\n const newMaterialId = this.materialDefinitions.push(material) - 1;\n this.materialMap.set(hash, newMaterialId);\n return newMaterialId;\n }\n\n /**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from batch table.\\\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private _createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n this._setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n this._setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n this._setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n this._setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in batchTable\n */\n private getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n }\n\n /**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private _setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.ordering!.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private _createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n }\n\n /**\n * Do conversion of 3DTiles batch table to I3s node attributes.\n * @param batchTable - Table with layer meta data.\n */\n private _convertBatchTableInfoToNodeAttributes(batchTable: BatchTableJson): void {\n let attributeIndex = 0;\n const batchTableWithObjectId = {\n OBJECTID: [0],\n ...batchTable\n };\n\n for (const key in batchTableWithObjectId) {\n const firstAttribute = batchTableWithObjectId[key][0];\n const attributeType = this.getAttributeType(key, firstAttribute);\n\n const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this._getFieldAttributeType(attributeType);\n const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);\n const popupInfo = this._createPopupInfo(batchTableWithObjectId);\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 * Find and return attribute type based on key form Batch table.\n * @param attributeType\n */\n private _getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Generate popup info to show metadata on the map.\n * @param batchTable - Batch table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\n private _createPopupInfo(batchTable: BatchTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in batchTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\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 this.sourceTileset!.options = {...this.sourceTileset!.options, ...preloadOptions};\n if (preloadOptions.headers) {\n this.sourceTileset!.loadOptions.fetch = {\n ...this.sourceTileset!.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: TileHeader): 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 * Check if the tile's content format is supported by the converter\n * @param sourceRootTile\n * @returns\n */\n private isContentSupported(sourceRootTile: Tile3D): boolean {\n return ['b3dm', 'glTF'].includes(sourceRootTile?.content?.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 const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);\n const source = await sourceResponse.text();\n this.workerSource.I3SAttributes = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"i3s-converter.js"}
1
+ {"version":3,"sources":["../../../src/i3s-converter/i3s-converter.ts"],"names":["ION_DEFAULT_TOKEN","env","IonToken","HARDCODED_NODES_PER_PAGE","_3D_TILES","_3D_OBJECT_LAYER_TYPE","STRING_TYPE","SHORT_INT_TYPE","DOUBLE_TYPE","OBJECT_ID_TYPE","REFRESH_TOKEN_TIMEOUT","CESIUM_DATASET_PREFIX","I3SConverter","Tiles3DLoader","WriteQueue","nodePages","NodePages","writeFile","options","layers0Path","materialMap","Map","materialDefinitions","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","layersHasTexture","isBrowser","console","log","BROWSER_ERROR_MESSAGE","conversionStartTime","process","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","sevenZipExe","maxDepth","token","Boolean","Loader","indexOf","CesiumIonLoader","writeQueue","startListening","PGMLoader","geoidHeightModel","useWriteFunction","writeFileForSlpk","loadWorkers","_fetchPreloadOptions","preloadOptions","tilesetOptions","loadOptions","basis","format","headers","fetch","Object","assign","sourceTilesetJson","sourceTileset","Tileset3D","_createAndSaveTileset","_finishConversion","workerFarm","WorkerFarm","getWorkerFarm","destroy","tilesetPath","_formLayers0","sourceRootTile","root","boundingVolumes","parentId","push","index","lodThreshold","obb","children","isCreateSlpk","root0","_formRootNodeIndexDocument","_convertNodesTree","store","defaultGeometrySchema","ordering","filter","attribute","_writeLayers0","_writeNodeIndexDocument","save","finalize","_createSlpk","fullExtent","boundingVolume","extent","xmin","ymin","xmax","ymax","layers0data","version","toUpperCase","id","name","href","nodesPerPage","compressGeometry","root0data","level","lodSelection","metricType","maxError","_loadTile","isContentSupported","_createNode","child","childPath","path","enqueue","archiveKey","writePromise","JSON","stringify","_addChildrenWithNeighborsAndWriteFile","parentNode","sourceTiles","unloadContent","nodePath","rootPath","slpkTilesetPath","slpkFileName","data","childNodes","_addChildren","_addNeighborsAndWriteFile","sourceTile","type","mbs","node","Number","length","neighbor","neighbors","warn","parentTile","_checkAddRefinementTypeForTile","_updateTilesetOptions","propertyTable","attributeStorageInfo","_convertPropertyTableToNodeAttributes","_convertResources","resourcesData","nodes","nodesInPage","emptyResources","geometry","compressedGeometry","texture","sharedResources","meshMaterial","vertexCount","attributes","featureCount","resources","maxScreenThresholdSQ","find","val","nodeInPage","_createNodeInNodePages","_createNodeIndexDocument","mesh","_writeResources","boundingVolumeWarnings","content","nodesCounter","workerSource","definition","resource","material","nodeId","updateMaterialByNodeId","_findOrCreateMaterial","texelCountHint","image","height","width","updateTexelCountHintByNodeId","updateVertexCountByNodeId","updateNodeAttributeByNodeId","updateFeatureCountByNodeId","nodeData","toString","geometryData","sharedResource","textureData","attributeData","folderName","key","geometryBuffer","slpkChildPath","_writeGeometries","_writeShared","_writeTexture","_writeAttributes","slpkGeometryPath","geometryPath","slpkCompressedGeometryPath","compressedGeometryPath","sharedData","sharedDataStr","slpkSharedPath","sharedPath","_getFormatByMimeType","mimeType","formats","bufferView","writeTextureFile","copyArrayBuffer","subarray","arrayToEncode","Uint8Array","ktx2TextureData","KTX2BasisWriterWorker","source","ktx2","reuseWorkers","_nodeWorkers","decodedFromKTX2TextureData","ImageWriter","textureSetDefinitions","slpkTexturePath","compress","texturePath","fileBuffer","slpkAttributesPath","attributesPath","hash","has","get","newMaterialId","set","attributeIndex","attributeType","storageAttribute","header","property","valueType","attributeValues","valuesPerElement","_setupIdAttribute","_setupStringAttribute","_setupDoubleAttribute","isInteger","unshift","encoding","attributeByteCounts","fieldAttributeType","alias","propertyTableWithObjectId","OBJECTID","firstAttribute","getAttributeType","_createdStorageAttribute","_getFieldAttributeType","fieldAttribute","_createFieldAttribute","popupInfo","_createPopupInfo","fields","layerType","title","mediaInfos","fieldInfos","popupElements","expressionInfos","fieldName","visible","isEditable","label","params","addRefinementPercentage","filesSize","diff","conversionTime","preload","accessToken","refreshTokenTime","tile","ADD_TILE_REFINEMENT","refine","includes","url","DracoWriterWorker","sourceResponse","text","i3sAttributesWorkerUrl","I3SAttributesWorker","I3SAttributes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAEA,IAAMA,iBAAiB,GACrB,kCAAQC,GAAR,8DAAaC,QAAb,KACA,0NAFF;AAGA,IAAMC,wBAAwB,GAAG,EAAjC;AACA,IAAMC,SAAS,GAAG,SAAlB;AACA,IAAMC,qBAAqB,GAAG,UAA9B;AACA,IAAMC,WAAW,GAAG,QAApB;AACA,IAAMC,cAAc,GAAG,OAAvB;AACA,IAAMC,WAAW,GAAG,QAApB;AACA,IAAMC,cAAc,GAAG,UAAvB;AACA,IAAMC,qBAAqB,GAAG,IAA9B;AACA,IAAMC,qBAAqB,GAAG,UAA9B;;IAMqBC,Y;AA0BnB,0BAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kEAZsB,EAYtB;AAAA,+DAX0B,CAAC,CAAD,EAAI,CAAJ,CAW1B;AAAA,4DAVuB,CAAC,CAAD,EAAI,CAAJ,CAUvB;AAAA,yDAToB,IASpB;AAAA,4DARmB,IAQnB;AAAA,kDAPaC,qBAOb;AAAA;AAAA;AAAA;AAAA,wDAH0B,EAG1B;AAAA,sDAF2B,IAAIC,mBAAJ,EAE3B;AACZ,SAAKC,SAAL,GAAiB,IAAIC,kBAAJ,CAAcC,oBAAd,EAAyBd,wBAAzB,CAAjB;AACA,SAAKe,OAAL,GAAe,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1E,MAAlC;AACAzM,gBAAAA,OAAO,CAACC,GAAR;;AApBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';\nimport type {FeatureTableJson} from '@loaders.gl/3d-tiles';\nimport type {WriteQueueItem} from '../lib/utils/write-queue';\nimport type {\n AttributeStorageInfo,\n SceneLayer3D,\n BoundingVolumes,\n Node3DIndexDocument,\n NodeReference,\n MaxScreenThresholdSQ,\n NodeInPage,\n LodSelection,\n Attribute,\n ESRIField,\n Field,\n PopupInfo,\n FieldInfo\n} from '@loaders.gl/i3s';\nimport {load, encode, fetchFile, getLoaderOptions, isBrowser} from '@loaders.gl/core';\nimport {Tileset3D} from '@loaders.gl/tiles';\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} from '../lib/utils/file-utils';\nimport {\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 {NODE as nodeTemplate} from './json-templates/node';\nimport {SHARED_RESOURCES as sharedResourcesTemplate} from './json-templates/shared-resources';\nimport {validateNodeBoundingVolumes} from './helpers/node-debug';\nimport TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';\nimport {KTX2BasisWriterWorker} from '@loaders.gl/textures';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s/src/types';\nimport {ImageWriter} from '@loaders.gl/images';\nimport {GLTFImagePostprocessed} from '@loaders.gl/gltf';\nimport {I3SConvertedResources, SharedResourcesArrays} from './types';\nimport {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';\nimport {DracoWriterWorker} from '@loaders.gl/draco';\nimport WriteQueue from '../lib/utils/write-queue';\nimport {I3SAttributesWorker} from '../i3s-attributes-worker';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\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 STRING_TYPE = 'string';\nconst SHORT_INT_TYPE = 'Int32';\nconst DOUBLE_TYPE = 'double';\nconst OBJECT_ID_TYPE = 'OBJECTID';\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<any, any>;\n materialDefinitions: I3SMaterialDefinition[];\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: Tileset3D | null = null;\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\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n this.options = {};\n this.layers0Path = '';\n this.materialMap = new Map();\n this.materialDefinitions = [];\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 }\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 */\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 validate?: boolean;\n generateTextures?: boolean;\n generateBoundingVolumes?: boolean;\n }): Promise<any> {\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,\n sevenZipExe,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes\n } = options;\n this.options = {maxDepth, slpk, sevenZipExe, egmFilePath, draco, token, inputUrl};\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 const tilesetOptions: Tileset3DProps = {loadOptions: {basis: {format: 'rgba32'}}};\n if (preloadOptions.headers) {\n tilesetOptions.loadOptions!.fetch = {headers: preloadOptions.headers};\n }\n Object.assign(tilesetOptions, preloadOptions);\n const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);\n // console.log(tilesetJson); // eslint-disable-line\n this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);\n\n await this._createAndSaveTileset(outputPath, tilesetName);\n await this._finishConversion({slpk: Boolean(slpk), outputPath, tilesetName});\n return sourceTilesetJson;\n } catch (error) {\n throw error;\n } finally {\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\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._formLayers0(tilesetName);\n\n this.materialDefinitions = [];\n this.materialMap = new Map();\n\n const sourceRootTile: TileHeader = this.sourceTileset!.root!;\n const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel!);\n const parentId = this.nodePages.push({\n index: 0,\n lodThreshold: 0,\n obb: boundingVolumes.obb,\n children: []\n });\n\n const isCreateSlpk = this.options.slpk;\n const root0 = this._formRootNodeIndexDocument(boundingVolumes);\n\n await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);\n\n this.layers0!.materialDefinitions = this.materialDefinitions;\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 await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));\n await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);\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 */\n private _formLayers0(tilesetName: string): void {\n const fullExtent = convertBoundingVolumeToI3SFullExtent(\n this.sourceTileset?.boundingVolume || this.sourceTileset?.root?.boundingVolume\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 * Convert and save the layer and embedded tiles\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\n private _formRootNodeIndexDocument(boundingVolumes: BoundingVolumes): Node3DIndexDocument {\n const root0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 'root',\n level: 0,\n lodSelection: [\n {\n metricType: 'maxScreenThresholdSQ',\n maxError: 0\n },\n {\n metricType: 'maxScreenThreshold',\n maxError: 0\n }\n ],\n ...boundingVolumes,\n children: []\n };\n return transform(root0data, nodeTemplate());\n }\n\n /**\n * Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md\n * @param root0 - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n * @param sourceRootTile - Source (3DTile) tile data\n * @param parentId - node id in node pages\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n */\n private async _convertNodesTree(\n root0: Node3DIndexDocument,\n sourceRootTile: TileHeader,\n parentId: number,\n boundingVolumes: BoundingVolumes\n ): Promise<void> {\n await this.sourceTileset!._loadTile(sourceRootTile);\n if (this.isContentSupported(sourceRootTile)) {\n root0.children = root0.children || [];\n root0.children.push({\n id: '1',\n href: './1',\n ...boundingVolumes\n });\n const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);\n const childPath = join(this.layers0Path, 'nodes', child.path!);\n\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',\n writePromise: writeFileForSlpk(\n childPath,\n JSON.stringify(child),\n '3dNodeIndexDocument.json'\n )\n });\n } else {\n await this.writeQueue.enqueue({writePromise: writeFile(childPath, JSON.stringify(child))});\n }\n } else {\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: root0,\n sourceTiles: sourceRootTile.children,\n parentId,\n level: 1\n });\n }\n await sourceRootTile.unloadContent();\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: writeFileForSlpk(\n this.layers0Path,\n JSON.stringify(this.layers0),\n '3dSceneLayer.json'\n )\n });\n } else {\n await this.writeQueue.enqueue({\n writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))\n });\n }\n }\n\n /**\n * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md in file\n */\n private async _writeNodeIndexDocument(\n root0: Node3DIndexDocument,\n nodePath: string,\n rootPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n await this.writeQueue.enqueue({\n archiveKey: `nodes/${nodePath}/3dNodeIndexDocument.json.gz`,\n writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')\n });\n } else {\n await this.writeQueue.enqueue({writePromise: writeFile(rootPath, JSON.stringify(root0))});\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 * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildrenWithNeighborsAndWriteFile(data: {\n parentNode: Node3DIndexDocument;\n sourceTiles: TileHeader[];\n parentId: number;\n level: number;\n }): Promise<void> {\n const childNodes = [];\n await this._addChildren({...data, childNodes});\n await this._addNeighborsAndWriteFile(data.parentNode, childNodes);\n }\n\n /**\n * Add child nodes recursively and write them to files\n * @param data - arguments\n * @param data.childNodes - array of target child nodes\n * @param data.sourceTiles - array of source child nodes\n * @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes\n * @param data.parentId - id of parent node in node pages\n * @param data.level - level of node (distanse to root node in the tree)\n */\n private async _addChildren(data: {\n childNodes: NodeReference[];\n sourceTiles: TileHeader[];\n parentNode: Node3DIndexDocument;\n parentId: number;\n level: number;\n }): Promise<void> {\n const {childNodes, sourceTiles, parentNode, parentId, level} = data;\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const sourceTile of sourceTiles) {\n if (sourceTile.type === 'json') {\n await this.sourceTileset!._loadTile(sourceTile);\n await this._addChildren({\n parentNode,\n sourceTiles: sourceTile.children,\n childNodes,\n parentId,\n level: level + 1\n });\n await sourceTile.unloadContent();\n } else {\n const children = await this._createNode(parentNode, sourceTile, parentId, level);\n parentNode.children = parentNode.children || [];\n for (const child of children) {\n parentNode.children.push({\n id: child.id,\n href: `../${child.path}`,\n obb: child.obb,\n mbs: child.mbs\n });\n childNodes.push(child);\n }\n }\n if (sourceTile.id) {\n console.log(sourceTile.id); // eslint-disable-line\n }\n }\n }\n\n /**\n * Add neightbors to 3DNodeIndexDocument and write it in a file\n * @param parentNode - arguments\n * @param childNodes - array of target child nodes\n */\n private async _addNeighborsAndWriteFile(\n parentNode: Node3DIndexDocument,\n childNodes: Node3DIndexDocument[]\n ): Promise<void> {\n for (const node of childNodes) {\n const childPath = join(this.layers0Path, 'nodes', node.path!);\n const nodePath = node.path;\n delete node.path;\n\n // Don't do large amount of \"neightbors\" to avoid big memory consumption\n if (Number(parentNode?.children?.length) < 1000) {\n for (const neighbor of parentNode.children || []) {\n // eslint-disable-next-line max-depth\n if (node.id === neighbor.id) {\n continue; // eslint-disable-line\n }\n\n if (node.neighbors) {\n node.neighbors.push({...neighbor});\n }\n }\n } else {\n // eslint-disable-next-line no-console, no-undef\n console.warn(\n `Node ${node.id}: neighbors attribute is omited because of large number of neigbors`\n );\n delete node.neighbors;\n }\n await this._writeNodeIndexDocument(node, nodePath!, childPath);\n node.neighbors = [];\n }\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param parentTile - parent 3DNodeIndexDocument\n * @param sourceTile - source tile (3DTile)\n * @param parentId - id of parent node in node pages\n * @param level - level of node (distanse to root node in the tree)\n */\n private async _createNode(\n parentTile: Node3DIndexDocument,\n sourceTile: TileHeader,\n parentId: number,\n level: number\n ): Promise<Node3DIndexDocument[]> {\n if (this.validate) {\n this._checkAddRefinementTypeForTile(sourceTile);\n }\n\n await this._updateTilesetOptions();\n await this.sourceTileset!._loadTile(sourceTile);\n\n let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel!);\n\n const propertyTable = getPropertyTable(sourceTile);\n\n if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {\n this._convertPropertyTableToNodeAttributes(propertyTable);\n }\n\n const resourcesData = await this._convertResources(sourceTile, propertyTable);\n\n const nodes: Node3DIndexDocument[] = [];\n const nodesInPage: NodeInPage[] = [];\n const emptyResources = {\n geometry: null,\n compressedGeometry: null,\n texture: null,\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 = this._createNodeInNodePages(\n maxScreenThresholdSQ,\n boundingVolumes,\n sourceTile,\n parentId,\n resources\n );\n const node = this._createNodeIndexDocument(\n parentTile,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n\n if (nodeInPage.mesh) {\n await this._writeResources(resources, node.path!);\n }\n\n if (this.validate) {\n this.boundingVolumeWarnings = validateNodeBoundingVolumes(node);\n\n if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {\n console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings); //eslint-disable-line\n }\n }\n\n nodes.push(node);\n nodesInPage.push(nodeInPage);\n }\n\n sourceTile.unloadContent();\n\n await this._addChildrenWithNeighborsAndWriteFile({\n parentNode: nodes[0],\n sourceTiles: sourceTile.children,\n parentId: nodesInPage[0].index!,\n level: level + 1\n });\n return nodes;\n }\n\n /**\n * Convert tile to one or more I3S nodes\n * @param sourceTile - source tile (3DTile)\n * result.geometry - ArrayBuffer with geometry attributes\n * result.compressedGeometry - ArrayBuffer with compressed (draco) geometry\n * result.texture - texture image\n * result.sharedResources - shared resource data object\n * result.meshMaterial - PBR-like material object\n * result.vertexCount - number of vertices in geometry\n * result.attributes - feature attributes\n * result.featureCount - number of features\n */\n private async _convertResources(\n sourceTile: TileHeader,\n propertyTable: FeatureTableJson | null\n ): Promise<I3SConvertedResources[] | null> {\n if (!this.isContentSupported(sourceTile)) {\n return null;\n }\n const resourcesData = await convertB3dmToI3sGeometry(\n sourceTile.content,\n Number(this.nodePages.nodesCounter),\n propertyTable,\n this.featuresHashArray,\n this.layers0?.attributeStorageInfo,\n this.options.draco,\n this.generateBoundingVolumes,\n this.geoidHeightModel!,\n this.workerSource\n );\n return resourcesData;\n }\n\n /**\n * Create a new 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 * @return the node object in node pages\n */\n private _createNodeInNodePages(\n maxScreenThresholdSQ: MaxScreenThresholdSQ,\n boundingVolumes: BoundingVolumes,\n sourceTile: TileHeader,\n parentId: number,\n resources: I3SConvertedResources\n ): NodeInPage {\n const {meshMaterial, texture, vertexCount, featureCount, geometry} = 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: texture ? 0 : 1,\n resource: 0\n },\n attribute: {\n resource: 0\n },\n material: {\n definition: 0\n }\n };\n }\n const nodeId = this.nodePages.push(nodeInPage, parentId);\n\n if (meshMaterial) {\n this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));\n }\n\n if (texture) {\n const texelCountHint = texture.image.height * texture.image.width;\n this.nodePages.updateTexelCountHintByNodeId(nodeId, texelCountHint);\n }\n\n if (vertexCount) {\n this.vertexCounter += vertexCount;\n this.nodePages.updateVertexCountByNodeId(nodeId, vertexCount);\n }\n this.nodePages.updateNodeAttributeByNodeId(nodeId);\n if (featureCount) {\n this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);\n }\n\n return nodeInPage;\n }\n\n /**\n * Create a new node page object in node pages\n * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node\n * @param boundingVolumes - Bounding volumes\n * @param lodSelection - Level of Details (LOD) metrics\n * @param nodeInPage - corresponding node object in a node page\n * @param resources - the node resources data\n * @param resources.texture - texture image\n * @param resources.attributes - feature attributes\n * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object\n */\n private _createNodeIndexDocument(\n parentNode: Node3DIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources\n ): Node3DIndexDocument {\n const {texture, attributes} = resources;\n const nodeId = nodeInPage.index!;\n const nodeData = {\n version: parentNode.version,\n id: nodeId.toString(),\n path: nodeId.toString(),\n level: parentNode.level! + 1,\n ...boundingVolumes,\n lodSelection,\n parentNode: {\n id: parentNode.id,\n href: `../${parentNode.id}`,\n mbs: parentNode.mbs,\n obb: parentNode.obb\n },\n children: [],\n neighbors: []\n };\n const node = transform(nodeData, nodeTemplate());\n\n if (nodeInPage.mesh) {\n node.geometryData = [{href: './geometries/0'}];\n node.sharedResource = {href: './shared'};\n\n if (texture) {\n node.textureData = [{href: './textures/0'}, {href: './textures/1'}];\n }\n\n if (attributes && attributes.length && this.layers0?.attributeStorageInfo?.length) {\n node.attributeData = [];\n for (let index = 0; index < attributes.length; index++) {\n const folderName = this.layers0.attributeStorageInfo[index].key;\n node.attributeData.push({href: `./attributes/${folderName}/0`});\n }\n }\n }\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: 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 }\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: 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: 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);\n }\n const newMaterialId = this.materialDefinitions.push(material) - 1;\n this.materialMap.set(hash, newMaterialId);\n return newMaterialId;\n }\n\n /**\n * Generate storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private _createdStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n this._setupIdAttribute(storageAttribute);\n break;\n case STRING_TYPE:\n this._setupStringAttribute(storageAttribute);\n break;\n case DOUBLE_TYPE:\n this._setupDoubleAttribute(storageAttribute);\n break;\n case SHORT_INT_TYPE:\n break;\n default:\n this._setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md\n * @param key - attribute's key\n * @param attribute - attribute's type in propertyTable\n */\n private getAttributeType(key: string, attribute: string): string {\n if (key === OBJECT_ID_TYPE) {\n return OBJECT_ID_TYPE;\n }\n if (typeof attribute === STRING_TYPE) {\n return STRING_TYPE;\n } else if (typeof attribute === 'number') {\n return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;\n }\n return STRING_TYPE;\n }\n\n /**\n * Setup storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private _setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.ordering!.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private _setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Setup field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private _createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\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 = this.getAttributeType(key, firstAttribute);\n\n const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this._getFieldAttributeType(attributeType);\n const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);\n const popupInfo = this._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 * Find and return attribute type based on key form propertyTable.\n * @param attributeType\n */\n private _getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case STRING_TYPE:\n return 'esriFieldTypeString';\n case SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Generate popup info to show metadata on the map.\n * @param propertyTable - table data with OBJECTID.\n * @return data for correct rendering of popup.\n */\n private _createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const key in propertyTable) {\n fieldInfos.push({\n fieldName: key,\n visible: true,\n isEditable: false,\n label: key\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\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 this.sourceTileset!.options = {...this.sourceTileset!.options, ...preloadOptions};\n if (preloadOptions.headers) {\n this.sourceTileset!.loadOptions.fetch = {\n ...this.sourceTileset!.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: TileHeader): 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 * Check if the tile's content format is supported by the converter\n * @param sourceRootTile\n * @returns\n */\n private isContentSupported(sourceRootTile: Tile3D): boolean {\n return ['b3dm', 'glTF'].includes(sourceRootTile?.content?.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 const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, {...getLoaderOptions()});\n const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);\n const source = await sourceResponse.text();\n this.workerSource.I3SAttributes = source;\n console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console\n }\n}\n"],"file":"i3s-converter.js"}
@@ -217,7 +217,7 @@ var WriteQueue = function (_Queue) {
217
217
 
218
218
  case 14:
219
219
  _context4.next = 16;
220
- return Promise.all(promises);
220
+ return Promise.allSettled(promises);
221
221
 
222
222
  case 16:
223
223
  writeResults = _context4.sent;
@@ -248,11 +248,9 @@ var WriteQueue = function (_Queue) {
248
248
  for (var i = 0; i < archiveKeys.length; i++) {
249
249
  var archiveKey = archiveKeys[i];
250
250
 
251
- if (!archiveKey) {
252
- continue;
251
+ if (archiveKey && 'value' in writeResults[i]) {
252
+ this.fileMap[archiveKey] = writeResults[i].value;
253
253
  }
254
-
255
- this.fileMap[archiveKey] = writeResults[i];
256
254
  }
257
255
  }
258
256
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/write-queue.ts"],"names":["MEMORY_LIMIT","WriteQueue","listeningInterval","writeConcurrency","val","process","memoryUsage","rss","startWrite","intervalId","setInterval","bind","clearInterval","writePromise","doWrite","stopListening","length","promises","archiveKeys","i","item","dequeue","archiveKey","push","Promise","all","writeResults","updateFileMap","fileMap","Queue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAGA,IAAMA,YAAY,GAAG,IAAI,IAAJ,GAAW,IAAX,GAAkB,IAAvC;;IAOqBC,U;;;;;AAOnB,wBAA8E;AAAA;;AAAA,QAAlEC,iBAAkE,uEAAtC,IAAsC;AAAA,QAAhCC,gBAAgC,uEAAL,GAAK;AAAA;AAC5E;AAD4E;AAAA,+FALlC,IAKkC;AAAA,0FAJpC,EAIoC;AAAA;AAAA;AAE5E,UAAKD,iBAAL,GAAyBA,iBAAzB;AACA,UAAKC,gBAAL,GAAwBA,gBAAxB;AAH4E;AAI7E;;;;;+EAED,iBAAcC,GAAd;AAAA;AAAA;AAAA;AAAA;AACE,oHAAcA,GAAd;;AADF,sBAGMC,iBAAQC,WAAR,GAAsBC,GAAtB,GAA4BP,YAHlC;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAIU,KAAKQ,UAAL,EAJV;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAQA,0BAAiB;AACf,WAAKC,UAAL,GAAkBC,WAAW,CAAC,KAAKF,UAAL,CAAgBG,IAAhB,CAAqB,IAArB,CAAD,EAA6B,KAAKT,iBAAlC,CAA7B;AACD;;;WAED,yBAAgB;AACd,UAAI,KAAKO,UAAT,EAAqB;AACnBG,QAAAA,aAAa,CAAC,KAAKH,UAAN,CAAb;AACD;AACF;;;;kFAED;AAAA;AAAA;AAAA;AAAA;AAAA,qBACM,KAAKI,YADX;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAEU,KAAKA,YAFf;;AAAA;AAGI,qBAAKA,YAAL,GAAoB,IAApB;AAHJ;;AAAA;AAME,qBAAKA,YAAL,GAAoB,KAAKC,OAA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AGD,WAAW,CAACF,MAAhC,EAAwCG,CAAC,EAAzC,EAA6C;AAC3C,YAAMG,UAAU,GAAGJ,WAAW,CAACC,CAAD,CAA9B;;AACA,YAAI,CAACG,UAAL,EAAiB;AACf;AACD;;AACD,aAAKM,OAAL,CAAaN,UAAb,IAA2BI,YAAY,CAACP,CAAD,CAAvC;AACD;AACF;;;EA1E+DU,Y","sourcesContent":["import {Queue} from './queue';\nimport process from 'process';\n\n/** Memory limit size is based on testing */\nconst MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n writePromise: Promise<string>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n async enqueue(val: T) {\n super.enqueue(val);\n /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */\n if (process.memoryUsage().rss > MEMORY_LIMIT) {\n await this.startWrite();\n }\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (this.writePromise) {\n await this.writePromise;\n this.writePromise = null;\n return;\n }\n this.writePromise = this.doWrite();\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n promises.push(writePromise);\n }\n const writeResults = await Promise.all(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n this.writePromise = null;\n }\n\n private updateFileMap(archiveKeys: (string | undefined)[], writeResults: string[]) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (!archiveKey) {\n continue;\n }\n this.fileMap[archiveKey] = writeResults[i];\n }\n }\n}\n"],"file":"write-queue.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/write-queue.ts"],"names":["MEMORY_LIMIT","WriteQueue","listeningInterval","writeConcurrency","val","process","memoryUsage","rss","startWrite","intervalId","setInterval","bind","clearInterval","writePromise","doWrite","stopListening","length","promises","archiveKeys","i","item","dequeue","archiveKey","push","Promise","allSettled","writeResults","updateFileMap","fileMap","value","Queue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAGA,IAAMA,YAAY,GAAG,IAAI,IAAJ,GAAW,IAAX,GAAkB,IAAvC;;IAOqBC,U;;;;;AAOnB,wBAA8E;AAAA;;AAAA,QAAlEC,iBAAkE,uEAAtC,IAAsC;AAAA,QAAhCC,gBAAgC,uEAAL,GAAK;AAAA;AAC5E;AAD4E;AAAA,+FALlC,IAKkC;AAAA,0FAJpC,EAIoC;AAAA;AAAA;AAE5E,UAAKD,iBAAL,GAAyBA,iBAAzB;AACA,UAAKC,gBAAL,GAAwBA,gBAAxB;AAH4E;AAI7E;;;;;+EAED,iBAAcC,GAAd;AAAA;AAAA;AAAA;AAAA;AACE,oHAAcA,GAAd;;AADF,sBAGMC,iBAAQC,WAAR,GAAsBC,GAAtB,GAA4BP,YAHlC;AAAA;AAAA;AAAA;;AAAA;AAAA,uBAIU,KAAKQ,UAAL,EAJV;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAQA,0BAAiB;AACf,WAAKC,UAAL,GAAkBC,WAAW,CAAC,KAAKF,UAAL,CAAgBG,IAAhB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;AAAA;AAAA,uBAa+BK,OAAO,CAACC,UAAR,CAAmBR,QAAnB,CAb/B;;AAAA;AAaUS,gBAAAA,YAbV;AAcI,qBAAKC,aAAL,CAAmBT,WAAnB,EAAgCQ,YAAhC;AAdJ;AAAA;;AAAA;AAgBE,qBAAKb,YAAL,GAAoB,IAApB;;AAhBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAmBA,uBACEK,WADF,EAEEQ,YAFF,EAGE;AACA,WAAK,IAAIP,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,WAAW,CAACF,MAAhC,EAAwCG,CAAC,EAAzC,EAA6C;AAC3C,YAAMG,UAAU,GAAGJ,WAAW,CAACC,CAAD,CAA9B;;AACA,YAAIG,UAAU,IAAI,WAAWI,YAAY,CAACP,CAAD,CAAzC,EAA8C;AAC5C,eAAKS,OAAL,CAAaN,UAAb,IAA4BI,YAAY,CAACP,CAAD,CAAb,CAAoDU,KAA/E;AACD;AACF;AACF;;;EA5E+DC,Y","sourcesContent":["import {Queue} from './queue';\nimport process from 'process';\n\n/** Memory limit size is based on testing */\nconst MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n writePromise: Promise<string>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n async enqueue(val: T) {\n super.enqueue(val);\n /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */\n if (process.memoryUsage().rss > MEMORY_LIMIT) {\n await this.startWrite();\n }\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (this.writePromise) {\n await this.writePromise;\n this.writePromise = null;\n return;\n }\n this.writePromise = this.doWrite();\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n promises.push(writePromise);\n }\n const writeResults = await Promise.allSettled(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n this.writePromise = null;\n }\n\n private updateFileMap(\n archiveKeys: (string | undefined)[],\n writeResults: PromiseSettledResult<string>[]\n ) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (archiveKey && 'value' in writeResults[i]) {\n this.fileMap[archiveKey] = (writeResults[i] as PromiseFulfilledResult<string>).value;\n }\n }\n }\n}\n"],"file":"write-queue.js"}
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _geoid = require("@math.gl/geoid");
15
15
 
16
- var VERSION = typeof "3.2.6" !== 'undefined' ? "3.2.6" : 'latest';
16
+ var VERSION = typeof "3.3.0-alpha.2" !== 'undefined' ? "3.3.0-alpha.2" : 'latest';
17
17
  var PGMLoader = {
18
18
  name: 'PGM - Netpbm grayscale image format',
19
19
  id: 'pgm',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/pgm-loader.ts"],"names":["VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"mappings":";;;;;;;;;;;;;AAMA;;AAFA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAOO,IAAMC,SAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,qCADmC;AAEzCC,EAAAA,EAAE,EAAE,KAFqC;AAGzCC,EAAAA,MAAM,EAAE,gBAHiC;AAIzCC,EAAAA,OAAO,EAAEL,OAJgC;AAKzCM,EAAAA,SAAS,EAAE,CAAC,0BAAD,CAL8B;AAMzCC,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP,EAAoBC,OAApB;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAgC,qBAAS,IAAIC,UAAJ,CAAeF,WAAf,CAAT,EAAsCC,OAAtC,CAAhC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KANoC;AAOzCE,EAAAA,UAAU,EAAE,CAAC,KAAD,CAP6B;AAQzCF,EAAAA,OAAO,EAAE;AAEPG,IAAAA,KAAK,EAAE;AAFA;AARgC,CAApC","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport {parsePGM} from '@math.gl/geoid';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"file":"pgm-loader.js"}
1
+ {"version":3,"sources":["../../src/pgm-loader.ts"],"names":["VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","extensions","cubic"],"mappings":";;;;;;;;;;;;;AAMA;;AAFA,IAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAOO,IAAMC,SAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,qCADmC;AAEzCC,EAAAA,EAAE,EAAE,KAFqC;AAGzCC,EAAAA,MAAM,EAAE,gBAHiC;AAIzCC,EAAAA,OAAO,EAAEL,OAJgC;AAKzCM,EAAAA,SAAS,EAAE,CAAC,0BAAD,CAL8B;AAMzCC,EAAAA,KAAK;AAAA,2EAAE,iBAAOC,WAAP,EAAoBC,OAApB;AAAA;AAAA;AAAA;AAAA;AAAA,+CAAgC,qBAAS,IAAIC,UAAJ,CAAeF,WAAf,CAAT,EAAsCC,OAAtC,CAAhC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAAF;;AAAA;AAAA;AAAA;;AAAA;AAAA,KANoC;AAOzCE,EAAAA,UAAU,EAAE,CAAC,KAAD,CAP6B;AAQzCF,EAAAA,OAAO,EAAE;AAEPG,IAAAA,KAAK,EAAE;AAFA;AARgC,CAApC","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nimport {parsePGM} from '@math.gl/geoid';\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),\n extensions: ['pgm'],\n options: {\n // TODO - use pgm namespace\n cubic: false\n }\n};\n"],"file":"pgm-loader.js"}
@@ -1,5 +1,5 @@
1
1
  import { processOnWorker } from '@loaders.gl/worker-utils';
2
- const VERSION = typeof "3.2.6" !== 'undefined' ? "3.2.6" : 'latest';
2
+ const VERSION = typeof "3.3.0-alpha.2" !== 'undefined' ? "3.3.0-alpha.2" : 'latest';
3
3
  export const Tile3dAttributesWorker = {
4
4
  id: '3d-tiles-attributes',
5
5
  name: '3DTiles Attributes Worker',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/3d-tiles-attributes-worker.ts"],"names":["processOnWorker","VERSION","Tile3dAttributesWorker","id","name","module","version","options","attributes","transform3DTilesAttributesOnWorker","i3sAttributesData","_typecheckI3SAttributesWorker"],"mappings":"AAGA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAeA,OAAO,MAAMC,sBAAsB,GAAG;AACpCC,EAAAA,EAAE,EAAE,qBADgC;AAEpCC,EAAAA,IAAI,EAAE,2BAF8B;AAGpCC,EAAAA,MAAM,EAAE,gBAH4B;AAIpCC,EAAAA,OAAO,EAAEL,OAJ2B;AAKpCM,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AADL;AAL2B,CAA/B;AAaP,OAAO,SAASC,kCAAT,CACLC,iBADK,EAELH,OAFK,EAGiB;AACtB,SAAOP,eAAe,CAACE,sBAAD,EAAyBQ,iBAAzB,EAA4CH,OAA5C,CAAtB;AACD;AAED,OAAO,MAAMI,6BAA2C,GAAGT,sBAApD","sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {FeatureAttribute} from '@loaders.gl/i3s';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type Tile3DAttributesWorkerOptions = {\n featureAttributes: FeatureAttribute | null;\n source: string;\n};\n\nexport type I3SAttributesData = {\n tileContent: any;\n textureFormat: string;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const Tile3dAttributesWorker = {\n id: '3d-tiles-attributes',\n name: '3DTiles Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n attributes: null\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transform3DTilesAttributesOnWorker(\n i3sAttributesData: I3SAttributesData,\n options: Tile3DAttributesWorkerOptions\n): Promise<ArrayBuffer> {\n return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;\n"],"file":"3d-tiles-attributes-worker.js"}
1
+ {"version":3,"sources":["../../src/3d-tiles-attributes-worker.ts"],"names":["processOnWorker","VERSION","Tile3dAttributesWorker","id","name","module","version","options","attributes","transform3DTilesAttributesOnWorker","i3sAttributesData","_typecheckI3SAttributesWorker"],"mappings":"AAGA,SAAQA,eAAR,QAA8B,0BAA9B;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAeA,OAAO,MAAMC,sBAAsB,GAAG;AACpCC,EAAAA,EAAE,EAAE,qBADgC;AAEpCC,EAAAA,IAAI,EAAE,2BAF8B;AAGpCC,EAAAA,MAAM,EAAE,gBAH4B;AAIpCC,EAAAA,OAAO,EAAEL,OAJ2B;AAKpCM,EAAAA,OAAO,EAAE;AACPC,IAAAA,UAAU,EAAE;AADL;AAL2B,CAA/B;AAaP,OAAO,SAASC,kCAAT,CACLC,iBADK,EAELH,OAFK,EAGiB;AACtB,SAAOP,eAAe,CAACE,sBAAD,EAAyBQ,iBAAzB,EAA4CH,OAA5C,CAAtB;AACD;AAED,OAAO,MAAMI,6BAA2C,GAAGT,sBAApD","sourcesContent":["import type {WorkerObject} from '@loaders.gl/worker-utils';\nimport type {FeatureAttribute} from '@loaders.gl/i3s';\n\nimport {processOnWorker} from '@loaders.gl/worker-utils';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type Tile3DAttributesWorkerOptions = {\n featureAttributes: FeatureAttribute | null;\n source: string;\n};\n\nexport type I3SAttributesData = {\n tileContent: any;\n textureFormat: string;\n};\n\n/**\n * I3S Attributes Worker to handle B3DM object\n */\nexport const Tile3dAttributesWorker = {\n id: '3d-tiles-attributes',\n name: '3DTiles Attributes Worker',\n module: 'tile-converter',\n version: VERSION,\n options: {\n attributes: null\n }\n};\n\n/**\n * Performs I3S attributes transformation\n */\nexport function transform3DTilesAttributesOnWorker(\n i3sAttributesData: I3SAttributesData,\n options: Tile3DAttributesWorkerOptions\n): Promise<ArrayBuffer> {\n return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);\n}\n\nexport const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;\n"],"file":"3d-tiles-attributes-worker.js"}