@loaders.gl/tile-converter 3.2.5 → 3.2.8

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 +161 -106
  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
@@ -17,6 +17,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
17
17
 
18
18
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
19
 
20
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
+
20
22
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
23
 
22
24
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -27,10 +29,14 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
27
29
 
28
30
  var _queue = require("./queue");
29
31
 
32
+ var _process = _interopRequireDefault(require("process"));
33
+
30
34
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
31
35
 
32
36
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
37
 
38
+ var MEMORY_LIMIT = 4 * 1024 * 1024 * 1024;
39
+
34
40
  var WriteQueue = function (_Queue) {
35
41
  (0, _inherits2.default)(WriteQueue, _Queue);
36
42
 
@@ -54,6 +60,38 @@ var WriteQueue = function (_Queue) {
54
60
  }
55
61
 
56
62
  (0, _createClass2.default)(WriteQueue, [{
63
+ key: "enqueue",
64
+ value: function () {
65
+ var _enqueue = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(val) {
66
+ return _regenerator.default.wrap(function _callee$(_context) {
67
+ while (1) {
68
+ switch (_context.prev = _context.next) {
69
+ case 0:
70
+ (0, _get2.default)((0, _getPrototypeOf2.default)(WriteQueue.prototype), "enqueue", this).call(this, val);
71
+
72
+ if (!(_process.default.memoryUsage().rss > MEMORY_LIMIT)) {
73
+ _context.next = 4;
74
+ break;
75
+ }
76
+
77
+ _context.next = 4;
78
+ return this.startWrite();
79
+
80
+ case 4:
81
+ case "end":
82
+ return _context.stop();
83
+ }
84
+ }
85
+ }, _callee, this);
86
+ }));
87
+
88
+ function enqueue(_x) {
89
+ return _enqueue.apply(this, arguments);
90
+ }
91
+
92
+ return enqueue;
93
+ }()
94
+ }, {
57
95
  key: "startListening",
58
96
  value: function startListening() {
59
97
  this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
@@ -68,26 +106,26 @@ var WriteQueue = function (_Queue) {
68
106
  }, {
69
107
  key: "startWrite",
70
108
  value: function () {
71
- var _startWrite = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee() {
72
- return _regenerator.default.wrap(function _callee$(_context) {
109
+ var _startWrite = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2() {
110
+ return _regenerator.default.wrap(function _callee2$(_context2) {
73
111
  while (1) {
74
- switch (_context.prev = _context.next) {
112
+ switch (_context2.prev = _context2.next) {
75
113
  case 0:
76
114
  if (!this.writePromise) {
77
- _context.next = 5;
115
+ _context2.next = 5;
78
116
  break;
79
117
  }
80
118
 
81
- _context.next = 3;
119
+ _context2.next = 3;
82
120
  return this.writePromise;
83
121
 
84
122
  case 3:
85
123
  this.writePromise = null;
86
- return _context.abrupt("return");
124
+ return _context2.abrupt("return");
87
125
 
88
126
  case 5:
89
127
  this.writePromise = this.doWrite();
90
- _context.next = 8;
128
+ _context2.next = 8;
91
129
  return this.writePromise;
92
130
 
93
131
  case 8:
@@ -95,10 +133,10 @@ var WriteQueue = function (_Queue) {
95
133
 
96
134
  case 9:
97
135
  case "end":
98
- return _context.stop();
136
+ return _context2.stop();
99
137
  }
100
138
  }
101
- }, _callee, this);
139
+ }, _callee2, this);
102
140
  }));
103
141
 
104
142
  function startWrite() {
@@ -110,21 +148,21 @@ var WriteQueue = function (_Queue) {
110
148
  }, {
111
149
  key: "finalize",
112
150
  value: function () {
113
- var _finalize = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2() {
114
- return _regenerator.default.wrap(function _callee2$(_context2) {
151
+ var _finalize = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3() {
152
+ return _regenerator.default.wrap(function _callee3$(_context3) {
115
153
  while (1) {
116
- switch (_context2.prev = _context2.next) {
154
+ switch (_context3.prev = _context3.next) {
117
155
  case 0:
118
156
  this.stopListening();
119
- _context2.next = 3;
157
+ _context3.next = 3;
120
158
  return this.startWrite();
121
159
 
122
160
  case 3:
123
161
  case "end":
124
- return _context2.stop();
162
+ return _context3.stop();
125
163
  }
126
164
  }
127
- }, _callee2, this);
165
+ }, _callee3, this);
128
166
  }));
129
167
 
130
168
  function finalize() {
@@ -136,15 +174,15 @@ var WriteQueue = function (_Queue) {
136
174
  }, {
137
175
  key: "doWrite",
138
176
  value: function () {
139
- var _doWrite = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3() {
177
+ var _doWrite = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4() {
140
178
  var promises, archiveKeys, i, item, _ref, archiveKey, writePromise, writeResults;
141
179
 
142
- return _regenerator.default.wrap(function _callee3$(_context3) {
180
+ return _regenerator.default.wrap(function _callee4$(_context4) {
143
181
  while (1) {
144
- switch (_context3.prev = _context3.next) {
182
+ switch (_context4.prev = _context4.next) {
145
183
  case 0:
146
184
  if (!this.length) {
147
- _context3.next = 20;
185
+ _context4.next = 20;
148
186
  break;
149
187
  }
150
188
 
@@ -154,18 +192,18 @@ var WriteQueue = function (_Queue) {
154
192
 
155
193
  case 4:
156
194
  if (!(i < this.writeConcurrency)) {
157
- _context3.next = 14;
195
+ _context4.next = 14;
158
196
  break;
159
197
  }
160
198
 
161
199
  item = this.dequeue();
162
200
 
163
201
  if (item) {
164
- _context3.next = 8;
202
+ _context4.next = 8;
165
203
  break;
166
204
  }
167
205
 
168
- return _context3.abrupt("break", 14);
206
+ return _context4.abrupt("break", 14);
169
207
 
170
208
  case 8:
171
209
  _ref = item, archiveKey = _ref.archiveKey, writePromise = _ref.writePromise;
@@ -174,17 +212,17 @@ var WriteQueue = function (_Queue) {
174
212
 
175
213
  case 11:
176
214
  i++;
177
- _context3.next = 4;
215
+ _context4.next = 4;
178
216
  break;
179
217
 
180
218
  case 14:
181
- _context3.next = 16;
219
+ _context4.next = 16;
182
220
  return Promise.all(promises);
183
221
 
184
222
  case 16:
185
- writeResults = _context3.sent;
223
+ writeResults = _context4.sent;
186
224
  this.updateFileMap(archiveKeys, writeResults);
187
- _context3.next = 0;
225
+ _context4.next = 0;
188
226
  break;
189
227
 
190
228
  case 20:
@@ -192,10 +230,10 @@ var WriteQueue = function (_Queue) {
192
230
 
193
231
  case 21:
194
232
  case "end":
195
- return _context3.stop();
233
+ return _context4.stop();
196
234
  }
197
235
  }
198
- }, _callee3, this);
236
+ }, _callee4, this);
199
237
  }));
200
238
 
201
239
  function doWrite() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/write-queue.ts"],"names":["WriteQueue","listeningInterval","writeConcurrency","intervalId","setInterval","startWrite","bind","clearInterval","writePromise","doWrite","stopListening","length","promises","archiveKeys","i","item","dequeue","archiveKey","push","Promise","all","writeResults","updateFileMap","fileMap","Queue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;IAOqBA,U;;;;;AAOnB,wBAA8E;AAAA;;AAAA,QAAlEC,iBAAkE,uEAAtC,IAAsC;AAAA,QAAhCC,gBAAgC,uEAAL,GAAK;AAAA;AAC5E;AAD4E;AAAA,+FALlC,IAKkC;AAAA,0FAJpC,EAIoC;AAAA;AAAA;AAE5E,UAAKD,iBAAL,GAAyBA,iBAAzB;AACA,UAAKC,gBAAL,GAAwBA,gBA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ACAL,gBAAAA,QAAQ,CAACM,IAAT,CAAcV,YAAd;;AAXN;AAI+CM,gBAAAA,CAAC,EAJhD;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAa+BK,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAb/B;;AAAA;AAaUS,gBAAAA,YAbV;AAcI,qBAAKC,aAAL,CAAmBT,WAAnB,EAAgCQ,YAAhC;AAdJ;AAAA;;AAAA;AAgBE,qBAAKb,YAAL,GAAoB,IAApB;;AAhBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAmBA,uBAAsBK,WAAtB,EAA2DQ,YAA3D,EAAmF;AACjF,WAAK,IAAIP,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,WAAW,CAACF,MAAhC,EAAwCG,CAAC,EAAzC,EAA6C;AAC3C,YAAMG,UAAU,GAAGJ,WAAW,CAACC,CAAD,CAA9B;;AACA,YAAI,CAACG,UAAL,EAAiB;AACf;AACD;;AACD,aAAKM,OAAL,CAAaN,UAAb,IAA2BI,YAAY,CAACP,CAAD,CAAvC;AACD;AACF;;;EAlE+DU,Y","sourcesContent":["import {Queue} from './queue';\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n writePromise: Promise<string>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (this.writePromise) {\n await this.writePromise;\n this.writePromise = null;\n return;\n }\n this.writePromise = this.doWrite();\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n promises.push(writePromise);\n }\n const writeResults = await Promise.all(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n this.writePromise = null;\n }\n\n private updateFileMap(archiveKeys: (string | undefined)[], writeResults: string[]) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (!archiveKey) {\n continue;\n }\n this.fileMap[archiveKey] = writeResults[i];\n }\n }\n}\n"],"file":"write-queue.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/write-queue.ts"],"names":["MEMORY_LIMIT","WriteQueue","listeningInterval","writeConcurrency","val","process","memoryUsage","rss","startWrite","intervalId","setInterval","bind","clearInterval","writePromise","doWrite","stopListening","length","promises","archiveKeys","i","item","dequeue","archiveKey","push","Promise","all","writeResults","updateFileMap","fileMap","Queue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;AAGA,IAAMA,YAAY,GAAG,IAAI,IAAJ,GAAW,IAAX,GAAkB,IAAvC;;IAOqBC,U;;;;;AAOnB,wBAA8E;AAAA;;AAAA,QAAlEC,iBAAkE,uEAAtC,IAAsC;AAAA,QAAhCC,gBAAgC,uEAAL,GAAK;AAAA;AAC5E;AAD4E;AAAA,+FALlC,IAKkC;AAAA,0FAJpC,EAIoC;AAAA;AAAA;AAE5E,UAAKD,iBAAL,GAAyBA,iBAAzB;AACA,UAAKC,gBAAL,GAAwBA,gBAAxB;AAH4E;AAI7E;;;;;+EAED,iBAAcC,GAAd;AAAA;AAAA;AAAA;AAAA;AACE,oHAAcA,GAAd;;AADF,sBAGMC,i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AAA;;AAAA;;AAAA;AAAA,uBASyCA,IATzC,EASaE,UATb,QASaA,UATb,EASyBT,YATzB,QASyBA,YATzB;AAUMK,gBAAAA,WAAW,CAACK,IAAZ,CAAiBD,UAAjB;AACAL,gBAAAA,QAAQ,CAACM,IAAT,CAAcV,YAAd;;AAXN;AAI+CM,gBAAAA,CAAC,EAJhD;AAAA;AAAA;;AAAA;AAAA;AAAA,uBAa+BK,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAb/B;;AAAA;AAaUS,gBAAAA,YAbV;AAcI,qBAAKC,aAAL,CAAmBT,WAAnB,EAAgCQ,YAAhC;AAdJ;AAAA;;AAAA;AAgBE,qBAAKb,YAAL,GAAoB,IAApB;;AAhBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAmBA,uBAAsBK,WAAtB,EAA2DQ,YAA3D,EAAmF;AACjF,WAAK,IAAIP,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,WAAW,CAACF,MAAhC,EAAwCG,CAAC,EAAzC,EAA6C;AAC3C,YAAMG,UAAU,GAAGJ,WAAW,CAACC,CAAD,CAA9B;;AACA,YAAI,CAACG,UAAL,EAAiB;AACf;AACD;;AACD,aAAKM,OAAL,CAAaN,UAAb,IAA2BI,YAAY,CAACP,CAAD,CAAvC;AACD;AACF;;;EA1E+DU,Y","sourcesContent":["import {Queue} from './queue';\nimport process from 'process';\n\n/** Memory limit size is based on testing */\nconst MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB\n\nexport type WriteQueueItem = {\n archiveKey?: string;\n writePromise: Promise<string>;\n};\n\nexport default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {\n private intervalId?: NodeJS.Timeout;\n public writePromise: Promise<void> | null = null;\n public fileMap: {[key: string]: string} = {};\n public listeningInterval: number;\n public writeConcurrency: number;\n\n constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {\n super();\n this.listeningInterval = listeningInterval;\n this.writeConcurrency = writeConcurrency;\n }\n\n async enqueue(val: T) {\n super.enqueue(val);\n /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */\n if (process.memoryUsage().rss > MEMORY_LIMIT) {\n await this.startWrite();\n }\n }\n\n startListening() {\n this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);\n }\n\n stopListening() {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n }\n }\n\n async startWrite(): Promise<void> {\n if (this.writePromise) {\n await this.writePromise;\n this.writePromise = null;\n return;\n }\n this.writePromise = this.doWrite();\n await this.writePromise;\n this.writePromise = null;\n }\n\n async finalize(): Promise<void> {\n this.stopListening();\n await this.startWrite();\n }\n\n private async doWrite(): Promise<void> {\n while (this.length) {\n const promises: Promise<string>[] = [];\n const archiveKeys: (string | undefined)[] = [];\n for (let i = 0; i < this.writeConcurrency; i++) {\n const item = this.dequeue();\n if (!item) {\n break;\n }\n const {archiveKey, writePromise} = item as WriteQueueItem;\n archiveKeys.push(archiveKey);\n promises.push(writePromise);\n }\n const writeResults = await Promise.all(promises);\n this.updateFileMap(archiveKeys, writeResults);\n }\n this.writePromise = null;\n }\n\n private updateFileMap(archiveKeys: (string | undefined)[], writeResults: string[]) {\n for (let i = 0; i < archiveKeys.length; i++) {\n const archiveKey = archiveKeys[i];\n if (!archiveKey) {\n continue;\n }\n this.fileMap[archiveKey] = writeResults[i];\n }\n }\n}\n"],"file":"write-queue.js"}
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _geoid = require("@math.gl/geoid");
15
15
 
16
- var VERSION = typeof "3.2.5" !== 'undefined' ? "3.2.5" : 'latest';
16
+ var VERSION = typeof "3.2.8" !== 'undefined' ? "3.2.8" : 'latest';
17
17
  var PGMLoader = {
18
18
  name: 'PGM - Netpbm grayscale image format',
19
19
  id: 'pgm',
@@ -1,5 +1,5 @@
1
1
  import { processOnWorker } from '@loaders.gl/worker-utils';
2
- const VERSION = typeof "3.2.5" !== 'undefined' ? "3.2.5" : 'latest';
2
+ const VERSION = typeof "3.2.8" !== 'undefined' ? "3.2.8" : 'latest';
3
3
  export const Tile3dAttributesWorker = {
4
4
  id: '3d-tiles-attributes',
5
5
  name: '3DTiles Attributes Worker',
@@ -1,5 +1,5 @@
1
1
  import { processOnWorker } from '@loaders.gl/worker-utils';
2
- const VERSION = typeof "3.2.5" !== 'undefined' ? "3.2.5" : 'latest';
2
+ const VERSION = typeof "3.2.8" !== 'undefined' ? "3.2.8" : 'latest';
3
3
  export const I3SAttributesWorker = {
4
4
  id: 'i3s-attributes',
5
5
  name: 'I3S Attributes Worker',
@@ -121,7 +121,7 @@ export default class NodePages {
121
121
  for (const [index, nodePage] of this.nodePages.entries()) {
122
122
  const nodePageStr = JSON.stringify(nodePage);
123
123
  const slpkPath = join(layers0Path, 'nodepages');
124
- writeQueue.enqueue({
124
+ await writeQueue.enqueue({
125
125
  archiveKey: "nodePages/".concat(index.toString(), ".json.gz"),
126
126
  writePromise: this.writeFile(slpkPath, nodePageStr, "".concat(index.toString(), ".json"))
127
127
  });
@@ -131,7 +131,7 @@ export default class NodePages {
131
131
  nodeCount: this.nodesCounter
132
132
  }, metadataTemplate());
133
133
  const compress = false;
134
- writeQueue.enqueue({
134
+ await writeQueue.enqueue({
135
135
  archiveKey: 'metadata.json',
136
136
  writePromise: this.writeFile(layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
137
137
  });
@@ -139,7 +139,7 @@ export default class NodePages {
139
139
  for (const [index, nodePage] of this.nodePages.entries()) {
140
140
  const nodePageStr = JSON.stringify(nodePage);
141
141
  const nodePagePath = join(layers0Path, 'nodepages', index.toString());
142
- writeQueue.enqueue({
142
+ await writeQueue.enqueue({
143
143
  writePromise: this.writeFile(nodePagePath, nodePageStr)
144
144
  });
145
145
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.ts"],"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","undefined","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","writeQueue","slpk","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";AAEA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAqCA,eAAe,MAAMC,SAAN,CAAgB;AAY7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;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;;AAMDM,EAAAA,gBAAgB,CAACC,IAAD,EAAuB;AACrC,SAAKF,SAAL,GAAiBE,IAAjB;AACD;;AAODC,EAAAA,WAAW,CAACC,EAAD,EAAyB;AAClC,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKR,YAArB,CAAlB;AACA,UAAMY,SAAS,GAAGJ,EAAE,GAAG,KAAKR,YAA5B;AACA,WAAO,KAAKE,SAAL,CAAeO,SAAf,EAA0BN,KAA1B,CAAgCS,SAAhC,CAAP;AACD;;AAODC,EAAAA,sBAAsB,CAACL,EAAD,EAAaM,UAAb,EAAuC;AAC3D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A7B;AAAf,SAAnB;AACD;AACF;AACF;;AA5L4B","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":["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","undefined","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","writeQueue","slpk","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";AAEA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAqCA,eAAe,MAAMC,SAAN,CAAgB;AAY7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;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;;AAMDM,EAAAA,gBAAgB,CAACC,IAAD,EAAuB;AACrC,SAAKF,SAAL,GAAiBE,IAAjB;AACD;;AAODC,EAAAA,WAAW,CAACC,EAAD,EAAyB;AAClC,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKR,YAArB,CAAlB;AACA,UAAMY,SAAS,GAAGJ,EAAE,GAAG,KAAKR,YAA5B;AACA,WAAO,KAAKE,SAAL,CAAeO,SAAf,EAA0BN,KAA1B,CAAgCS,SAAhC,CAAP;AACD;;AAODC,EAAAA,sBAAsB,CAACL,EAAD,EAAaM,UAAb,EAAuC;AAC3D,UAAMC,IAAI,GAAG,KAAKR,WAAL,CAAiBC,EAAjB,CAAb;;AACA,QAAI,CAACO,IAAI,CAACC,IAA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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"}
@@ -277,12 +277,12 @@ export default class I3SConverter {
277
277
  const childPath = join(this.layers0Path, 'nodes', child.path);
278
278
 
279
279
  if (this.options.slpk) {
280
- this.writeQueue.enqueue({
280
+ await this.writeQueue.enqueue({
281
281
  archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
282
282
  writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
283
283
  });
284
284
  } else {
285
- this.writeQueue.enqueue({
285
+ await this.writeQueue.enqueue({
286
286
  writePromise: writeFile(childPath, JSON.stringify(child))
287
287
  });
288
288
  }
@@ -300,12 +300,12 @@ export default class I3SConverter {
300
300
 
301
301
  async _writeLayers0() {
302
302
  if (this.options.slpk) {
303
- this.writeQueue.enqueue({
303
+ await this.writeQueue.enqueue({
304
304
  archiveKey: '3dSceneLayer.json.gz',
305
305
  writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
306
306
  });
307
307
  } else {
308
- this.writeQueue.enqueue({
308
+ await this.writeQueue.enqueue({
309
309
  writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
310
310
  });
311
311
  }
@@ -313,12 +313,12 @@ export default class I3SConverter {
313
313
 
314
314
  async _writeNodeIndexDocument(root0, nodePath, rootPath) {
315
315
  if (this.options.slpk) {
316
- this.writeQueue.enqueue({
316
+ await this.writeQueue.enqueue({
317
317
  archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
318
318
  writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
319
319
  });
320
320
  } else {
321
- this.writeQueue.enqueue({
321
+ await this.writeQueue.enqueue({
322
322
  writePromise: writeFile(rootPath, JSON.stringify(root0))
323
323
  });
324
324
  }
@@ -643,13 +643,13 @@ export default class I3SConverter {
643
643
  async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
644
644
  if (this.options.slpk) {
645
645
  const slpkGeometryPath = join(childPath, 'geometries');
646
- this.writeQueue.enqueue({
646
+ await this.writeQueue.enqueue({
647
647
  archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
648
648
  writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
649
649
  });
650
650
  } else {
651
651
  const geometryPath = join(childPath, 'geometries/0/');
652
- this.writeQueue.enqueue({
652
+ await this.writeQueue.enqueue({
653
653
  writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
654
654
  });
655
655
  }
@@ -657,13 +657,13 @@ export default class I3SConverter {
657
657
  if (this.options.draco) {
658
658
  if (this.options.slpk) {
659
659
  const slpkCompressedGeometryPath = join(childPath, 'geometries');
660
- this.writeQueue.enqueue({
660
+ await this.writeQueue.enqueue({
661
661
  archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
662
662
  writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
663
663
  });
664
664
  } else {
665
665
  const compressedGeometryPath = join(childPath, 'geometries/1/');
666
- this.writeQueue.enqueue({
666
+ await this.writeQueue.enqueue({
667
667
  writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
668
668
  });
669
669
  }
@@ -681,13 +681,13 @@ export default class I3SConverter {
681
681
 
682
682
  if (this.options.slpk) {
683
683
  const slpkSharedPath = join(childPath, 'shared');
684
- this.writeQueue.enqueue({
684
+ await this.writeQueue.enqueue({
685
685
  archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
686
686
  writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
687
687
  });
688
688
  } else {
689
689
  const sharedPath = join(childPath, 'shared/');
690
- this.writeQueue.enqueue({
690
+ await this.writeQueue.enqueue({
691
691
  writePromise: writeFile(sharedPath, sharedDataStr)
692
692
  });
693
693
  }
@@ -757,13 +757,13 @@ export default class I3SConverter {
757
757
  if (this.options.slpk) {
758
758
  const slpkTexturePath = join(childPath, 'textures');
759
759
  const compress = false;
760
- this.writeQueue.enqueue({
760
+ await this.writeQueue.enqueue({
761
761
  archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
762
762
  writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
763
763
  });
764
764
  } else {
765
765
  const texturePath = join(childPath, "textures/".concat(name, "/"));
766
- this.writeQueue.enqueue({
766
+ await this.writeQueue.enqueue({
767
767
  writePromise: writeFile(texturePath, textureData, "index.".concat(format))
768
768
  });
769
769
  }
@@ -779,13 +779,13 @@ export default class I3SConverter {
779
779
 
780
780
  if (this.options.slpk) {
781
781
  const slpkAttributesPath = join(childPath, 'attributes', folderName);
782
- this.writeQueue.enqueue({
782
+ await this.writeQueue.enqueue({
783
783
  archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
784
784
  writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
785
785
  });
786
786
  } else {
787
787
  const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
788
- this.writeQueue.enqueue({
788
+ await this.writeQueue.enqueue({
789
789
  writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
790
790
  });
791
791
  }