@loaders.gl/tile-converter 3.2.4 → 3.2.7

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/3d-tiles-attributes-worker.js +3 -3
  2. package/dist/3d-tiles-attributes-worker.js.map +1 -1
  3. package/dist/converter.min.js +10 -10
  4. package/dist/dist.min.js +160 -105
  5. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  6. package/dist/es5/i3s-attributes-worker.js +1 -1
  7. package/dist/es5/i3s-converter/helpers/node-pages.js +102 -46
  8. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  9. package/dist/es5/i3s-converter/i3s-converter.js +204 -105
  10. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  11. package/dist/es5/lib/utils/write-queue.js +66 -28
  12. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  13. package/dist/es5/pgm-loader.js +1 -1
  14. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  15. package/dist/esm/i3s-attributes-worker.js +1 -1
  16. package/dist/esm/i3s-converter/helpers/node-pages.js +3 -3
  17. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  18. package/dist/esm/i3s-converter/i3s-converter.js +16 -16
  19. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  20. package/dist/esm/lib/utils/write-queue.js +10 -0
  21. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  22. package/dist/esm/pgm-loader.js +1 -1
  23. package/dist/i3s-attributes-worker.js.map +1 -1
  24. package/dist/i3s-converter/helpers/node-pages.js +3 -3
  25. package/dist/i3s-converter/i3s-converter.js +16 -16
  26. package/dist/lib/utils/write-queue.d.ts +1 -0
  27. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  28. package/dist/lib/utils/write-queue.js +13 -0
  29. package/package.json +15 -15
  30. package/src/i3s-converter/helpers/node-pages.ts +3 -3
  31. package/src/i3s-converter/i3s-converter.ts +16 -16
  32. package/src/lib/utils/write-queue.ts +12 -0
