@loaders.gl/tile-converter 4.0.0-alpha.10 → 4.0.0-alpha.11

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 (78) hide show
  1. package/bin/slpk-extractor.js +4 -0
  2. package/dist/3d-tiles-attributes-worker.js +1 -1
  3. package/dist/converter-cli.js +18 -84
  4. package/dist/converter.min.js +50 -50
  5. package/dist/dist.min.js +2 -2
  6. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  7. package/dist/es5/converter-cli.js +18 -63
  8. package/dist/es5/converter-cli.js.map +1 -1
  9. package/dist/es5/deps-installer/deps-installer.js +1 -1
  10. package/dist/es5/i3s-attributes-worker.js +1 -1
  11. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  12. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  13. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
  14. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  15. package/dist/es5/i3s-converter/i3s-converter.js +1 -1
  16. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  17. package/dist/es5/lib/utils/cli-utils.js +57 -0
  18. package/dist/es5/lib/utils/cli-utils.js.map +1 -0
  19. package/dist/es5/pgm-loader.js +1 -1
  20. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +181 -0
  21. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
  22. package/dist/es5/slpk-extractor/slpk-extractor.js +172 -0
  23. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
  24. package/dist/es5/slpk-extractor-cli.js +117 -0
  25. package/dist/es5/slpk-extractor-cli.js.map +1 -0
  26. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  27. package/dist/esm/converter-cli.js +1 -46
  28. package/dist/esm/converter-cli.js.map +1 -1
  29. package/dist/esm/deps-installer/deps-installer.js +1 -1
  30. package/dist/esm/i3s-attributes-worker.js +1 -1
  31. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  32. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  33. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
  34. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  35. package/dist/esm/i3s-converter/i3s-converter.js +1 -1
  36. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  37. package/dist/esm/lib/utils/cli-utils.js +47 -0
  38. package/dist/esm/lib/utils/cli-utils.js.map +1 -0
  39. package/dist/esm/pgm-loader.js +1 -1
  40. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +43 -0
  41. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
  42. package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
  43. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
  44. package/dist/esm/slpk-extractor-cli.js +74 -0
  45. package/dist/esm/slpk-extractor-cli.js.map +1 -0
  46. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
  47. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  48. package/dist/i3s-converter/helpers/coordinate-converter.js +1 -2
  49. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  50. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  51. package/dist/i3s-converter/helpers/gltf-attributes.js +2 -1
  52. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -3
  53. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  54. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
  55. package/dist/i3s-converter/i3s-converter.js +1 -1
  56. package/dist/lib/utils/cli-utils.d.ts +34 -0
  57. package/dist/lib/utils/cli-utils.d.ts.map +1 -0
  58. package/dist/lib/utils/cli-utils.js +82 -0
  59. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +48 -0
  60. package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -0
  61. package/dist/slpk-extractor/helpers/file-handle-provider.js +71 -0
  62. package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
  63. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
  64. package/dist/slpk-extractor/slpk-extractor.js +78 -0
  65. package/dist/slpk-extractor-cli.d.ts +17 -0
  66. package/dist/slpk-extractor-cli.d.ts.map +1 -0
  67. package/dist/slpk-extractor-cli.js +102 -0
  68. package/dist/slpk-extractor.min.js +189 -0
  69. package/package.json +17 -15
  70. package/src/converter-cli.ts +7 -72
  71. package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
  72. package/src/i3s-converter/helpers/gltf-attributes.ts +7 -8
  73. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -3
  74. package/src/i3s-converter/i3s-converter.ts +1 -1
  75. package/src/lib/utils/cli-utils.ts +78 -0
  76. package/src/slpk-extractor/helpers/file-handle-provider.ts +91 -0
  77. package/src/slpk-extractor/slpk-extractor.ts +102 -0
  78. package/src/slpk-extractor-cli.ts +128 -0
@@ -5,6 +5,7 @@ require("@loaders.gl/polyfills");
5
5
  const path_1 = require("path");
6
6
  const tile_converter_1 = require("@loaders.gl/tile-converter");
7
7
  const deps_installer_1 = require("./deps-installer/deps-installer");
