@loaders.gl/tile-converter 3.2.0-alpha.2 → 3.2.0-alpha.3
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.
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/converter-cli.d.ts +2 -0
- package/dist/converter-cli.d.ts.map +1 -0
- package/dist/converter-cli.js +232 -0
- package/dist/converter.min.js +68 -68
- package/dist/deps-installer/deps-installer.d.ts +11 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +10 -0
- package/dist/dist.min.js +95 -162
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/converter-cli.js +306 -0
- package/dist/es5/converter-cli.js.map +1 -0
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +4 -4
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +64 -43
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/index.js +0 -24
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/converter-cli.js +230 -0
- package/dist/esm/converter-cli.js.map +1 -0
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +4 -4
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +44 -26
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.js +1 -1
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/geometry-converter.js +3 -3
- package/dist/i3s-converter/i3s-converter.d.ts +0 -2
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +34 -16
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -7
- package/package.json +16 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +1 -1
- package/src/converter-cli.ts +310 -0
- package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
- package/src/i3s-converter/helpers/geometry-converter.ts +4 -4
- package/src/i3s-converter/i3s-converter.ts +37 -25
- package/src/index.ts +0 -5
- package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
- package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
- package/src/deps-installer/deps-installer.d.ts +0 -10
|
@@ -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
|
+
}
|