@loaders.gl/tile-converter 3.0.10 → 3.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/dist.es5.min.js +14 -14
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +14 -14
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/i3s-converter/i3s-converter.js +27 -16
  6. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  7. package/dist/es5/pgm-loader.js +1 -1
  8. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +11 -11
  9. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  10. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +1 -1
  11. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  12. package/dist/esm/i3s-converter/helpers/geometry-converter.js +2 -2
  13. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  14. package/dist/esm/i3s-converter/helpers/node-debug.js +2 -2
  15. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
  16. package/dist/esm/i3s-converter/helpers/node-pages.js +2 -2
  17. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  18. package/dist/esm/i3s-converter/i3s-converter.js +36 -28
  19. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  20. package/dist/esm/i3s-converter/json-templates/shared-resources.js +2 -2
  21. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  22. package/dist/esm/i3s-server/controllers/index-controller.js +1 -1
  23. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  24. package/dist/esm/lib/utils/compress-util.js +13 -13
  25. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  26. package/dist/esm/lib/utils/file-utils.js +1 -1
  27. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  28. package/dist/esm/lib/utils/statistic-utills.js +5 -5
  29. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  30. package/dist/esm/pgm-loader.js +1 -1
  31. package/package.json +14 -14
  32. package/src/i3s-converter/i3s-converter.ts +10 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.js"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","toString","metadata","nodeCount","compress","nodePagePath","Promise","all"],"mappings":"AAAA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAkCA,eAAe,MAAMC,SAAN,CAAgB;AAO7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AACA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;AAEDM,EAAAA,gBAAgB,CAACC,IAAD,EAAO;AACrB,SAAKF,SAAL,GAAiBE,IAAjB;AACD;;AAODC,EAAAA,WAAW,CAACC,EAAD,EAAK;AACd,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKR,YAArB,CAAlB;AACA,UAAMY,SAA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,EAAc,WAAd,EAA2BpB,KAAK,CAAC8B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,CAACR,IAAT,CAAc,KAAK/B,SAAL,CAAekD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AA1K4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\n\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n useWriteFunction(func) {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param {number} id - end-to-end index of the node\n * @return {object} the node object\n */\n getNodeById(id) {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id, materialId) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id, vertexCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id, featureCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n updateTexelCountHintByNodeId(id, texelCountHint) {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param {number | null} parentId - end-to-end parent node index\n * @param {number} childId - end-to-end child node index\n * @return {void}\n */\n addChildRelation(parentId, childId) {\n if (parentId === null) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param {object} node - node object\n * @return {void}\n */\n updateResourceInMesh(node) {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param {object} node - node object\n * @param {number | null} parentId - index of parent node\n * @return {number}\n */\n push(node, parentId = null) {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path, fileMap, slpk = false) {\n const promises = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate);\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.js"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath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,EAAzC,WAAd;AACAT,QAAAA,OAAO,qBAAcrB,KAAK,CAAC8B,QAAN,EAAd,cAAP,aAAsDD,QAAtD;AACD;;AACD,YAAME,QAAQ,GAAGzD,SAAS,CAAC;AAAC0D,QAAAA,SAAS,EAAE,KAAKnD;AAAjB,OAAD,EAAiCL,gBAAjC,CAA1B;AACA,YAAMyD,QAAQ,GAAG,KAAjB;AACAZ,MAAAA,OAAO,CAAC,eAAD,CAAP,GAA2B,MAAM,KAAKrC,SAAL,CAC/BoC,WAD+B,EAE/BO,IAAI,CAACC,SAAL,CAAeG,QAAf,CAF+B,EAG/B,eAH+B,EAI/BE,QAJ+B,CAAjC;AAMD,KAfD,MAeO;AACL,WAAK,MAAM,CAACjC,KAAD,EAAQwB,QAAR,CAAX,IAAgC,KAAK1C,SAAL,CAAe2C,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMU,YAAY,GAAG7D,IAAI,CAAC+C,WAAD,EAAc,WAAd,EAA2BpB,KAAK,CAAC8B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,CAACR,IAAT,CAAc,KAAK/B,SAAL,CAAekD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AA1K4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\n\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n useWriteFunction(func) {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param {number} id - end-to-end index of the node\n * @return {object} the node object\n */\n getNodeById(id) {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id, materialId) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id, vertexCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id, featureCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n updateTexelCountHintByNodeId(id, texelCountHint) {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param {number | null} parentId - end-to-end parent node index\n * @param {number} childId - end-to-end child node index\n * @return {void}\n */\n addChildRelation(parentId, childId) {\n if (parentId === null) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param {object} node - node object\n * @return {void}\n */\n updateResourceInMesh(node) {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param {object} node - node object\n * @param {number | null} parentId - index of parent node\n * @return {number}\n */\n push(node, parentId = null) {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path, fileMap, slpk = false) {\n const promises = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate);\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import { load } from '@loaders.gl/core';
3
3
  import { Tileset3D } from '@loaders.gl/tiles';
4
- import { CesiumIonLoader } from '@loaders.gl/3d-tiles';
4
+ import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
5
5
  import { join } from 'path';
6
6
  import { v4 as uuidv4 } from 'uuid';
7
7
  import process from 'process';
@@ -29,6 +29,7 @@ const SHORT_INT_TYPE = 'Int32';
29
29
  const DOUBLE_TYPE = 'double';
30
30
  const OBJECT_ID_TYPE = 'OBJECTID';
31
31
  const REFRESH_TOKEN_TIMEOUT = 1800;
32
+ const CESIUM_DATASET_PREFIX = 'https://';
32
33
  export default class I3SConverter {
33
34
  constructor() {
34
35
  _defineProperty(this, "nodePages", void 0);
@@ -63,6 +64,8 @@ export default class I3SConverter {
63
64
 
64
65
  _defineProperty(this, "geoidHeightModel", void 0);
65
66
 
67
+ _defineProperty(this, "Loader", Tiles3DLoader);
68
+
66
69
  this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
67
70
  this.fileMap = {};
68
71
  this.options = {};
@@ -104,6 +107,7 @@ export default class I3SConverter {
104
107
  inputUrl
105
108
  };
106
109
  this.validate = validate;
110
+ this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
107
111
  console.log('Loading egm file...');
108
112
  this.geoidHeightModel = await load(egmFilePath, PGMLoader);
109
113
  console.log('Loading egm file completed!');
@@ -124,7 +128,7 @@ export default class I3SConverter {
124
128
  }
125
129
 
126
130
  Object.assign(tilesetOptions, preloadOptions);
127
- const sourceTilesetJson = await load(inputUrl, CesiumIonLoader, tilesetOptions.loadOptions);
131
+ const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
128
132
  this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
129
133
  await this._createAndSaveTileset(outputPath, tilesetName);
130
134
  await this._finishConversion({
@@ -136,7 +140,7 @@ export default class I3SConverter {
136
140
  }
137
141
 
138
142
  async _createAndSaveTileset(outputPath, tilesetName) {
139
- const tilesetPath = join(`${outputPath}`, `${tilesetName}`);
143
+ const tilesetPath = join("".concat(outputPath), "".concat(tilesetName));
140
144
 
141
145
  try {
142
146
  await removeDir(tilesetPath);
@@ -171,12 +175,12 @@ export default class I3SConverter {
171
175
  _formLayers0(tilesetName) {
172
176
  const extent = convertCommonToI3SExtentCoordinate(this.sourceTileset);
173
177
  const layers0data = {
174
- version: `{${uuidv4().toUpperCase()}}`,
178
+ version: "{".concat(uuidv4().toUpperCase(), "}"),
175
179
  id: 0,
176
180
  name: tilesetName,
177
181
  href: './layers/0',
178
182
  store: {
179
- id: `{${uuidv4().toUpperCase()}}`,
183
+ id: "{".concat(uuidv4().toUpperCase(), "}"),
180
184
  extent
181
185
  },
182
186
  nodePages: {
@@ -189,7 +193,7 @@ export default class I3SConverter {
189
193
 
190
194
  _formRootNodeIndexDocument(boundingVolumes) {
191
195
  const root0data = {
192
- version: `{${uuidv4().toUpperCase()}}`,
196
+ version: "{".concat(uuidv4().toUpperCase(), "}"),
193
197
  id: 'root',
194
198
  level: 0,
195
199
  lodSelection: [{
@@ -244,7 +248,7 @@ export default class I3SConverter {
244
248
 
245
249
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
246
250
  if (this.options.slpk) {
247
- this.fileMap[`nodes/${nodePath}/3dNodeIndexDocument.json.gz`] = await writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
251
+ this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = await writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
248
252
  } else {
249
253
  await writeFile(rootPath, JSON.stringify(root0));
250
254
  }
@@ -253,7 +257,7 @@ export default class I3SConverter {
253
257
  async _createSlpk(tilesetPath) {
254
258
  if (this.options.slpk) {
255
259
  const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');
256
- const slpkFileName = `${tilesetPath}.slpk`;
260
+ const slpkFileName = "".concat(tilesetPath, ".slpk");
257
261
  await compressWithChildProcess(slpkTilesetPath, slpkFileName, 0, '.', this.options.sevenZipExe);
258
262
 
259
263
  try {
@@ -301,7 +305,7 @@ export default class I3SConverter {
301
305
  for (const child of children) {
302
306
  parentNode.children.push({
303
307
  id: child.id,
304
- href: `../${child.path}`,
308
+ href: "../".concat(child.path),
305
309
  ...boundingVolumes
306
310
  });
307
311
  childNodes.push(child);
@@ -330,7 +334,7 @@ export default class I3SConverter {
330
334
  });
331
335
  }
332
336
  } else {
333
- console.warn(`Node ${node.id}: neighbors attribute is omited because of large number of neigbors`);
337
+ console.warn("Node ".concat(node.id, ": neighbors attribute is omited because of large number of neigbors"));
334
338
  delete node.neighbors;
335
339
  }
336
340
 
@@ -483,7 +487,7 @@ export default class I3SConverter {
483
487
  lodSelection,
484
488
  parentNode: {
485
489
  id: parentNode.id,
486
- href: `../${parentNode.id}`,
490
+ href: "../".concat(parentNode.id),
487
491
  mbs: parentNode.mbs,
488
492
  obb: parentNode.obb
489
493
  },
@@ -512,7 +516,7 @@ export default class I3SConverter {
512
516
  for (let index = 0; index < attributes.length; index++) {
513
517
  const folderName = this.layers0.attributeStorageInfo[index].key;
514
518
  node.attributeData.push({
515
- href: `./attributes/${folderName}/0`
519
+ href: "./attributes/".concat(folderName, "/0")
516
520
  });
517
521
  }
518
522
  }
@@ -540,7 +544,7 @@ export default class I3SConverter {
540
544
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
541
545
  if (this.options.slpk) {
542
546
  const slpkGeometryPath = join(childPath, 'geometries');
543
- this.fileMap[`${slpkChildPath}/geometries/0.bin.gz`] = await writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin');
547
+ this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = await writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin');
544
548
  } else {
545
549
  const geometryPath = join(childPath, 'geometries/0/');
546
550
  await writeFile(geometryPath, geometryBuffer, 'index.bin');
@@ -549,7 +553,7 @@ export default class I3SConverter {
549
553
  if (this.options.draco) {
550
554
  if (this.options.slpk) {
551
555
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
552
- this.fileMap[`${slpkChildPath}/geometries/1.bin.gz`] = await writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
556
+ this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = await writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
553
557
  } else {
554
558
  const compressedGeometryPath = join(childPath, 'geometries/1/');
555
559
  await writeFile(compressedGeometryPath, compressedGeometry, 'index.bin');
@@ -564,7 +568,7 @@ export default class I3SConverter {
564
568
 
565
569
  if (this.options.slpk) {
566
570
  const slpkSharedPath = join(childPath, 'shared');
567
- this.fileMap[`${slpkChildPath}/shared/sharedResource.json.gz`] = await writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json');
571
+ this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = await writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json');
568
572
  } else {
569
573
  const sharedPath = join(childPath, 'shared/');
570
574
  await writeFile(sharedPath, sharedDataStr);
@@ -589,10 +593,10 @@ export default class I3SConverter {
589
593
  if (this.options.slpk) {
590
594
  const slpkTexturePath = join(childPath, 'textures');
591
595
  const compress = false;
592
- this.fileMap[`${slpkChildPath}/textures/0.${format}`] = await writeFileForSlpk(slpkTexturePath, textureData, `0.${format}`, compress);
596
+ this.fileMap["".concat(slpkChildPath, "/textures/0.").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "0.".concat(format), compress);
593
597
  } else {
594
598
  const texturePath = join(childPath, 'textures/0/');
595
- await writeFile(texturePath, textureData, `index.${format}`);
599
+ await writeFile(texturePath, textureData, "index.".concat(format));
596
600
  }
597
601
  }
598
602
  }
@@ -605,9 +609,9 @@ export default class I3SConverter {
605
609
 
606
610
  if (this.options.slpk) {
607
611
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
608
- this.fileMap[`${slpkChildPath}/attributes/${folderName}.bin.gz`] = await writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin');
612
+ this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = await writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin');
609
613
  } else {
610
- const attributesPath = join(childPath, `attributes/${folderName}/0`);
614
+ const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
611
615
  await writeFile(attributesPath, fileBuffer, 'index.bin');
612
616
  }
613
617
  }
@@ -641,7 +645,7 @@ export default class I3SConverter {
641
645
 
642
646
  _createdStorageAttribute(attributeIndex, key, attributeType) {
643
647
  const storageAttribute = {
644
- key: `f_${attributeIndex}`,
648
+ key: "f_".concat(attributeIndex),
645
649
  name: key,
646
650
  ordering: ['attributeValues'],
647
651
  header: [{
@@ -818,22 +822,26 @@ export default class I3SConverter {
818
822
  const filesSize = await calculateFilesSize(params);
819
823
  const diff = process.hrtime(this.conversionStartTime);
820
824
  const conversionTime = timeConverter(diff);
821
- console.log(`------------------------------------------------`);
822
- console.log(`Finishing conversion of ${_3D_TILES}`);
823
- console.log(`Total conversion time: ${conversionTime}`);
824
- console.log(`Vertex count: `, this.vertexCounter);
825
- console.log(`File(s) size: `, filesSize, ' bytes');
826
- console.log(`Percentage of tiles with "ADD" refinement type:`, addRefinementPercentage, '%');
827
- console.log(`------------------------------------------------`);
825
+ console.log("------------------------------------------------");
826
+ console.log("Finishing conversion of ".concat(_3D_TILES));
827
+ console.log("Total conversion time: ".concat(conversionTime));
828
+ console.log("Vertex count: ", this.vertexCounter);
829
+ console.log("File(s) size: ", filesSize, ' bytes');
830
+ console.log("Percentage of tiles with \"ADD\" refinement type:", addRefinementPercentage, '%');
831
+ console.log("------------------------------------------------");
828
832
  }
829
833
 
830
834
  async _fetchPreloadOptions() {
835
+ if (!this.Loader.preload) {
836
+ return {};
837
+ }
838
+
831
839
  const options = {
832
840
  'cesium-ion': {
833
841
  accessToken: this.options.token || ION_DEFAULT_TOKEN
834
842
  }
835
843
  };
836
- const preloadOptions = await CesiumIonLoader.preload(this.options.inputUrl, options);
844
+ const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
837
845
  this.refreshTokenTime = process.hrtime();
838
846
  return { ...options,
839
847
  ...preloadOptions