8
+ const cli_utils_1 = require("./lib/utils/cli-utils");
8
9
  const TILESET_TYPE = {
9
10
  I3S: 'I3S',
10
11
  _3DTILES: '3DTILES'
@@ -18,7 +19,7 @@ async function main() {
18
19
  if (args.length === 0) {
19
20
  printHelp();
20
21
  }
21
- const validatedOptionsArr = validateOptionsWithEqual(args);
22
+ const validatedOptionsArr = (0, cli_utils_1.validateOptionsWithEqual)(args);
22
23
  const options = parseOptions(validatedOptionsArr);
23
24
  if (options.installDependencies) {
24
25
  const depthInstaller = new deps_installer_1.DepsInstaller();
@@ -129,18 +130,6 @@ function validateOptions(options) {
129
130
  }
130
131
  return options;
131
132
  }
132
- function validateOptionsWithEqual(args) {
133
- return args.reduce((acc, curr) => {
134
- const equalSignIndex = curr.indexOf('=');
135
- const beforeEqual = curr.slice(0, equalSignIndex);
136
- const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
137
- const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
138
- if (condition) {
139
- return acc.concat(beforeEqual, afterEqual);
140
- }
141
- return acc.concat(curr);
142
- }, []);
143
- }
144
133
  /**
145
134
  * Parse option from the cli arguments array
146
135
  * @param args
@@ -165,52 +154,52 @@ function parseOptions(args) {
165
154
  if (arg.indexOf('--') === 0) {
166
155
  switch (arg) {
167
156
  case '--input-type':
168
- opts.inputType = getStringValue(index, args);
157
+ opts.inputType = (0, cli_utils_1.getStringValue)(index, args);
169
158
  break;
170
159
  case '--tileset':
171
- opts.tileset = getURLValue(index, args);
160
+ opts.tileset = (0, cli_utils_1.getURLValue)(index, args);
172
161
  break;
173
162
  case '--name':
174
- opts.name = getStringValue(index, args);
163
+ opts.name = (0, cli_utils_1.getStringValue)(index, args);
175
164
  break;
176
165
  case '--output':
177
- opts.output = getStringValue(index, args);
166
+ opts.output = (0, cli_utils_1.getStringValue)(index, args);
178
167
  break;
179
168
  case '--instant-node-writing':
180
- opts.instantNodeWriting = getBooleanValue(index, args);
169
+ opts.instantNodeWriting = (0, cli_utils_1.getBooleanValue)(index, args);
181
170
  break;
182
171
  case '--split-nodes':
183
- opts.mergeMaterials = getBooleanValue(index, args);
172
+ opts.mergeMaterials = (0, cli_utils_1.getBooleanValue)(index, args);
184
173
  break;
185
174
  case '--max-depth':
186
- opts.maxDepth = getIntegerValue(index, args);
175
+ opts.maxDepth = (0, cli_utils_1.getIntegerValue)(index, args);
187
176
  break;
188
177
  case '--slpk':
189
- opts.slpk = getBooleanValue(index, args);
178
+ opts.slpk = (0, cli_utils_1.getBooleanValue)(index, args);
190
179
  break;
191
180
  case '--7zExe':
192
- opts.sevenZipExe = getStringValue(index, args);
181
+ opts.sevenZipExe = (0, cli_utils_1.getStringValue)(index, args);
193
182
  break;
194
183
  case '--egm':
195
- opts.egm = getStringValue(index, args);
184
+ opts.egm = (0, cli_utils_1.getStringValue)(index, args);
196
185
  break;
197
186
  case '--token':
198
- opts.token = getStringValue(index, args);
187
+ opts.token = (0, cli_utils_1.getStringValue)(index, args);
199
188
  break;
200
189
  case '--no-draco':
201
- opts.draco = getBooleanValue(index, args);
190
+ opts.draco = (0, cli_utils_1.getBooleanValue)(index, args);
202
191
  break;
203
192
  case '--validate':
204
- opts.validate = getBooleanValue(index, args);
193
+ opts.validate = (0, cli_utils_1.getBooleanValue)(index, args);
205
194
  break;
206
195
  case '--install-dependencies':
207
- opts.installDependencies = getBooleanValue(index, args);
196
+ opts.installDependencies = (0, cli_utils_1.getBooleanValue)(index, args);
208
197
  break;
209
198
  case '--generate-textures':
210
- opts.generateTextures = getBooleanValue(index, args);
199
+ opts.generateTextures = (0, cli_utils_1.getBooleanValue)(index, args);
211
200
  break;
212
201
  case '--generate-bounding-volumes':
213
- opts.generateBoundingVolumes = getBooleanValue(index, args);
202
+ opts.generateBoundingVolumes = (0, cli_utils_1.getBooleanValue)(index, args);
214
203
  break;
215
204
  case '--help':
216
205
  printHelp();
@@ -223,58 +212,3 @@ function parseOptions(args) {
223
212
  });
224
213
  return opts;
225
214
  }
226
- /**
227
- * Get string option value from cli arguments
228
- * @param index - option's name index in the argument's array.
229
- * The value of the option should be next to name of the option.
230
- * @param args - cli arguments array
231
- * @returns - string value of the option
232
- */
233
- function getStringValue(index, args) {
234
- if (index + 1 >= args.length) {
235
- return '';
236
- }
237
- const value = args[index + 1];
238
- if (value.indexOf('--') === 0) {
239
- return '';
240
- }
241
- return value;
242
- }
243
- /**
244
- * Modyfy URL path to be compatible with fetch
245
- * @param index - option's name index in the argument's array.
246
- * The value of the option should be next to name of the option.
247
- * @param args - cli arguments array
248
- * @returns - string value of the option
249
- */
250
- function getURLValue(index, args) {
251
- const value = getStringValue(index, args);
252
- console.log(`Input tileset value: ${value}`);
253
- console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
254
- return value.replace(/\\/g, '/');
255
- }
256
- /**
257
- * Get integer option value from cli arguments
258
- * @param index - option's name index in the argument's array
259
- * The value of the option should be next to name of the option.
260
- * @param args - cli arguments array
261
- * @returns - number value of the option
262
- */
263
- function getIntegerValue(index, args) {
264
- const stringValue = getStringValue(index, args);
265
- const result = Number.parseInt(stringValue);
266
- if (isFinite(result)) {
267
- return result;
268
- }
269
- return NaN;
270
- }
271
- function getBooleanValue(index, args) {
272
- const stringValue = getStringValue(index, args).toLowerCase().trim();
273
- if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
274
- return false;
275
- }
276
- if (!stringValue || stringValue === 'true') {
277
- return true;
278
- }
279
- return false;
280
- }