@loaders.gl/tile-converter 3.2.0-alpha.2 → 3.2.0

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 (82) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.js.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +1 -1
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/3d-tiles-converter.js +5 -0
  6. package/dist/constants.d.ts +2 -0
  7. package/dist/constants.d.ts.map +1 -0
  8. package/dist/constants.js +4 -0
  9. package/dist/converter-cli.d.ts +2 -0
  10. package/dist/converter-cli.d.ts.map +1 -0
  11. package/dist/converter-cli.js +232 -0
  12. package/dist/converter.min.js +68 -68
  13. package/dist/deps-installer/deps-installer.d.ts +11 -1
  14. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  15. package/dist/deps-installer/deps-installer.js +10 -0
  16. package/dist/dist.min.js +147 -171
  17. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  18. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  19. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +33 -22
  20. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  21. package/dist/es5/constants.js +9 -0
  22. package/dist/es5/constants.js.map +1 -0
  23. package/dist/es5/converter-cli.js +306 -0
  24. package/dist/es5/converter-cli.js.map +1 -0
  25. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  26. package/dist/es5/i3s-attributes-worker.js +1 -1
  27. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/geometry-converter.js +4 -4
  29. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  30. package/dist/es5/i3s-converter/i3s-converter.js +84 -49
  31. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  32. package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
  33. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  34. package/dist/es5/index.js +0 -24
  35. package/dist/es5/index.js.map +1 -1
  36. package/dist/es5/pgm-loader.js +1 -1
  37. package/dist/es5/pgm-loader.js.map +1 -1
  38. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  39. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  40. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +7 -1
  41. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  42. package/dist/esm/constants.js +2 -0
  43. package/dist/esm/constants.js.map +1 -0
  44. package/dist/esm/converter-cli.js +230 -0
  45. package/dist/esm/converter-cli.js.map +1 -0
  46. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  47. package/dist/esm/i3s-attributes-worker.js +1 -1
  48. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  49. package/dist/esm/i3s-converter/helpers/geometry-converter.js +4 -4
  50. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  51. package/dist/esm/i3s-converter/i3s-converter.js +57 -29
  52. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  53. package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
  54. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  55. package/dist/esm/index.js +0 -3
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/pgm-loader.js +1 -1
  58. package/dist/esm/pgm-loader.js.map +1 -1
  59. package/dist/i3s-attributes-worker.js +1 -1
  60. package/dist/i3s-attributes-worker.js.map +2 -2
  61. package/dist/i3s-converter/helpers/geometry-converter.js +3 -3
  62. package/dist/i3s-converter/i3s-converter.d.ts +0 -2
  63. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  64. package/dist/i3s-converter/i3s-converter.js +42 -18
  65. package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
  66. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  67. package/dist/i3s-converter/json-templates/layers.js +24 -0
  68. package/dist/index.d.ts +0 -3
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +1 -7
  71. package/package.json +20 -18
  72. package/src/3d-tiles-converter/3d-tiles-converter.ts +7 -2
  73. package/src/constants.ts +2 -0
  74. package/src/converter-cli.ts +310 -0
  75. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  76. package/src/i3s-converter/helpers/geometry-converter.ts +4 -4
  77. package/src/i3s-converter/i3s-converter.ts +46 -29
  78. package/src/i3s-converter/json-templates/layers.ts +25 -0
  79. package/src/index.ts +0 -5
  80. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  81. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  82. package/src/deps-installer/deps-installer.d.ts +0 -10
@@ -29,7 +29,7 @@ export default class Tiles3DConverter {
29
29
  inputUrl: string;
30
30
  outputPath: string;
31
31
  tilesetName: string;
32
- maxDepth: number;
32
+ maxDepth?: number;
33
33
  egmFilePath: string;
34
34
  }): Promise<any>;
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAkC,MAAM,iBAAiB,CAAC;AAQ3F,OAAO,EAAC,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAmBrC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,SAAS,GAAG,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AG,IAAI,CAAC;IAClD,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;;IAa3C;;;;;;;;OAQG;IACU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC;IA0DhB;;;;;OAKG;YACW,YAAY;IAgE1B;;;;;OAKG;YACW,cAAc;IAyB5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;YAiBjB,WAAW;CAS1B"}
@@ -19,6 +19,7 @@ const b3dm_converter_1 = __importDefault(require("./helpers/b3dm-converter"));
19
19
  const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
20
20
  const _3d_tiles_attributes_worker_1 = require("../3d-tiles-attributes-worker");
21
21
  const worker_utils_1 = require("@loaders.gl/worker-utils");
22
+ const constants_1 = require("../constants");
22
23
  const I3S = 'I3S';