@@ -181,58 +181,114 @@ var NodePages = function () {
181
181
  case 0:
182
182
  slpk = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
183
183
 
184
- if (slpk) {
185
- _iterator = _createForOfIteratorHelper(this.nodePages.entries());
186
-
187
- try {
188
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
189
- _step$value = (0, _slicedToArray2.default)(_step.value, 2), index = _step$value[0], nodePage = _step$value[1];
190
- nodePageStr = JSON.stringify(nodePage);
191
- slpkPath = (0, _path.join)(layers0Path, 'nodepages');
192
- writeQueue.enqueue({
193
- archiveKey: "nodePages/".concat(index.toString(), ".json.gz"),
194
- writePromise: this.writeFile(slpkPath, nodePageStr, "".concat(index.toString(), ".json"))
195
- });
196
- }
197
- } catch (err) {
198
- _iterator.e(err);
199
- } finally {
200
- _iterator.f();
201
- }
202
-
203
- metadata = (0, _jsonMapTransform.default)({
204
- nodeCount: this.nodesCounter
205
- }, (0, _metadata.METADATA)());
206
- compress = false;
207
- writeQueue.enqueue({
208
- archiveKey: 'metadata.json',
209
- writePromise: this.writeFile(layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
210
- });
211
- } else {
212
- _iterator2 = _createForOfIteratorHelper(this.nodePages.entries());
213
-
214
- try {
215
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
216
- _step2$value = (0, _slicedToArray2.default)(_step2.value, 2), _index = _step2$value[0], _nodePage = _step2$value[1];
217
- _nodePageStr = JSON.stringify(_nodePage);
218
- nodePagePath = (0, _path.join)(layers0Path, 'nodepages', _index.toString());
219
- writeQueue.enqueue({
220
- writePromise: this.writeFile(nodePagePath, _nodePageStr)
221
- });
222
- }
223
- } catch (err) {
224
- _iterator2.e(err);
225
- } finally {
226
- _iterator2.f();
227
- }
184
+ if (!slpk) {
185
+ _context.next = 27;
186
+ break;
228
187
  }
229
188
 
230
- case 2:
189
+ _iterator = _createForOfIteratorHelper(this.nodePages.entries());
190
+ _context.prev = 3;
191
+
192
+ _iterator.s();
193
+
194
+ case 5:
195
+ if ((_step = _iterator.n()).done) {
196
+ _context.next = 13;
197
+ break;
198
+ }
199
+
200
+ _step$value = (0, _slicedToArray2.default)(_step.value, 2), index = _step$value[0], nodePage = _step$value[1];
201
+ nodePageStr = JSON.stringify(nodePage);
202
+ slpkPath = (0, _path.join)(layers0Path, 'nodepages');
203
+ _context.next = 11;
204
+ return writeQueue.enqueue({
205
+ archiveKey: "nodePages/".concat(index.toString(), ".json.gz"),
206
+ writePromise: this.writeFile(slpkPath, nodePageStr, "".concat(index.toString(), ".json"))
207
+ });
208
+
209
+ case 11:
210
+ _context.next = 5;
211
+ break;
212
+
213
+ case 13:
214
+ _context.next = 18;
215
+ break;
216
+
217
+ case 15:
218
+ _context.prev = 15;
219
+ _context.t0 = _context["catch"](3);
220
+
221
+ _iterator.e(_context.t0);
222
+
223
+ case 18:
224
+ _context.prev = 18;
225
+
226
+ _iterator.f();
227
+
228
+ return _context.finish(18);
229
+
230
+ case 21:
231
+ metadata = (0, _jsonMapTransform.default)({
232
+ nodeCount: this.nodesCounter
233
+ }, (0, _metadata.METADATA)());
234
+ compress = false;
235
+ _context.next = 25;
236
+ return writeQueue.enqueue({
237
+ archiveKey: 'metadata.json',
238
+ writePromise: this.writeFile(layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
239
+ });
240
+
241
+ case 25:
242
+ _context.next = 46;
243
+ break;
244
+
245
+ case 27:
246
+ _iterator2 = _createForOfIteratorHelper(this.nodePages.entries());
247
+ _context.prev = 28;
248
+
249
+ _iterator2.s();
250
+
251
+ case 30:
252
+ if ((_step2 = _iterator2.n()).done) {
253
+ _context.next = 38;
254
+ break;
255
+ }
256
+
257
+ _step2$value = (0, _slicedToArray2.default)(_step2.value, 2), _index = _step2$value[0], _nodePage = _step2$value[1];
258
+ _nodePageStr = JSON.stringify(_nodePage);
259
+ nodePagePath = (0, _path.join)(layers0Path, 'nodepages', _index.toString());
260
+ _context.next = 36;
261
+ return writeQueue.enqueue({
262
+ writePromise: this.writeFile(nodePagePath, _nodePageStr)
263
+ });
264
+
265
+ case 36:
266
+ _context.next = 30;
267
+ break;
268
+
269
+ case 38:
270
+ _context.next = 43;
271
+ break;
272
+
273
+ case 40:
274
+ _context.prev = 40;
275
+ _context.t1 = _context["catch"](28);
276
+
277
+ _iterator2.e(_context.t1);
278
+
279
+ case 43:
280
+ _context.prev = 43;
281
+
282
+ _iterator2.f();
283
+
284
+ return _context.finish(43);
285
+
286
+ case 46:
231
287
  case "end":
232
288
  return _context.stop();
233
289
  }
234
290
  }
235
- }, _callee, this);
291
+ }, _callee, this, [[3, 15, 18, 21], [28, 40, 43, 46]]);
236
292
  }));
237
293
 
