@loaders.gl/tile-converter 4.0.4 → 4.0.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAGpB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAcrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAIhE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrD,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IAC3C,aAAa,EAAE,gBAAgB,CAQ7B;;IAaF;;;;;;;;OAQG;IACU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC;IAqDhB;;;;;;OAMG;YACW,gBAAgB;IAyD9B;;;;;OAKG;YACW,YAAY;IAe1B;;;;;OAKG;YACW,cAAc;IA2B5B;;;;OAIG;IACH,OA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;;OAKG;YACW,cAAc;IA2B5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;CAgBhC"}
@@ -28,6 +28,7 @@ export default class Tiles3DConverter {
28
28
  this.loaderOptions = {
29
29
  _nodeWorkers: true,
30
30
  reuseWorkers: true,
31
+ worker: false,
31
32
  i3s: {
32
33
  coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS,
33
34
  decodeTextures: false
@@ -144,11 +145,9 @@ export default class Tiles3DConverter {
144
145
  if (this.options.maxDepth && level > this.options.maxDepth) {
145
146
  return;
146
147
  }
147
- const promises = [];
148
148
  for (const childNodeInfo of parentSourceNode.children || []) {
149
- promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
149
+ await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);
150
150
  }
151
- await Promise.all(promises);
152
151
  }
153
152
  async _loadChildNode(parentNode, childNodeInfo) {
154
153
  var _this$sourceTileset2;
@@ -1 +1 @@
1
- {"version":3,"file":"3d-tiles-converter.js","names":["join","process","transform","load","isBrowser","I3SLoader","I3SAttributeLoader","COORDINATE_SYSTEM","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","createObbFromMbs","WorkerFarm","BROWSER_ERROR_MESSAGE","B3dmConverter","loadI3SContent","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","loaderOptions","_nodeWorkers","reuseWorkers","i3s","coordinateSystem","LNGLAT_OFFSETS","decodeTextures","workerUrl","convert","_this$sourceTileset","console","log","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","hrtime","rootNode","root","obb","mbs","e","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","getWorkerFarm","destroy","convertChildNode","parentSourceNode","parentNode","level","childNodeInfo","sourceChild","_loadChildNode","contentUrl","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","b3dmConverter","b3dm","uri","id","Uint8Array","push","promises","Promise","all","_this$sourceTileset2","header","nodePagesTile","formTileFromNodePages","parseInt","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","baseUrl","arguments","length","undefined","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","attributeUrls","index","attribute","attributeName","name","attributeType","_getAttributeType","attributesList","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime"],"sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"sourcesContent":["import type {\n AttributeStorageInfo,\n FeatureAttribute,\n NodeReference,\n I3STilesetHeader\n} from '@loaders.gl/i3s';\nimport type {Tiles3DTileJSON} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {load, isBrowser} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport B3dmConverter, {I3SAttributesData} from './helpers/b3dm-converter';\nimport {I3STileHeader} from '@loaders.gl/i3s/src/types';\nimport {loadI3SContent} from './helpers/load-i3s';\nimport {I3SLoaderOptions} from '@loaders.gl/i3s/src/i3s-loader';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: I3STilesetHeader | null;\n attributeStorageInfo?: AttributeStorageInfo[] | null;\n workerSource: {[key: string]: string} = {};\n loaderOptions: I3SLoaderOptions = {\n _nodeWorkers: true,\n reuseWorkers: true,\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false},\n // We need to load local fs workers because nodejs can't load workers from the Internet\n 'i3s-content': {\n workerUrl: './modules/i3s/dist/i3s-content-worker-node.js'\n }\n };\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\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.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n }): Promise<any> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\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 this.sourceTileset = await load(inputUrl, I3SLoader, this.loaderOptions);\n\n if (!this.sourceTileset) {\n return;\n }\n\n const rootNode = this.sourceTileset?.root;\n if (!rootNode.obb) {\n rootNode.obb = createObbFromMbs(rootNode.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = this.sourceTileset.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Tiles3DTileJSON = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * Convert particular I3S Node\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n * @param childNodeInfo child node to convert\n */\n private async convertChildNode(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number,\n childNodeInfo: NodeReference\n ): Promise<void> {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n if (sourceChild.contentUrl) {\n const content = await loadI3SContent(this.sourceTileset, sourceChild, this.loaderOptions);\n\n if (!content) {\n await this._addChildren(sourceChild, parentNode, level + 1);\n return;\n }\n\n this.vertexCounter += content?.vertexCount || 0;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);\n }\n\n if (!sourceChild.obb) {\n sourceChild.obb = createObbFromMbs(sourceChild.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)\n };\n const child: Tiles3DTileJSON = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: content,\n box: boundingVolume.box,\n textureFormat: sourceChild.textureFormat\n };\n\n const b3dmConverter = new B3dmConverter();\n const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n const promises: Promise<void>[] = [];\n for (const childNodeInfo of parentSourceNode.children || []) {\n promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));\n }\n await Promise.all(promises);\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(\n parentNode: I3STileHeader,\n childNodeInfo: NodeReference\n ): Promise<I3STileHeader> {\n let header;\n if (this.sourceTileset?.nodePagesTile) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(\n parseInt(childNodeInfo.id)\n );\n } else {\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.loaderOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, I3SLoader, options);\n }\n return header;\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string = '', relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: I3STileHeader,\n attributeStorageInfo: AttributeStorageInfo[]\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls = []} = sourceChild;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\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 filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n}\n"],"mappings":"AAQA,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAO,iBAAiB;AAAC,SAGzEC,SAAS;AAAA,SACTC,kBAAkB;AAAA,SAClBC,sCAAsC;AAAA,SACtCC,SAAS,EAAEC,SAAS;AAAA,SACpBC,kBAAkB,EAAEC,aAAa;AAAA,SACjCC,OAAO,IAAIC,eAAe;AAAA,SAC1BC,gBAAgB;AACxB,SAAQC,UAAU,QAAO,0BAA0B;AAAC,SAC5CC,qBAAqB;AAAA,OACtBC,aAAa;AAAA,SAEZC,cAAc;AAGtB,MAAMC,GAAG,GAAG,KAAK;AAKjB,eAAe,MAAMC,gBAAgB,CAAC;EAmBpCC,WAA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AIA,SAAS,CAACS,eAAe,EAAE;MAC7B,OAAOT,SAAS,CAACS,eAAe,CAACC,SAAS;IAC5C,CAAC,MAAM,IAAIV,SAAS,CAACW,SAAS,EAAE;MAC9B,OAAO,OAAO;IAChB;IACA,OAAO,EAAE;EACX;EAMQL,oBAAoBA,CAACD,cAAkC,EAAQ;IACrE,KAAK,IAAIN,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGM,cAAc,CAACf,MAAM,EAAES,KAAK,EAAE,EAAE;MAC1D,MAAMa,eAAe,GAAGP,cAAc,CAACN,KAAK,CAAC;MAE7C,KAAK,MAAMc,GAAG,IAAID,eAAe,EAAE;QACjCA,eAAe,CAACC,GAAG,CAAC,GAAGC,KAAK,CAACC,IAAI,CAACH,eAAe,CAACC,GAAG,CAAC,CAAC;MACzD;IACF;EACF;EAMA,MAAclE,iBAAiBA,CAACqE,MAI/B,EAAiB;IAChB,MAAMC,SAAS,GAAG,MAAM1H,kBAAkB,CAACyH,MAAM,CAAC;IAClD,MAAME,IAAI,GAAGvI,OAAO,CAACiD,MAAM,CAAC,IAAI,CAACtB,mBAAmB,CAAC;IACrD,MAAM6G,cAAc,GAAG3H,aAAa,CAAC0H,IAAI,CAAC;IAE1C7F,OAAO,CAACC,GAAG,CAAE,kDAAiD,CAAC;IAC/DD,OAAO,CAACC,GAAG,CAAE,wBAAuBtB,GAAI,EAAC,CAAC;IAC1CqB,OAAO,CAACC,GAAG,CAAE,0BAAyB6F,cAAe,EAAC,CAAC;IACvD9F,OAAO,CAACC,GAAG,CAAE,gBAAe,EAAE,IAAI,CAACjB,aAAa,CAAC;IACjDgB,OAAO,CAACC,GAAG,CAAE,gBAAe,EAAE2F,SAAS,EAAE,QAAQ,CAAC;IAClD5F,OAAO,CAACC,GAAG,CAAE,kDAAiD,CAAC;EACjE;AACF"}
1
+ {"version":3,"file":"3d-tiles-converter.js","names":["join","process","transform","load","isBrowser","I3SLoader","I3SAttributeLoader","COORDINATE_SYSTEM","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","createObbFromMbs","WorkerFarm","BROWSER_ERROR_MESSAGE","B3dmConverter","loadI3SContent","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","loaderOptions","_nodeWorkers","reuseWorkers","worker","i3s","coordinateSystem","LNGLAT_OFFSETS","decodeTextures","workerUrl","convert","_this$sourceTileset","console","log","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","hrtime","rootNode","root","obb","mbs","e","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","workerFarm","getWorkerFarm","destroy","convertChildNode","parentSourceNode","parentNode","level","childNodeInfo","sourceChild","_loadChildNode","contentUrl","content","vertexCount","featureAttributes","_loadChildAttributes","child","i3sAttributesData","tileContent","textureFormat","b3dmConverter","b3dm","uri","id","Uint8Array","push","_this$sourceTileset2","header","nodePagesTile","formTileFromNodePages","parseInt","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","baseUrl","arguments","length","undefined","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","promises","attributeUrls","index","attribute","attributeName","name","attributeType","_getAttributeType","attributesList","Promise","all","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime"],"sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"sourcesContent":["import type {\n AttributeStorageInfo,\n FeatureAttribute,\n NodeReference,\n I3STilesetHeader\n} from '@loaders.gl/i3s';\nimport type {Tiles3DTileJSON} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {load, isBrowser} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport B3dmConverter, {I3SAttributesData} from './helpers/b3dm-converter';\nimport {I3STileHeader} from '@loaders.gl/i3s/src/types';\nimport {loadI3SContent} from './helpers/load-i3s';\nimport {I3SLoaderOptions} from '@loaders.gl/i3s/src/i3s-loader';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: I3STilesetHeader | null;\n attributeStorageInfo?: AttributeStorageInfo[] | null;\n workerSource: {[key: string]: string} = {};\n loaderOptions: I3SLoaderOptions = {\n _nodeWorkers: true,\n reuseWorkers: true,\n // TODO: converter freezes in the end because of i3s-content-worker\n worker: false,\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false},\n // We need to load local fs workers because nodejs can't load workers from the Internet\n 'i3s-content': {\n workerUrl: './modules/i3s/dist/i3s-content-worker-node.js'\n }\n };\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n }\n\n /**\n * Convert i3s format data to 3dTiles\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.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n }): Promise<any> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\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 this.sourceTileset = await load(inputUrl, I3SLoader, this.loaderOptions);\n\n if (!this.sourceTileset) {\n return;\n }\n\n const rootNode = this.sourceTileset?.root;\n if (!rootNode.obb) {\n rootNode.obb = createObbFromMbs(rootNode.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = this.sourceTileset.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Tiles3DTileJSON = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: []\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * Convert particular I3S Node\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n * @param childNodeInfo child node to convert\n */\n private async convertChildNode(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number,\n childNodeInfo: NodeReference\n ): Promise<void> {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n if (sourceChild.contentUrl) {\n const content = await loadI3SContent(this.sourceTileset, sourceChild, this.loaderOptions);\n\n if (!content) {\n await this._addChildren(sourceChild, parentNode, level + 1);\n return;\n }\n\n this.vertexCounter += content?.vertexCount || 0;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);\n }\n\n if (!sourceChild.obb) {\n sourceChild.obb = createObbFromMbs(sourceChild.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)\n };\n const child: Tiles3DTileJSON = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: content,\n box: boundingVolume.box,\n textureFormat: sourceChild.textureFormat\n };\n\n const b3dmConverter = new B3dmConverter();\n const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);\n\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.children || []) {\n await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(\n parentNode: I3STileHeader,\n childNodeInfo: NodeReference\n ): Promise<I3STileHeader> {\n let header;\n if (this.sourceTileset?.nodePagesTile) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(\n parseInt(childNodeInfo.id)\n );\n } else {\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options = {\n i3s: {\n ...this.loaderOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, I3SLoader, options);\n }\n return header;\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string = '', relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: I3STileHeader,\n attributeStorageInfo: AttributeStorageInfo[]\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls = []} = sourceChild;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\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 filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n}\n"],"mappings":"AAQA,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,EAAEC,kBAAkB,EAAE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9F,OAAO,CAACC,GAAG,CAAE,gBAAe,EAAE,IAAI,CAAClB,aAAa,CAAC;IACjDiB,OAAO,CAACC,GAAG,CAAE,gBAAe,EAAE2F,SAAS,EAAE,QAAQ,CAAC;IAClD5F,OAAO,CAACC,GAAG,CAAE,kDAAiD,CAAC;EACjE;AACF"}
@@ -57,7 +57,7 @@ async function convert(options) {
57
57
  switch (inputType) {
58
58
  case TILESET_TYPE.I3S:
59
59
  const tiles3DConverter = new Tiles3DConverter();
60
- tiles3DConverter.convert({
60
+ await tiles3DConverter.convert({
61
61
  inputUrl: options.tileset,
62
62
  outputPath: options.output,
63
63
  tilesetName: options.name,
@@ -1 +1 @@
1
- {"version":3,"file":"converter-cli.js","names":["join","inquirer","I3SConverter","Tiles3DConverter","DepsInstaller","getBooleanValue","getIntegerValue","getStringValue","getURLValue","validateOptionsWithEqual","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","installDependencies","depthInstaller","install","validatedOptions","validateOptions","convert","catch","error","console","log","exit","inputType","toUpperCase","tiles3DConverter","inputUrl","tileset","outputPath","output","tilesetName","name","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","metadataClass","analyze","mandatoryOptionsWithExceptions","getMessage","condition","value","Boolean","Object","values","includes","exceptions","mandatoryOption","optionValue","conditionFunc","testValue","push","forEach","exeption","opts","cwd","arg","index","indexOf","warn"],"sources":["../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport inquirer from 'inquirer';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\nimport {\n getBooleanValue,\n getIntegerValue,\n getStringValue,\n getURLValue,\n validateOptionsWithEqual\n} from './lib/utils/cli-utils';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */\n metadataClass?: string;\n /** With this options the tileset content will be analyzed without conversion */\n analyze?: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');\n console.log('--analyze [Analyze the input tileset content without conversion, default: false]');\n console.log(\n '--metadata-class [One of the list of feature metadata classes, detected by converter on \"analyze\" stage, default: not set]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting,\n metadataClass: options.metadataClass,\n analyze: options.analyze,\n inquirer\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: {\n getMessage: () => void;\n condition?: (optionValue: any) => boolean;\n };\n } = {\n name: {\n getMessage: () => console.log('Missed: --name [Tileset name]'),\n condition: (value: any) => Boolean(value) || Boolean(options.analyze)\n },\n output: {getMessage: () => console.log('Missed: --output [Output path name]')},\n sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},\n egm: {getMessage: () => console.log('Missed: --egm [*.pgm earth gravity model file path]')},\n tileset: {getMessage: () => console.log('Missed: --tileset [tileset.json file]')},\n inputType: {\n getMessage: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),\n condition: (value) =>\n Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase())\n }\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n\n const conditionFunc = mandatoryOptionsWithExceptions[mandatoryOption].condition;\n const testValue = conditionFunc ? conditionFunc(optionValue) : optionValue;\n\n if (!testValue) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption].getMessage);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--analyze':\n opts.analyze = getBooleanValue(index, args);\n break;\n case '--metadata-class':\n opts.metadataClass = getStringValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AAAC,SAClEC,aAAa;AAAA,SAEnBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,wBAAwB;AAyD1B,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,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9D,IAAI,CAAC;UAC9C;QACF,KAAK,OAAO;UACV2D,IAAI,CAAC7B,GAAG,GAAGrC,cAAc,CAACqE,KAAK,EAAE9D,IAAI,CAAC;UACtC;QACF,KAAK,SAAS;UACZ2D,IAAI,CAACzB,KAAK,GAAGzC,cAAc,CAACqE,KAAK,EAAE9D,IAAI,CAAC;UACxC;QACF,KAAK,YAAY;UACf2D,IAAI,CAACxB,KAAK,GAAG5C,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UACzC;QACF,KAAK,YAAY;UACf2D,IAAI,CAACpB,QAAQ,GAAGhD,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UAC5C;QACF,KAAK,wBAAwB;UAC3B2D,IAAI,CAACnD,mBAAmB,GAAGjB,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UACvD;QACF,KAAK,qBAAqB;UACxB2D,IAAI,CAACtB,gBAAgB,GAAG9C,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UACpD;QACF,KAAK,6BAA6B;UAChC2D,IAAI,CAACrB,uBAAuB,GAAG/C,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UAC3D;QACF,KAAK,WAAW;UACd2D,IAAI,CAACjB,OAAO,GAAGnD,eAAe,CAACuE,KAAK,EAAE9D,IAAI,CAAC;UAC3C;QACF,KAAK,kBAAkB;UACrB2D,IAAI,CAAClB,aAAa,GAAGhD,cAAc,CAACqE,KAAK,EAAE9D,IAAI,CAAC;UAChD;QACF,KAAK,QAAQ;UACXI,SAAS,CAAC,CAAC;UACX;QACF;UACEY,OAAO,CAACgD,IAAI,CAAE,kBAAiBH,GAAI,EAAC,CAAC;UACrC5D,OAAO,CAACiB,IAAI,CAAC,CAAC,CAAC;MACnB;IACF;EACF,CAAC,CAAC;EACF,OAAOyC,IAAI;AACb"}
1
+ {"version":3,"file":"converter-cli.js","names":["join","inquirer","I3SConverter","Tiles3DConverter","DepsInstaller","getBooleanValue","getIntegerValue","getStringValue","getURLValue","validateOptionsWithEqual","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","installDependencies","depthInstaller","install","validatedOptions","validateOptions","convert","catch","error","console","log","exit","inputType","toUpperCase","tiles3DConverter","inputUrl","tileset","outputPath","output","tilesetName","name","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","metadataClass","analyze","mandatoryOptionsWithExceptions","getMessage","condition","value","Boolean","Object","values","includes","exceptions","mandatoryOption","optionValue","conditionFunc","testValue","push","forEach","exeption","opts","cwd","arg","index","indexOf","warn"],"sources":["../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport inquirer from 'inquirer';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\nimport {\n getBooleanValue,\n getIntegerValue,\n getStringValue,\n getURLValue,\n validateOptionsWithEqual\n} from './lib/utils/cli-utils';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n /** Feature metadata class from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA extensions */\n metadataClass?: string;\n /** With this options the tileset content will be analyzed without conversion */\n analyze?: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log('--generate-bounding-volumes [Generate obb and mbs bounding volumes from geometry]');\n console.log('--analyze [Analyze the input tileset content without conversion, default: false]');\n console.log(\n '--metadata-class [One of the list of feature metadata classes, detected by converter on \"analyze\" stage, default: not set]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n await tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting,\n metadataClass: options.metadataClass,\n analyze: options.analyze,\n inquirer\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: {\n getMessage: () => void;\n condition?: (optionValue: any) => boolean;\n };\n } = {\n name: {\n getMessage: () => console.log('Missed: --name [Tileset name]'),\n condition: (value: any) => Boolean(value) || Boolean(options.analyze)\n },\n output: {getMessage: () => console.log('Missed: --output [Output path name]')},\n sevenZipExe: {getMessage: () => console.log('Missed: --7zExe [7z archiver executable path]')},\n egm: {getMessage: () => console.log('Missed: --egm [*.pgm earth gravity model file path]')},\n tileset: {getMessage: () => console.log('Missed: --tileset [tileset.json file]')},\n inputType: {\n getMessage: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]'),\n condition: (value) =>\n Boolean(value) && Object.values(TILESET_TYPE).includes(value.toUpperCase())\n }\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n\n const conditionFunc = mandatoryOptionsWithExceptions[mandatoryOption].condition;\n const testValue = conditionFunc ? conditionFunc(optionValue) : optionValue;\n\n if (!testValue) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption].getMessage);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--analyze':\n opts.analyze = getBooleanValue(index, args);\n break;\n case '--metadata-class':\n opts.metadataClass = getStringValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,QAAQ,MAAM,UAAU;AAC/B,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AAAC,SAClEC,aAAa;AAAA,SAEnBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,wBAAwB;AAyD1B,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE;AACZ,CAAC;AAMD,eAAeC,IAAIA,CAAA,EAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IACrBC,SAAS,CAAC,CAAC;EACb;EAEA,MAAMC,mBAAmB,GAAGV,wBAAwB,CAACK,IAAI,CAAC;EAE1D,MAAMM,OAA8B,GAAGC,YAAY,CAACF,mBAAmB,CAAC;EAExE,IAAIC,OAAO,CAACE,mBAAmB,EAAE;IAC/B,MAAMC,cAAc,GAAG,IAAInB,aAAa,CAAC,CAAC;IAC1CmB,cAAc,CAACC,OAAO,CAAC,MAAM,CAAC;IAC9B;EACF;EAEA,MAAMC,gBAAgD,GAAGC,eAAe,C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