23
24
  /**
24
25
  * Converter from i3s to 3d-tiles
@@ -45,6 +46,10 @@ class Tiles3DConverter {
45
46
  * @param options.maxDepth The max tree depth of conversion
46
47
  */
47
48
  async convert(options) {
49
+ if (core_1.isBrowser) {
50
+ console.log(constants_1.BROWSER_ERROR_MESSAGE);
51
+ return constants_1.BROWSER_ERROR_MESSAGE;
52
+ }
48
53
  const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
49
54
  this.conversionStartTime = process_1.default.hrtime();
50
55
  this.options = { maxDepth };
@@ -0,0 +1,2 @@
1
+ export declare const BROWSER_ERROR_MESSAGE = "Tile converter does not work in browser, only in node js environment";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,yEACsC,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BROWSER_ERROR_MESSAGE = void 0;
4
+ exports.BROWSER_ERROR_MESSAGE = 'Tile converter does not work in browser, only in node js environment';
@@ -0,0 +1,2 @@
1
+ import '@loaders.gl/polyfills';
2
+ //# sourceMappingURL=converter-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter-cli.d.ts","sourceRoot":"","sources":["../src/converter-cli.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC"}
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable no-console */
4
+ require("@loaders.gl/polyfills");
5
+ const path_1 = require("path");
6
+ const tile_converter_1 = require("@loaders.gl/tile-converter");
7
+ const deps_installer_1 = require("./deps-installer/deps-installer");
8
+ const TILESET_TYPE = {
9
+ I3S: 'I3S',
10
+ _3DTILES: '3DTILES'
11
+ };
12
+ /**
13
+ * CLI entry
14
+ * @returns
15
+ */
16
+ async function main() {
17
+ const [, , ...args] = process.argv;
18
+ if (args.length === 0) {
19
+ printHelp();
20
+ }
21
+ const options = parseOptions(args);
22
+ if (options.installDependencies) {
23
+ const depthInstaller = new deps_installer_1.DepsInstaller();
24
+ depthInstaller.install('deps');
25
+ return;
26
+ }
27
+ const validatedOptions = validateOptions(options);
28
+ await convert(validatedOptions);
29
+ }
30
+ main().catch((error) => {
31
+ console.log(error);
32
+ process.exit(1); // eslint-disable-line
33
+ });
34
+ /**
35
+ * Output for `npx tile-converter --help`
36
+ */
37
+ function printHelp() {
38
+ console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');
39
+ console.log('--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]');
40
+ console.log('--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]');
41
+ console.log('--name [Tileset name]');
42
+ console.log('--output [Output folder, default: "data" folder]');
43
+ console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
44
+ console.log('--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]');
45
+ console.log('--input-type [tileset input type: I3S or 3DTILES]');
46
+ console.log('--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]');
47
+ console.log('--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"');
48
+ console.log('--token [Token for Cesium ION tilesets authentication]');
49
+ console.log('--no-draco [Disable draco compression for geometry]');
50
+ console.log('--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]');
51
+ console.log('--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]');
52
+ console.log('--validate [Enable validation]');
53
+ process.exit(0); // eslint-disable-line
54
+ }
55
+ /**
56
+ * Run conversion process
57
+ * @param options validated tile-converter options
58
+ */
59
+ async function convert(options) {
60
+ console.log(`------------------------------------------------`); // eslint-disable-line
61
+ console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line
62
+ console.log(`------------------------------------------------`); // eslint-disable-line
63
+ const inputType = options.inputType.toUpperCase();
64
+ switch (inputType) {
65
+ case TILESET_TYPE.I3S:
66
+ const tiles3DConverter = new tile_converter_1.Tiles3DConverter();
67
+ tiles3DConverter.convert({
68
+ inputUrl: options.tileset,
69
+ outputPath: options.output,
70
+ tilesetName: options.name,
71
+ maxDepth: options.maxDepth,
72
+ egmFilePath: options.egm
73
+ });
74
+ break;
75
+ case TILESET_TYPE._3DTILES:
76
+ const converter = new tile_converter_1.I3SConverter();
77
+ await converter.convert({
78
+ inputUrl: options.tileset,
79
+ outputPath: options.output,
80
+ tilesetName: options.name,
81
+ maxDepth: options.maxDepth,
82
+ slpk: options.slpk,
83
+ sevenZipExe: options.sevenZipExe,
84
+ egmFilePath: options.egm,
85
+ token: options.token,
86
+ draco: options.draco,
87
+ generateTextures: options.generateTextures,
88
+ generateBoundingVolumes: options.generateBoundingVolumes,
89
+ validate: options.validate
90
+ });
91
+ break;
92
+ default:
93
+ printHelp();
94
+ }
95
+ }
96
+ // OPTIONS
97
+ /**
98
+ * Validate input options of the CLI command
99
+ * @param options - input options of the CLI command
100
+ * @returns validated options
101
+ */
102
+ function validateOptions(options) {
103
+ const mandatoryOptionsWithExceptions = {
104
+ name: () => console.log('Missed: --name [Tileset name]'),
105
+ output: () => console.log('Missed: --output [Output path name]'),
106
+ sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),
107
+ egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),
108
+ tileset: () => console.log('Missed: --tileset [tileset.json file]'),
109
+ inputType: () => console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')
110
+ };
111
+ const exceptions = [];
112
+ for (const mandatoryOption in mandatoryOptionsWithExceptions) {
113
+ const optionValue = options[mandatoryOption];
114
+ const isWrongInputType = Boolean(optionValue) &&
115
+ mandatoryOption === 'inputType' &&
116
+ !Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());
117
+ if (!optionValue || isWrongInputType) {
118
+ exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
119
+ }
120
+ }
121
+ if (exceptions.length) {
122
+ exceptions.forEach((exeption) => exeption());
123
+ process.exit(0); // eslint-disable-line
124
+ }
125
+ return options;
126
+ }
127
+ /**
128
+ * Parse option from the cli arguments array
129
+ * @param args
130
+ * @returns
131
+ */
132
+ function parseOptions(args) {
133
+ const opts = {
134
+ output: 'data',
135
+ sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
136
+ egm: (0, path_1.join)(process.cwd(), 'deps', 'egm2008-5.pgm'),
137
+ draco: true,
138
+ installDependencies: false,
139
+ generateTextures: false,
140
+ generateBoundingVolumes: false,
141
+ validate: false,
142
+ slpk: false
143
+ };
144
+ // eslint-disable-next-line complexity
145
+ args.forEach((arg, index) => {
146
+ if (arg.indexOf('--') === 0) {
147
+ switch (arg) {
148
+ case '--input-type':
149
+ opts.inputType = getStringValue(index, args);
150
+ break;
151
+ case '--tileset':
152
+ opts.tileset = getStringValue(index, args);
153
+ break;
154
+ case '--name':
155
+ opts.name = getStringValue(index, args);
156
+ break;
157
+ case '--output':
158
+ opts.output = getStringValue(index, args);
159
+ break;
160
+ case '--max-depth':
161
+ opts.maxDepth = getIntegerValue(index, args);
162
+ break;
163
+ case '--slpk':
164
+ opts.slpk = true;
165
+ break;
166
+ case '--7zExe':
167
+ opts.sevenZipExe = getStringValue(index, args);
168
+ break;
169
+ case '--egm':
170
+ opts.egm = getStringValue(index, args);
171
+ break;
172
+ case '--token':
173
+ opts.token = getStringValue(index, args);
174
+ break;
175
+ case '--no-draco':
176
+ opts.draco = false;
177
+ break;
178
+ case '--validate':
179
+ opts.validate = true;
180
+ break;
181
+ case '--install-dependencies':
182
+ opts.installDependencies = true;
183
+ break;
184
+ case '--generate-textures':
185
+ opts.generateTextures = true;
186
+ break;
187
+ case '--generate-bounding-volumes':
188
+ opts.generateBoundingVolumes = true;
189
+ break;
190
+ case '--help':
191
+ printHelp();
192
+ break;
193
+ default:
194
+ console.warn(`Unknown option ${arg}`);
195
+ process.exit(0); // eslint-disable-line
196
+ }
197
+ }
198
+ });
199
+ return opts;
200
+ }
201
+ /**
202
+ * Get string option value from cli arguments
203
+ * @param index - option's name index in the argument's array.
204
+ * The value of the option should be next to name of the option.
205
+ * @param args - cli arguments array
206
+ * @returns - string value of the option
207
+ */
208
+ function getStringValue(index, args) {
209
+ if (index + 1 >= args.length) {
210
+ return '';
211
+ }
212
+ const value = args[index + 1];
213
+ if (value.indexOf('--') === 0) {
214
+ return '';
215
+ }
216
+ return value;
217
+ }
218
+ /**
219
+ * Get integer option value from cli arguments
220
+ * @param index - option's name index in the argument's array
221
+ * The value of the option should be next to name of the option.
222
+ * @param args - cli arguments array
223
+ * @returns - number value of the option
224
+ */
225
+ function getIntegerValue(index, args) {
226
+ const stringValue = getStringValue(index, args);
227
+ const result = Number.parseInt(stringValue);
228
+ if (isFinite(result)) {
229
+ return result;
230
+ }
231
+ return NaN;
232
+ }