238
294
  function save(_x, _x2) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.ts"],"names":["NodePages","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","func","id","pageIndex","Math","floor","nodeIndex","materialId","node","getNodeById","mesh","material","definition","resource","index","vertexCount","geometry","attribute","featureCount","texelCountHint","parentId","childId","undefined","parentNode","children","push","currentNodePage","length","addChildRelation","updateResourceInMesh","layers0Path","writeQueue","slpk","entries","nodePage","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;;;;;;;IAqCqBA,S;AAYnB,qBAAYC,aAAZ,EAA2BC,YAA3B,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AAEA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;;;WAMD,0BAAiBM,IAAjB,EAAuC;AACrC,WAAKD,SAAL,GAA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,eAHY,EAIZE,QAJY;AAFG,mBAAnB;AASD,iBApBD,MAoBO;AAAA,0DAC2B,KAAK/C,SAAL,CAAemC,OAAf,EAD3B;;AAAA;AACL,2EAA0D;AAAA,oFAA9CnB,MAA8C,oBAAvCoB,SAAuC;AAClDC,sBAAAA,YADkD,GACpCC,IAAI,CAACC,SAAL,CAAeH,SAAf,CADoC;AAElDY,sBAAAA,YAFkD,GAEnC,gBAAKhB,WAAL,EAAkB,WAAlB,EAA+BhB,MAAK,CAAC2B,QAAN,EAA/B,CAFmC;AAGxDV,sBAAAA,UAAU,CAACQ,OAAX,CAAmB;AAACG,wBAAAA,YAAY,EAAE,KAAK1C,SAAL,CAAe8C,YAAf,EAA6BX,YAA7B;AAAf,uBAAnB;AACD;AALI;AAAA;AAAA;AAAA;AAAA;AAMN;;AA/BH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {WriteQueueItem} from '../../lib/utils/write-queue';\n\nimport {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\nimport WriteQueue from '../../lib/utils/write-queue';\n\n// @ts-nocheck\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 readonly nodesPerPage: number;\n nodesCounter: number;\n writeFile: Function;\n readonly nodePages: {nodes: NodeInPage[]}[];\n\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 // @ts-expect-error\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n /**\n * Setup function to save node pages\n * @param func - function which should be used to save node pages\n */\n useWriteFunction(func: Function): void {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param id - end-to-end index of the node\n * @return the node object\n */\n getNodeById(id: number): NodeInPage {\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: number, materialId: number): void {\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: number, vertexCount: number): void {\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: number): void {\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: number, featureCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n /**\n * Update texelCountHint in node.mesh.material object by node id\n * @param id - end-to-end index of the node\n * @param texelCountHint - texelCountHint of particular node\n */\n updateTexelCountHintByNodeId(id: number, texelCountHint: number): void {\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 parentId - end-to-end parent node index\n * @param childId - end-to-end child node index\n */\n addChildRelation(parentId: number | undefined, childId: number): void {\n if (parentId === null || parentId === undefined) {\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 node - node object\n */\n updateResourceInMesh(node: NodeInPage): void {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param node - node object\n * @param parentId - index of parent node\n * @return\n */\n push(node: NodeInPage, parentId?: number): number {\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 layers0Path - path of layer\n * @param writeQueue - write queue that controlls files write concurrency\n * @param slpk\n */\n async save(\n layers0Path: string,\n writeQueue: WriteQueue<WriteQueueItem>,\n slpk: boolean = false\n ): Promise<void> {\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 writeQueue.enqueue({\n archiveKey: `nodePages/${index.toString()}.json.gz`,\n writePromise: this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)\n });\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n writeQueue.enqueue({\n archiveKey: 'metadata.json',\n writePromise: this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n )\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 writeQueue.enqueue({writePromise: this.writeFile(nodePagePath, nodePageStr)});\n }\n }\n }\n}\n"],"file":"node-pages.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.ts"],"names":["NodePages","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","func","id","pageIndex","Math","floor","nodeIndex","materialId","node","getNodeById","mesh","material","definition","resource","index","vertexCount","geometry","attribute","featureCount","texelCountHint","parentId","childId","undefined","parentNode","children","push","currentNodePage","length","addChildRelation","updateResourceInMesh","layers0Path","writeQueue","slpk","entries","nodePage","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;;;;;;;IAqCqBA,S;AAYnB,qBAAYC,aAAZ,EAA2BC,YAA3B,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AAEA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;;;WAMD,0BAAiBM,IAAjB,EAAuC;AACrC,WAAKD,SAAL,GAAiBC,IAAjB;AACD;;;WAOD,qBAAYC,EAAZ,EAAoC;AAClC,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKN,YAArB,CAAlB;AACA,UAAM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JY;AAFS,iBAAnB,CAhBV;;AAAA;AAAA;AAAA;;AAAA;AAAA,wDA0BoC,KAAK/C,SAAL,CAAemC,OAAf,EA1BpC;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,8EA0BgBnB,MA1BhB,oBA0BuBoB,SA1BvB;AA2BYC,gBAAAA,YA3BZ,GA2B0BC,IAAI,CAACC,SAAL,CAAeH,SAAf,CA3B1B;AA4BYY,gBAAAA,YA5BZ,GA4B2B,gBAAKhB,WAAL,EAAkB,WAAlB,EAA+BhB,MAAK,CAAC2B,QAAN,EAA/B,CA5B3B;AAAA;AAAA,uBA6BYV,UAAU,CAACQ,OAAX,CAAmB;AAACG,kBAAAA,YAAY,EAAE,KAAK1C,SAAL,CAAe8C,YAAf,EAA6BX,YAA7B;AAAf,iBAAnB,CA7BZ;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O","sourcesContent":["import type {WriteQueueItem} from '../../lib/utils/write-queue';\n\nimport {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\nimport WriteQueue from '../../lib/utils/write-queue';\n\n// @ts-nocheck\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 readonly nodesPerPage: number;\n nodesCounter: number;\n writeFile: Function;\n readonly nodePages: {nodes: NodeInPage[]}[];\n\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 // @ts-expect-error\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n /**\n * Setup function to save node pages\n * @param func - function which should be used to save node pages\n */\n useWriteFunction(func: Function): void {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param id - end-to-end index of the node\n * @return the node object\n */\n getNodeById(id: number): NodeInPage {\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: number, materialId: number): void {\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: number, vertexCount: number): void {\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: number): void {\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: number, featureCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n /**\n * Update texelCountHint in node.mesh.material object by node id\n * @param id - end-to-end index of the node\n * @param texelCountHint - texelCountHint of particular node\n */\n updateTexelCountHintByNodeId(id: number, texelCountHint: number): void {\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 parentId - end-to-end parent node index\n * @param childId - end-to-end child node index\n */\n addChildRelation(parentId: number | undefined, childId: number): void {\n if (parentId === null || parentId === undefined) {\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 node - node object\n */\n updateResourceInMesh(node: NodeInPage): void {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param node - node object\n * @param parentId - index of parent node\n * @return\n */\n push(node: NodeInPage, parentId?: number): number {\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 layers0Path - path of layer\n * @param writeQueue - write queue that controlls files write concurrency\n * @param slpk\n */\n async save(\n layers0Path: string,\n writeQueue: WriteQueue<WriteQueueItem>,\n slpk: boolean = false\n ): Promise<void> {\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 await writeQueue.enqueue({\n archiveKey: `nodePages/${index.toString()}.json.gz`,\n writePromise: this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)\n });\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n await writeQueue.enqueue({\n archiveKey: 'metadata.json',\n writePromise: this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n )\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 await writeQueue.enqueue({writePromise: this.writeFile(nodePagePath, nodePageStr)});\n }\n }\n }\n}\n"],"file":"node-pages.js"}
@@ -405,7 +405,7 @@ var I3SConverter = function () {
405
405
 
406
406
  case 2:
407
407
  if (!this.isContentSupported(sourceRootTile)) {
408
- _context3.next = 14;
408
+ _context3.next = 20;
409
409
  break;
410
410
  }
411
411
 
@@ -423,22 +423,33 @@ var I3SConverter = function () {
423
423
  child = _yield$this$_createNo2[0];
424
424
  childPath = (0, _path.join)(this.layers0Path, 'nodes', child.path);
425
425
 
426
- if (this.options.slpk) {
427
- this.writeQueue.enqueue({
428
- archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
429
- writePromise: (0, _fileUtils.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
430
- });
431
- } else {
432
- this.writeQueue.enqueue({
433
- writePromise: (0, _fileUtils.writeFile)(childPath, JSON.stringify(child))
434
- });
426
+ if (!this.options.slpk) {
427
+ _context3.next = 16;
428
+ break;
435
429
  }
436
430
 
437
- _context3.next = 16;
438
- break;
431
+ _context3.next = 14;
432
+ return this.writeQueue.enqueue({
433
+ archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
434
+ writePromise: (0, _fileUtils.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
435
+ });
439
436
 
440
437
  case 14:
441
- _context3.next = 16;
438
+ _context3.next = 18;
439
+ break;
440
+
441
+ case 16:
442
+ _context3.next = 18;
443
+ return this.writeQueue.enqueue({
444
+ writePromise: (0, _fileUtils.writeFile)(childPath, JSON.stringify(child))
445
+ });
446
+
447
+ case 18:
448
+ _context3.next = 22;
449
+ break;
450
+
451
+ case 20:
452
+ _context3.next = 22;
442
453
  return this._addChildrenWithNeighborsAndWriteFile({
443
454
  parentNode: root0,
444
455
  sourceTiles: sourceRootTile.children,
@@ -446,11 +457,11 @@ var I3SConverter = function () {
446
457
  level: 1
447
458
  });
448
459
 
449
- case 16:
450
- _context3.next = 18;
460
+ case 22:
461
+ _context3.next = 24;
451
462
  return sourceRootTile.unloadContent();
452
463
 
453
- case 18:
464
+ case 24:
454
465
  case "end":
455
466
  return _context3.stop();
456
467
  }
@@ -472,18 +483,28 @@ var I3SConverter = function () {
472
483
  while (1) {
473
484
  switch (_context4.prev = _context4.next) {
474
485
  case 0:
475
- if (this.options.slpk) {
476
- this.writeQueue.enqueue({
477
- archiveKey: '3dSceneLayer.json.gz',
478
- writePromise: (0, _fileUtils.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
479
- });
480
- } else {
481
- this.writeQueue.enqueue({
482
- writePromise: (0, _fileUtils.writeFile)(this.layers0Path, JSON.stringify(this.layers0))
483
- });
486
+ if (!this.options.slpk) {
487
+ _context4.next = 5;
488
+ break;
484
489
  }
485
490
 
486
- case 1:
491
+ _context4.next = 3;
492
+ return this.writeQueue.enqueue({
493
+ archiveKey: '3dSceneLayer.json.gz',
494
+ writePromise: (0, _fileUtils.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
495
+ });
496
+
497
+ case 3:
498
+ _context4.next = 7;
499
+ break;
500
+
501
+ case 5:
502
+ _context4.next = 7;
503
+ return this.writeQueue.enqueue({
504
+ writePromise: (0, _fileUtils.writeFile)(this.layers0Path, JSON.stringify(this.layers0))
505
+ });
506
+
507
+ case 7:
487
508
  case "end":
488
509
  return _context4.stop();
489
510
  }
@@ -505,18 +526,28 @@ var I3SConverter = function () {
505
526
  while (1) {
506
527
  switch (_context5.prev = _context5.next) {
507
528
  case 0:
508
- if (this.options.slpk) {
509
- this.writeQueue.enqueue({
510
- archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
511
- writePromise: (0, _fileUtils.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
512
- });
513
- } else {
514
- this.writeQueue.enqueue({
515
- writePromise: (0, _fileUtils.writeFile)(rootPath, JSON.stringify(root0))
516
- });
529
+ if (!this.options.slpk) {
530
+ _context5.next = 5;
531
+ break;
517
532
  }
518
533
 
519
- case 1:
534
+ _context5.next = 3;
535
+ return this.writeQueue.enqueue({
536
+ archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
537
+ writePromise: (0, _fileUtils.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
538
+ });
539
+
540
+ case 3:
541
+ _context5.next = 7;
542
+ break;
543
+
544
+ case 5:
545
+ _context5.next = 7;
546
+ return this.writeQueue.enqueue({
547
+ writePromise: (0, _fileUtils.writeFile)(rootPath, JSON.stringify(root0))
548
+ });
549
+
550
+ case 7:
520
551
  case "end":
521
552
  return _context5.stop();
522
553
  }
@@ -1218,35 +1249,59 @@ var I3SConverter = function () {
1218
1249
  while (1) {
1219
1250
  switch (_context13.prev = _context13.next) {
1220
1251
  case 0:
1221
- if (this.options.slpk) {
1222
- slpkGeometryPath = (0, _path.join)(childPath, 'geometries');
1223
- this.writeQueue.enqueue({
1224
- archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
1225
- writePromise: (0, _fileUtils.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin')
1226
- });
1227
- } else {
1228
- geometryPath = (0, _path.join)(childPath, 'geometries/0/');
1229
- this.writeQueue.enqueue({
1230
- writePromise: (0, _fileUtils.writeFile)(geometryPath, geometryBuffer, 'index.bin')
1231
- });
1252
+ if (!this.options.slpk) {
1253
+ _context13.next = 6;
1254
+ break;
1232
1255
  }
1233
1256
 
1234
- if (this.options.draco) {
1235
- if (this.options.slpk) {
1236
- slpkCompressedGeometryPath = (0, _path.join)(childPath, 'geometries');
1237
- this.writeQueue.enqueue({
1238
- archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
1239
- writePromise: (0, _fileUtils.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
1240
- });
1241
- } else {
1242
- compressedGeometryPath = (0, _path.join)(childPath, 'geometries/1/');
1243
- this.writeQueue.enqueue({
1244
- writePromise: (0, _fileUtils.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin')
1245
- });
1246
- }
1257
+ slpkGeometryPath = (0, _path.join)(childPath, 'geometries');
1258
+ _context13.next = 4;
1259
+ return this.writeQueue.enqueue({
1260
+ archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
1261
+ writePromise: (0, _fileUtils.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin')
1262
+ });
1263
+
1264
+ case 4:
1265
+ _context13.next = 9;
1266
+ break;
1267
+
1268
+ case 6:
1269
+ geometryPath = (0, _path.join)(childPath, 'geometries/0/');
1270
+ _context13.next = 9;
1271
+ return this.writeQueue.enqueue({
1272
+ writePromise: (0, _fileUtils.writeFile)(geometryPath, geometryBuffer, 'index.bin')
1273
+ });
1274
+
1275
+ case 9:
1276
+ if (!this.options.draco) {
1277
+ _context13.next = 19;
1278
+ break;
1247
1279
  }
1248
1280
 
1249
- case 2:
1281
+ if (!this.options.slpk) {
1282
+ _context13.next = 16;
1283
+ break;
1284
+ }
1285
+
1286
+ slpkCompressedGeometryPath = (0, _path.join)(childPath, 'geometries');
1287
+ _context13.next = 14;
1288
+ return this.writeQueue.enqueue({
1289
+ archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
1290
+ writePromise: (0, _fileUtils.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
1291
+ });
1292
+
1293
+ case 14:
1294
+ _context13.next = 19;
1295
+ break;
1296
+
1297
+ case 16:
1298
+ compressedGeometryPath = (0, _path.join)(childPath, 'geometries/1/');
1299
+ _context13.next = 19;
1300
+ return this.writeQueue.enqueue({
1301
+ writePromise: (0, _fileUtils.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin')
1302
+ });
1303
+
1304
+ case 19:
1250
1305
  case "end":
1251
1306
  return _context13.stop();
1252
1307
  }
@@ -1281,20 +1336,30 @@ var I3SConverter = function () {
1281
1336
  sharedData = (0, _jsonMapTransform.default)(sharedResources, (0, _sharedResources.SHARED_RESOURCES)());
1282
1337
  sharedDataStr = JSON.stringify(sharedData);
1283
1338
 
1284
- if (this.options.slpk) {
1285
- slpkSharedPath = (0, _path.join)(childPath, 'shared');
1286
- this.writeQueue.enqueue({
1287
- archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
1288
- writePromise: (0, _fileUtils.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json')
1289
- });
1290
- } else {
1291
- sharedPath = (0, _path.join)(childPath, 'shared/');
1292
- this.writeQueue.enqueue({
1293
- writePromise: (0, _fileUtils.writeFile)(sharedPath, sharedDataStr)
1294
- });
1339
+ if (!this.options.slpk) {
1340
+ _context14.next = 11;
1341
+ break;
1295
1342
  }
1296
1343
 
1297
- case 6:
1344
+ slpkSharedPath = (0, _path.join)(childPath, 'shared');
1345
+ _context14.next = 9;
1346
+ return this.writeQueue.enqueue({
1347
+ archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
1348
+ writePromise: (0, _fileUtils.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json')
1349
+ });
1350
+
1351
+ case 9:
1352
+ _context14.next = 14;
1353
+ break;
1354
+
1355
+ case 11:
1356
+ sharedPath = (0, _path.join)(childPath, 'shared/');
1357
+ _context14.next = 14;
1358
+ return this.writeQueue.enqueue({
1359
+ writePromise: (0, _fileUtils.writeFile)(sharedPath, sharedDataStr)
1360
+ });
1361
+
1362
+ case 14:
1298
1363
  case "end":
1299
1364
  return _context14.stop();
1300
1365
  }
@@ -1410,21 +1475,31 @@ var I3SConverter = function () {
1410
1475
  while (1) {
1411
1476
  switch (_context16.prev = _context16.next) {
1412
1477
  case 0:
1413
- if (this.options.slpk) {
1414
- slpkTexturePath = (0, _path.join)(childPath, 'textures');
1415
- compress = false;
1416
- this.writeQueue.enqueue({
1417
- archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
1418
- writePromise: (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
1419
- });
1420
- } else {
1421
- texturePath = (0, _path.join)(childPath, "textures/".concat(name, "/"));
1422
- this.writeQueue.enqueue({
1423
- writePromise: (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format))
1424
- });
1478
+ if (!this.options.slpk) {
1479
+ _context16.next = 7;
1480
+ break;
1425
1481
  }
1426
1482
 
1427
- case 1:
1483
+ slpkTexturePath = (0, _path.join)(childPath, 'textures');
1484
+ compress = false;
1485
+ _context16.next = 5;
1486
+ return this.writeQueue.enqueue({
1487
+ archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
1488
+ writePromise: (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
1489
+ });
1490
+
1491
+ case 5:
1492
+ _context16.next = 10;
1493
+ break;
1494
+
1495
+ case 7:
1496
+ texturePath = (0, _path.join)(childPath, "textures/".concat(name, "/"));
1497
+ _context16.next = 10;
1498
+ return this.writeQueue.enqueue({
1499
+ writePromise: (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format))
1500
+ });
1501
+
1502
+ case 10:
1428
1503
  case "end":
1429
1504
  return _context16.stop();
1430
1505
  }
@@ -1461,27 +1536,51 @@ var I3SConverter = function () {
1461
1536
  childPath = _args17.length > 1 ? _args17[1] : undefined;
1462
1537
  slpkChildPath = _args17.length > 2 ? _args17[2] : undefined;
1463
1538
 
1464
- if (attributes !== null && attributes !== void 0 && attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
1465
- for (index = 0; index < attributes.length; index++) {
1466
- folderName = this.layers0.attributeStorageInfo[index].key;
1467
- fileBuffer = new Uint8Array(attributes[index]);
1468
-
1469
- if (this.options.slpk) {
1470
- slpkAttributesPath = (0, _path.join)(childPath, 'attributes', folderName);
1471
- this.writeQueue.enqueue({
1472
- archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
1473
- writePromise: (0, _fileUtils.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin')
1474
- });
1475
- } else {
1476
- attributesPath = (0, _path.join)(childPath, "attributes/".concat(folderName, "/0"));
1477
- this.writeQueue.enqueue({
1478
- writePromise: (0, _fileUtils.writeFile)(attributesPath, fileBuffer, 'index.bin')
1479
- });
1480
- }
1481
- }
1539
+ if (!(attributes !== null && attributes !== void 0 && attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length)) {
1540
+ _context17.next = 20;
1541
+ break;
1482
1542
  }
1483
1543
 
1484
- case 4:
1544
+ index = 0;
1545
+
1546
+ case 5:
1547
+ if (!(index < attributes.length)) {
1548
+ _context17.next = 20;
1549
+ break;
1550
+ }
1551
+
1552
+ folderName = this.layers0.attributeStorageInfo[index].key;
1553
+ fileBuffer = new Uint8Array(attributes[index]);
1554
+
1555
+ if (!this.options.slpk) {
1556
+ _context17.next = 14;
1557
+ break;
1558
+ }
1559
+
1560
+ slpkAttributesPath = (0, _path.join)(childPath, 'attributes', folderName);
1561
+ _context17.next = 12;
1562
+ return this.writeQueue.enqueue({
1563
+ archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
1564
+ writePromise: (0, _fileUtils.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin')
1565
+ });
1566
+
1567
+ case 12:
1568
+ _context17.next = 17;
1569
+ break;
1570
+
1571
+ case 14:
1572
+ attributesPath = (0, _path.join)(childPath, "attributes/".concat(folderName, "/0"));
1573
+ _context17.next = 17;
1574
+ return this.writeQueue.enqueue({
1575
+ writePromise: (0, _fileUtils.writeFile)(attributesPath, fileBuffer, 'index.bin')
1576
+ });
1577
+
1578
+ case 17:
1579
+ index++;
1580
+ _context17.next = 5;
1581
+ break;
1582
+
1583
+ case 20:
1485
1584
  case "end":
1486
1585
  return _context17.stop();
1487
1586
  }