@loaders.gl/tile-converter 3.1.4 → 3.1.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.
package/dist/dist.min.js CHANGED
@@ -85099,12 +85099,13 @@ var I3SConverter = class {
85099
85099
  }
85100
85100
  }
85101
85101
  async writeTextureFile(textureData, name8, format, childPath, slpkChildPath) {
85102
- const texturePath = (0, import_path7.join)(childPath, `textures/${name8}/`);
85103
- await writeFile3(texturePath, textureData, `index.${format}`);
85104
85102
  if (this.options.slpk) {
85105
85103
  const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
85106
85104
  const compress = false;
85107
85105
  this.fileMap[`${slpkChildPath}/textures/${name8}.${format}`] = await writeFileForSlpk(slpkTexturePath, textureData, `${name8}.${format}`, compress);
85106
+ } else {
85107
+ const texturePath = (0, import_path7.join)(childPath, `textures/${name8}/`);
85108
+ await writeFile3(texturePath, textureData, `index.${format}`);
85108
85109
  }
85109
85110
  }
85110
85111
  async _writeAttributes(attributes, childPath, slpkChildPath) {
@@ -86068,7 +86069,13 @@ async function normalizeTilesetData(tileset, options, context) {
86068
86069
  } else {
86069
86070
  const rootNodeUrl = getUrlWithToken(`${tileset.url}/nodes/root`, options.i3s?.token);
86070
86071
  tileset.root = await load(rootNodeUrl, tileset.loader, {
86071
- i3s: { loadContent: false, isTileHeader: true, isTileset: false }
86072
+ ...options,
86073
+ i3s: {
86074
+ ...options.i3s,
86075
+ loadContent: false,
86076
+ isTileHeader: true,
86077
+ isTileset: false
86078
+ }
86072
86079
  });
86073
86080
  }
86074
86081
  tileset.basePath = tileset.url;
@@ -1389,30 +1389,32 @@ var I3SConverter = function () {
1389
1389
  key: "writeTextureFile",
1390
1390
  value: function () {
1391
1391
  var _writeTextureFile = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee16(textureData, name, format, childPath, slpkChildPath) {
1392
- var texturePath, slpkTexturePath, compress;
1392
+ var slpkTexturePath, compress, texturePath;
1393
1393
  return _regenerator.default.wrap(function _callee16$(_context16) {
1394
1394
  while (1) {
1395
1395
  switch (_context16.prev = _context16.next) {
1396
1396
  case 0:
1397
- texturePath = (0, _path.join)(childPath, "textures/".concat(name, "/"));
1398
- _context16.next = 3;
1399
- return (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format));
1400
-
1401
- case 3:
1402
1397
  if (!this.options.slpk) {
1403
- _context16.next = 9;
1398
+ _context16.next = 8;
1404
1399
  break;
1405
1400
  }
1406
1401
 
1407
1402
  slpkTexturePath = (0, _path.join)(childPath, 'textures');
1408
1403
  compress = false;
1409
- _context16.next = 8;
1404
+ _context16.next = 5;
1410
1405
  return (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
1411
1406
 
1412
- case 8:
1407
+ case 5:
1413
1408
  this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = _context16.sent;
1409
+ _context16.next = 11;
1410
+ break;
1414
1411
 
1415
- case 9:
1412
+ case 8:
1413
+ texturePath = (0, _path.join)(childPath, "textures/".concat(name, "/"));
1414
+ _context16.next = 11;
1415
+ return (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format));
1416
+
1417
+ case 11:
1416
1418
  case "end":
1417
1419
  return _context16.stop();
1418
1420
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/i3s-converter/i3s-converter.ts"],"names":["ION_DEFAULT_TOKEN","process","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","nodePages","NodePages","writeFile","fileMap","options","layers0Path","materialMap","Map","materialDefinitions","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","conversionStartTime","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","sevenZipExe","maxDepth","token","Boolean","Loader","indexOf","CesiumIonLoader","console","log","PGMLoader","geoidHeightModel","useWriteFunction","writeFileForSlpk","_fetchPreloadOptions","preloadOptions","tilesetOptions","loadOptions","basis","format","headers","fetch","Object","assign","sourceTilesetJson","sourceTileset","Tileset3D","_createAndSaveTileset","_finishConversion","tilesetPath","_formLayers0","sourceRootTile","root","boundingVolumes","parentId","push","index","lodThreshold","obb","children","isCreateSlpk","root0","_formRootNodeIndexDocument","_convertNodesTree","_writeLayers0","_writeNodeIndexDocument","save","_createSlpk","extent","layers0data","version","toUpperCase","id","name","href","store","nodesPerPage","compressGeometry","root0data","level","lodSelection","metricType","maxError","_loadTile","isContentSupported","_createNode","child","childPath","path","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","definition","resource","attribute","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","Uint8Array","KTX2BasisUniversalTextureWriter","ktx2TextureData","ImageWriter","decodedFromKTX2TextureData","textureSetDefinitions","texturePath","slpkTexturePath","compress","fileBuffer","slpkAttributesPath","attributesPath","hash","has","get","newMaterialId","set","attributeIndex","attributeType","storageAttribute","ordering","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAGA;;;;;;;;;;;;AAIA,IAAMA,iBAAiB,GACrBC,iBAAQC,GAAR,CAAYC,QAAZ,IACA,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;AAwBnB,0BAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,CAAuBE,uBAAvB,IAAkD,CAAlD;AACAmB,QAAAA,OAAO,CAACmF,IAAR,CAAa,yCAAb;AACD;;AAED,WAAKxG,iBAAL,CAAuBC,UAAvB,IAAqC,CAArC;AACD;;;WAMD,4BAA2B2C,cAA3B,EAA4D;AAAA;;AAC1D,aAAO,CAAC,MAAD,EAAS,MAAT,EAAiB4M,QAAjB,CAA0B5M,cAA1B,aAA0BA,cAA1B,gDAA0BA,cAAc,CAAEiE,OAA1C,0DAA0B,sBAAyBZ,IAAnD,CAAP;AACD","sourcesContent":["import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';\nimport type {BatchTableJson, B3DMContent} from '@loaders.gl/3d-tiles';\n\nimport type {\n AttributeStorageInfo,\n SceneLayer3D,\n BoundingVolumes,\n Node3DIndexDocument,\n NodeReference,\n MaxScreenThresholdSQ,\n NodeInPage,\n LodSelection,\n SharedResources,\n Attribute,\n ESRIField,\n Field,\n PopupInfo,\n FieldInfo\n} from '@loaders.gl/i3s';\nimport {load, encode} 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 convertCommonToI3SExtentCoordinate\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 {KTX2BasisUniversalTextureWriter} 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} from './types';\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 fileMap: {[key: string]: string};\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\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n this.fileMap = {};\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 }\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 /** @deprecated */\n inputType?: string;\n }): Promise<any> {\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 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 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 }\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 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.fileMap, isCreateSlpk);\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 extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);\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 };\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 this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(\n childPath,\n JSON.stringify(child),\n '3dNodeIndexDocument.json'\n );\n } else {\n await 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 this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(\n this.layers0Path,\n JSON.stringify(this.layers0),\n '3dSceneLayer.json'\n );\n } else {\n await writeFile(this.layers0Path, JSON.stringify(this.layers0));\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 this.fileMap[`nodes/${nodePath}/3dNodeIndexDocument.json.gz`] = await writeFileForSlpk(\n rootPath,\n JSON.stringify(root0),\n '3dNodeIndexDocument.json'\n );\n } else {\n await 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 // @ts-expect-error\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 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 );\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: ArrayBuffer,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/0.bin.gz`] = await writeFileForSlpk(\n slpkGeometryPath,\n geometryBuffer,\n '0.bin'\n );\n } else {\n const geometryPath = join(childPath, 'geometries/0/');\n await writeFile(geometryPath, geometryBuffer, 'index.bin');\n }\n\n if (this.options.draco) {\n if (this.options.slpk) {\n const slpkCompressedGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/1.bin.gz`] = await writeFileForSlpk(\n slpkCompressedGeometryPath,\n compressedGeometry,\n '1.bin'\n );\n } else {\n const compressedGeometryPath = join(childPath, 'geometries/1/');\n await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');\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: SharedResources,\n childPath: string,\n slpkChildPath: string,\n nodePath: string\n ): Promise<void> {\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 this.fileMap[`${slpkChildPath}/shared/sharedResource.json.gz`] = await writeFileForSlpk(\n slpkSharedPath,\n sharedDataStr,\n 'sharedResource.json'\n );\n } else {\n const sharedPath = join(childPath, 'shared/');\n await 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 = new Uint8Array(\n await encode(texture.image, KTX2BasisUniversalTextureWriter)\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 = new Uint8Array(\n await encode(texture.image!.data[0], ImageWriter)\n );\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: ArrayBuffer,\n name: string,\n format: 'jpg' | 'png' | 'ktx2',\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n const texturePath = join(childPath, `textures/${name}/`);\n await writeFile(texturePath, textureData, `index.${format}`);\n\n if (this.options.slpk) {\n const slpkTexturePath = join(childPath, 'textures');\n const compress = false;\n\n this.fileMap[`${slpkChildPath}/textures/${name}.${format}`] = await writeFileForSlpk(\n slpkTexturePath,\n textureData,\n `${name}.${format}`,\n compress\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[],\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 this.fileMap[`${slpkChildPath}/attributes/${folderName}.bin.gz`] = await writeFileForSlpk(\n slpkAttributesPath,\n fileBuffer,\n '0.bin'\n );\n } else {\n const attributesPath = join(childPath, `attributes/${folderName}/0`);\n await writeFile(attributesPath, fileBuffer, 'index.bin');\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"],"file":"i3s-converter.js"}
1
+ {"version":3,"sources":["../../../src/i3s-converter/i3s-converter.ts"],"names":["ION_DEFAULT_TOKEN","process","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","nodePages","NodePages","writeFile","fileMap","options","layers0Path","materialMap","Map","materialDefinitions","vertexCounter","layers0","featuresHashArray","refinementCounter","tilesCount","tilesWithAddRefineCount","validate","generateTextures","generateBoundingVolumes","conversionStartTime","hrtime","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","sevenZipExe","maxDepth","token","Boolean","Loader","indexOf","CesiumIonLoader","console","log","PGMLoader","geoidHeightModel","useWriteFunction","writeFileForSlpk","_fetchPreloadOptions","preloadOptions","tilesetOptions","loadOptions","basis","format","headers","fetch","Object","assign","sourceTilesetJson","sourceTileset","Tileset3D","_createAndSaveTileset","_finishConversion","tilesetPath","_formLayers0","sourceRootTile","root","boundingVolumes","parentId","push","index","lodThreshold","obb","children","isCreateSlpk","root0","_formRootNodeIndexDocument","_convertNodesTree","_writeLayers0","_writeNodeIndexDocument","save","_createSlpk","extent","layers0data","version","toUpperCase","id","name","href","store","nodesPerPage","compressGeometry","root0data","level","lodSelection","metricType","maxError","_loadTile","isContentSupported","_createNode","child","childPath","path","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","definition","resource","attribute","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","Uint8Array","KTX2BasisUniversalTextureWriter","ktx2TextureData","ImageWriter","decodedFromKTX2TextureData","textureSetDefinitions","slpkTexturePath","compress","texturePath","fileBuffer","slpkAttributesPath","attributesPath","hash","has","get","newMaterialId","set","attributeIndex","attributeType","storageAttribute","ordering","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmBA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAGA;;;;;;;;;;;;AAIA,IAAMA,iBAAiB,GACrBC,iBAAQC,GAAR,CAAYC,QAAZ,IACA,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;AAwBnB,0BAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kEATsB,EAStB;AAAA,+DAR0B,CAAC,CAAD,EAAI,CAAJ,CAQ1B;AAAA,4DAPuB,CAAC,CAAD,EAAI,CAAJ,CAOvB;AAAA,yDANoB,IAMpB;AAAA,4DALmB,IAKnB;AAAA,kDAJaC,qBAIb;AAAA;AAAA;AACZ,SAAKC,SAAL,GAAiB,IAAIC,kBAAJ,CAAcC,oBAA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cAA1B,aAA0BA,cAA1B,gDAA0BA,cAAc,CAAEiE,OAA1C,0DAA0B,sBAAyBZ,IAAnD,CAAP;AACD","sourcesContent":["import type {Tile3D, Tileset3DProps} from '@loaders.gl/tiles';\nimport type {BatchTableJson, B3DMContent} from '@loaders.gl/3d-tiles';\n\nimport type {\n AttributeStorageInfo,\n SceneLayer3D,\n BoundingVolumes,\n Node3DIndexDocument,\n NodeReference,\n MaxScreenThresholdSQ,\n NodeInPage,\n LodSelection,\n SharedResources,\n Attribute,\n ESRIField,\n Field,\n PopupInfo,\n FieldInfo\n} from '@loaders.gl/i3s';\nimport {load, encode} 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 convertCommonToI3SExtentCoordinate\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 {KTX2BasisUniversalTextureWriter} 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} from './types';\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 fileMap: {[key: string]: string};\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\n constructor() {\n this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n this.fileMap = {};\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 }\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 /** @deprecated */\n inputType?: string;\n }): Promise<any> {\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 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 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 }\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 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.fileMap, isCreateSlpk);\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 extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);\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 };\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 this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await writeFileForSlpk(\n childPath,\n JSON.stringify(child),\n '3dNodeIndexDocument.json'\n );\n } else {\n await 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 this.fileMap['3dSceneLayer.json.gz'] = await writeFileForSlpk(\n this.layers0Path,\n JSON.stringify(this.layers0),\n '3dSceneLayer.json'\n );\n } else {\n await writeFile(this.layers0Path, JSON.stringify(this.layers0));\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 this.fileMap[`nodes/${nodePath}/3dNodeIndexDocument.json.gz`] = await writeFileForSlpk(\n rootPath,\n JSON.stringify(root0),\n '3dNodeIndexDocument.json'\n );\n } else {\n await 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 // @ts-expect-error\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 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 );\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: ArrayBuffer,\n childPath: string,\n slpkChildPath: string\n ): Promise<void> {\n if (this.options.slpk) {\n const slpkGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/0.bin.gz`] = await writeFileForSlpk(\n slpkGeometryPath,\n geometryBuffer,\n '0.bin'\n );\n } else {\n const geometryPath = join(childPath, 'geometries/0/');\n await writeFile(geometryPath, geometryBuffer, 'index.bin');\n }\n\n if (this.options.draco) {\n if (this.options.slpk) {\n const slpkCompressedGeometryPath = join(childPath, 'geometries');\n this.fileMap[`${slpkChildPath}/geometries/1.bin.gz`] = await writeFileForSlpk(\n slpkCompressedGeometryPath,\n compressedGeometry,\n '1.bin'\n );\n } else {\n const compressedGeometryPath = join(childPath, 'geometries/1/');\n await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');\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: SharedResources,\n childPath: string,\n slpkChildPath: string,\n nodePath: string\n ): Promise<void> {\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 this.fileMap[`${slpkChildPath}/shared/sharedResource.json.gz`] = await writeFileForSlpk(\n slpkSharedPath,\n sharedDataStr,\n 'sharedResource.json'\n );\n } else {\n const sharedPath = join(childPath, 'shared/');\n await 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 = new Uint8Array(\n await encode(texture.image, KTX2BasisUniversalTextureWriter)\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 = new Uint8Array(\n await encode(texture.image!.data[0], ImageWriter)\n );\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: 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 this.fileMap[`${slpkChildPath}/textures/${name}.${format}`] = await writeFileForSlpk(\n slpkTexturePath,\n textureData,\n `${name}.${format}`,\n compress\n );\n } else {\n const texturePath = join(childPath, `textures/${name}/`);\n await writeFile(texturePath, textureData, `index.${format}`);\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[],\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 this.fileMap[`${slpkChildPath}/attributes/${folderName}.bin.gz`] = await writeFileForSlpk(\n slpkAttributesPath,\n fileBuffer,\n '0.bin'\n );\n } else {\n const attributesPath = join(childPath, `attributes/${folderName}/0`);\n await writeFile(attributesPath, fileBuffer, 'index.bin');\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"],"file":"i3s-converter.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.1.4" !== 'undefined' ? "3.1.4" : 'latest';
16
+ var VERSION = typeof "3.1.5" !== 'undefined' ? "3.1.5" : 'latest';
17
17
  var PGMLoader = {
18
18
  name: 'PGM - Netpbm grayscale image format',
19
19
  id: 'pgm',
@@ -676,13 +676,13 @@ export default class I3SConverter {
676
676
  }
677
677
 
678
678
  async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
679
- const texturePath = join(childPath, "textures/".concat(name, "/"));
680
- await writeFile(texturePath, textureData, "index.".concat(format));
681
-
682
679
  if (this.options.slpk) {
683
680
  const slpkTexturePath = join(childPath, 'textures');
684
681
  const compress = false;
685
682
  this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
683
+ } else {
684
+ const texturePath = join(childPath, "textures/".concat(name, "/"));
685
+ await writeFile(texturePath, textureData, "index.".concat(format));
686
686
  }
687
687
  }
688
688