@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.0-alpha.4
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.d.ts +28 -0
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/3d-tiles-attributes-worker.js +4 -0
- package/dist/3d-tiles-attributes-worker.js.map +7 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +34 -3
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -4
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +10 -10
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- 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 +910 -790
- package/dist/es5/3d-tiles-attributes-worker.js +29 -0
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +116 -46
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/constants.js +9 -0
- package/dist/es5/constants.js.map +1 -0
- 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 +29 -0
- package/dist/es5/i3s-attributes-worker.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +271 -182
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +293 -223
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/index.js +0 -16
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +14 -17
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +39 -14
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +61 -0
- package/dist/es5/lib/utils/queue.js.map +1 -0
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +225 -0
- package/dist/es5/lib/utils/write-queue.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/workers/i3s-attributes-worker.js +40 -0
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +16 -0
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +36 -4
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +16 -18
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- 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 +16 -0
- package/dist/esm/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +121 -62
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +157 -52
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +6 -8
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +11 -1
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +19 -0
- package/dist/esm/lib/utils/queue.js.map +1 -0
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +88 -0
- package/dist/esm/lib/utils/write-queue.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/workers/i3s-attributes-worker.js +4 -0
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/i3s-attributes-worker.d.ts +33 -0
- package/dist/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/i3s-attributes-worker.js +10 -0
- package/dist/i3s-attributes-worker.js.map +7 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +223 -113
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +13 -8
- package/dist/i3s-converter/i3s-converter.d.ts +7 -5
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +126 -40
- package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +24 -0
- package/dist/i3s-converter/types.d.ts +83 -8
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/lib/utils/compress-util.d.ts +44 -5
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +73 -6
- package/dist/lib/utils/file-utils.d.ts +34 -5
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +40 -1
- package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/lib/utils/lod-conversion-utils.js +21 -2
- package/dist/lib/utils/queue.d.ts +7 -0
- package/dist/lib/utils/queue.d.ts.map +1 -0
- package/dist/lib/utils/queue.js +18 -0
- package/dist/lib/utils/statistic-utills.d.ts +2 -2
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.d.ts +22 -0
- package/dist/lib/utils/write-queue.d.ts.map +1 -0
- package/dist/lib/utils/write-queue.js +62 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/workers/3d-tiles-attributes-worker.js +9 -0
- package/dist/workers/i3s-attributes-worker.d.ts +2 -0
- package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/workers/i3s-attributes-worker.js +5 -0
- package/package.json +23 -18
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +50 -5
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
- package/src/constants.ts +2 -0
- package/src/converter-cli.ts +310 -0
- package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
- package/src/i3s-attributes-worker.ts +46 -0
- package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
- package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
- package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +425 -179
- package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
- package/src/i3s-converter/helpers/node-pages.ts +25 -17
- package/src/i3s-converter/i3s-converter.ts +150 -90
- package/src/i3s-converter/json-templates/layers.ts +25 -0
- package/src/i3s-converter/types.ts +90 -8
- package/src/index.ts +0 -4
- package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
- package/src/lib/utils/file-utils.ts +84 -0
- package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
- package/src/lib/utils/queue.ts +17 -0
- package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
- package/src/lib/utils/write-queue.ts +75 -0
- package/src/workers/3d-tiles-attributes-worker.ts +6 -0
- package/src/workers/i3s-attributes-worker.ts +6 -0
- package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
- package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/es5/lib/utils/compress-util.d.ts +0 -53
- package/dist/es5/lib/utils/file-utils.d.ts +0 -43
- package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/esm/lib/utils/compress-util.d.ts +0 -53
- package/dist/esm/lib/utils/file-utils.d.ts +0 -43
- package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/src/deps-installer/deps-installer.d.ts +0 -10
- package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/src/lib/utils/compress-util.d.ts +0 -53
- package/src/lib/utils/file-utils.d.ts +0 -43
- package/src/lib/utils/file-utils.js +0 -38
- package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import '@loaders.gl/polyfills';
|
|
3
|
+
import {join} from 'path';
|
|
4
|
+
import {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';
|
|
5
|
+
import {DepsInstaller} from './deps-installer/deps-installer';
|
|
6
|
+
|
|
7
|
+
type TileConversionOptions = {
|
|
8
|
+
/** "I3S" - for I3S to 3DTiles conversion, "3DTILES" for 3DTiles to I3S conversion */
|
|
9
|
+
inputType?: string;
|
|
10
|
+
/** "tileset.json" file (3DTiles) / "http://..../SceneServer/layers/0" resource (I3S) */
|
|
11
|
+
tileset?: string;
|
|
12
|
+
/** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.
|
|
15
|
+
* Default: "data" folder */
|
|
16
|
+
output: string;
|
|
17
|
+
/** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: "C:\Program Files\7-Zip\7z.exe" */
|
|
18
|
+
sevenZipExe: string;
|
|
19
|
+
/** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,
|
|
20
|
+
* default: "./deps/egm2008-5.pgm". A model file can be loaded from GeographicLib
|
|
21
|
+
* https://geographiclib.sourceforge.io/html/geoid.html */
|
|
22
|
+
egm: string;
|
|
23
|
+
/** 3DTile->I3S only. Token for Cesium ION tileset authentication. */
|
|
24
|
+
token?: string;
|
|
25
|
+
/** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */
|
|
26
|
+
draco: boolean;
|
|
27
|
+
/** Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is
|
|
28
|
+
* implemented */
|
|
29
|
+
installDependencies: boolean;
|
|
30
|
+
/** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture
|
|
31
|
+
* if only KTX2 is provided */
|
|
32
|
+
generateTextures: boolean;
|
|
33
|
+
/** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */
|
|
34
|
+
generateBoundingVolumes: boolean;
|
|
35
|
+
/** Validate the dataset during conversion. Validation messages will be posted in the console output */
|
|
36
|
+
validate: boolean;
|
|
37
|
+
/** Maximal depth of the hierarchical tiles tree traversal, default: infinite */
|
|
38
|
+
maxDepth?: number;
|
|
39
|
+
/** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */
|
|
40
|
+
slpk: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/* During validation we check that particular options are defined so they can't be undefined */
|
|
44
|
+
type ValidatedTileConversionOptions = TileConversionOptions & {
|
|
45
|
+
/** "I3S" - for I3S to 3DTiles conversion, "3DTILES" for 3DTiles to I3S conversion */
|
|
46
|
+
inputType: string;
|
|
47
|
+
/** "tileset.json" file (3DTiles) / "http://..../SceneServer/layers/0" resource (I3S) */
|
|
48
|
+
tileset: string;
|
|
49
|
+
/** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const TILESET_TYPE = {
|
|
54
|
+
I3S: 'I3S',
|
|
55
|
+
_3DTILES: '3DTILES'
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* CLI entry
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
async function main() {
|
|
63
|
+
const [, , ...args] = process.argv;
|
|
64
|
+
|
|
65
|
+
if (args.length === 0) {
|
|
66
|
+
printHelp();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const options: TileConversionOptions = parseOptions(args);
|
|
70
|
+
|
|
71
|
+
if (options.installDependencies) {
|
|
72
|
+
const depthInstaller = new DepsInstaller();
|
|
73
|
+
depthInstaller.install('deps');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);
|
|
78
|
+
|
|
79
|
+
await convert(validatedOptions);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
main().catch((error) => {
|
|
83
|
+
console.log(error);
|
|
84
|
+
process.exit(1); // eslint-disable-line
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Output for `npx tile-converter --help`
|
|
89
|
+
*/
|
|
90
|
+
function printHelp(): void {
|
|
91
|
+
console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');
|
|
92
|
+
console.log(
|
|
93
|
+
'--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]'
|
|
94
|
+
);
|
|
95
|
+
console.log(
|
|
96
|
+
'--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'
|
|
97
|
+
);
|
|
98
|
+
console.log('--name [Tileset name]');
|
|
99
|
+
console.log('--output [Output folder, default: "data" folder]');
|
|
100
|
+
console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
|
|
101
|
+
console.log(
|
|
102
|
+
'--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'
|
|
103
|
+
);
|
|
104
|
+
console.log('--input-type [tileset input type: I3S or 3DTILES]');
|
|
105
|
+
console.log(
|
|
106
|
+
'--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]'
|
|
107
|
+
);
|
|
108
|
+
console.log(
|
|
109
|
+
'--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"'
|
|
110
|
+
);
|
|
111
|
+
console.log('--token [Token for Cesium ION tilesets authentication]');
|
|
112
|
+
console.log('--no-draco [Disable draco compression for geometry]');
|
|
113
|
+
console.log(
|
|
114
|
+
'--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'
|
|
115
|
+
);
|
|
116
|
+
console.log(
|
|
117
|
+
'--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]'
|
|
118
|
+
);
|
|
119
|
+
console.log('--validate [Enable validation]');
|
|
120
|
+
process.exit(0); // eslint-disable-line
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Run conversion process
|
|
125
|
+
* @param options validated tile-converter options
|
|
126
|
+
*/
|
|
127
|
+
async function convert(options: ValidatedTileConversionOptions) {
|
|
128
|
+
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
129
|
+
console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line
|
|
130
|
+
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
131
|
+
const inputType = options.inputType.toUpperCase();
|
|
132
|
+
switch (inputType) {
|
|
133
|
+
case TILESET_TYPE.I3S:
|
|
134
|
+
const tiles3DConverter = new Tiles3DConverter();
|
|
135
|
+
tiles3DConverter.convert({
|
|
136
|
+
inputUrl: options.tileset,
|
|
137
|
+
outputPath: options.output,
|
|
138
|
+
tilesetName: options.name,
|
|
139
|
+
maxDepth: options.maxDepth,
|
|
140
|
+
egmFilePath: options.egm
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
case TILESET_TYPE._3DTILES:
|
|
144
|
+
const converter = new I3SConverter();
|
|
145
|
+
await converter.convert({
|
|
146
|
+
inputUrl: options.tileset,
|
|
147
|
+
outputPath: options.output,
|
|
148
|
+
tilesetName: options.name,
|
|
149
|
+
maxDepth: options.maxDepth,
|
|
150
|
+
slpk: options.slpk,
|
|
151
|
+
sevenZipExe: options.sevenZipExe,
|
|
152
|
+
egmFilePath: options.egm,
|
|
153
|
+
token: options.token,
|
|
154
|
+
draco: options.draco,
|
|
155
|
+
generateTextures: options.generateTextures,
|
|
156
|
+
generateBoundingVolumes: options.generateBoundingVolumes,
|
|
157
|
+
validate: options.validate
|
|
158
|
+
});
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
printHelp();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// OPTIONS
|
|
166
|
+
/**
|
|
167
|
+
* Validate input options of the CLI command
|
|
168
|
+
* @param options - input options of the CLI command
|
|
169
|
+
* @returns validated options
|
|
170
|
+
*/
|
|
171
|
+
function validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {
|
|
172
|
+
const mandatoryOptionsWithExceptions: {
|
|
173
|
+
[key: string]: () => void;
|
|
174
|
+
} = {
|
|
175
|
+
name: () => console.log('Missed: --name [Tileset name]'),
|
|
176
|
+
output: () => console.log('Missed: --output [Output path name]'),
|
|
177
|
+
sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),
|
|
178
|
+
egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),
|
|
179
|
+
tileset: () => console.log('Missed: --tileset [tileset.json file]'),
|
|
180
|
+
inputType: () =>
|
|
181
|
+
console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')
|
|
182
|
+
};
|
|
183
|
+
const exceptions: (() => void)[] = [];
|
|
184
|
+
for (const mandatoryOption in mandatoryOptionsWithExceptions) {
|
|
185
|
+
const optionValue = options[mandatoryOption];
|
|
186
|
+
const isWrongInputType =
|
|
187
|
+
Boolean(optionValue) &&
|
|
188
|
+
mandatoryOption === 'inputType' &&
|
|
189
|
+
!Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());
|
|
190
|
+
|
|
191
|
+
if (!optionValue || isWrongInputType) {
|
|
192
|
+
exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (exceptions.length) {
|
|
196
|
+
exceptions.forEach((exeption) => exeption());
|
|
197
|
+
process.exit(0); // eslint-disable-line
|
|
198
|
+
}
|
|
199
|
+
return <ValidatedTileConversionOptions>options;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Parse option from the cli arguments array
|
|
204
|
+
* @param args
|
|
205
|
+
* @returns
|
|
206
|
+
*/
|
|
207
|
+
function parseOptions(args: string[]): TileConversionOptions {
|
|
208
|
+
const opts: TileConversionOptions = {
|
|
209
|
+
output: 'data',
|
|
210
|
+
sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
|
|
211
|
+
egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),
|
|
212
|
+
draco: true,
|
|
213
|
+
installDependencies: false,
|
|
214
|
+
generateTextures: false,
|
|
215
|
+
generateBoundingVolumes: false,
|
|
216
|
+
validate: false,
|
|
217
|
+
slpk: false
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// eslint-disable-next-line complexity
|
|
221
|
+
args.forEach((arg, index) => {
|
|
222
|
+
if (arg.indexOf('--') === 0) {
|
|
223
|
+
switch (arg) {
|
|
224
|
+
case '--input-type':
|
|
225
|
+
opts.inputType = getStringValue(index, args);
|
|
226
|
+
break;
|
|
227
|
+
case '--tileset':
|
|
228
|
+
opts.tileset = getStringValue(index, args);
|
|
229
|
+
break;
|
|
230
|
+
case '--name':
|
|
231
|
+
opts.name = getStringValue(index, args);
|
|
232
|
+
break;
|
|
233
|
+
case '--output':
|
|
234
|
+
opts.output = getStringValue(index, args);
|
|
235
|
+
break;
|
|
236
|
+
case '--max-depth':
|
|
237
|
+
opts.maxDepth = getIntegerValue(index, args);
|
|
238
|
+
break;
|
|
239
|
+
case '--slpk':
|
|
240
|
+
opts.slpk = true;
|
|
241
|
+
break;
|
|
242
|
+
case '--7zExe':
|
|
243
|
+
opts.sevenZipExe = getStringValue(index, args);
|
|
244
|
+
break;
|
|
245
|
+
case '--egm':
|
|
246
|
+
opts.egm = getStringValue(index, args);
|
|
247
|
+
break;
|
|
248
|
+
case '--token':
|
|
249
|
+
opts.token = getStringValue(index, args);
|
|
250
|
+
break;
|
|
251
|
+
case '--no-draco':
|
|
252
|
+
opts.draco = false;
|
|
253
|
+
break;
|
|
254
|
+
case '--validate':
|
|
255
|
+
opts.validate = true;
|
|
256
|
+
break;
|
|
257
|
+
case '--install-dependencies':
|
|
258
|
+
opts.installDependencies = true;
|
|
259
|
+
break;
|
|
260
|
+
case '--generate-textures':
|
|
261
|
+
opts.generateTextures = true;
|
|
262
|
+
break;
|
|
263
|
+
case '--generate-bounding-volumes':
|
|
264
|
+
opts.generateBoundingVolumes = true;
|
|
265
|
+
break;
|
|
266
|
+
case '--help':
|
|
267
|
+
printHelp();
|
|
268
|
+
break;
|
|
269
|
+
default:
|
|
270
|
+
console.warn(`Unknown option ${arg}`);
|
|
271
|
+
process.exit(0); // eslint-disable-line
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return opts;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Get string option value from cli arguments
|
|
280
|
+
* @param index - option's name index in the argument's array.
|
|
281
|
+
* The value of the option should be next to name of the option.
|
|
282
|
+
* @param args - cli arguments array
|
|
283
|
+
* @returns - string value of the option
|
|
284
|
+
*/
|
|
285
|
+
function getStringValue(index: number, args: string[]): string {
|
|
286
|
+
if (index + 1 >= args.length) {
|
|
287
|
+
return '';
|
|
288
|
+
}
|
|
289
|
+
const value = args[index + 1];
|
|
290
|
+
if (value.indexOf('--') === 0) {
|
|
291
|
+
return '';
|
|
292
|
+
}
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get integer option value from cli arguments
|
|
298
|
+
* @param index - option's name index in the argument's array
|
|
299
|
+
* The value of the option should be next to name of the option.
|
|
300
|
+
* @param args - cli arguments array
|
|
301
|
+
* @returns - number value of the option
|
|
302
|
+
*/
|
|
303
|
+
function getIntegerValue(index: number, args: string[]): number {
|
|
304
|
+
const stringValue: string = getStringValue(index, args);
|
|
305
|
+
const result: number = Number.parseInt(stringValue);
|
|
306
|
+
if (isFinite(result)) {
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
return NaN;
|
|
310
|
+
}
|
|
@@ -5,8 +5,18 @@ import {join} from 'path';
|
|
|
5
5
|
|
|
6
6
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Install external dependencies for converter:
|
|
10
|
+
* * PGM file (implemented);
|
|
11
|
+
* * Draco library (not implemented);
|
|
12
|
+
* * 7z archiver (not implemented);
|
|
13
|
+
*/
|
|
8
14
|
export class DepsInstaller {
|
|
9
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Run instalation
|
|
17
|
+
* @param path destination folder
|
|
18
|
+
*/
|
|
19
|
+
async install(path: string = ''): Promise<void> {
|
|
10
20
|
console.log('Installing "EGM2008-5" model...'); // eslint-disable-line no-console
|
|
11
21
|
const fileMap = await load(PGM_LINK, ZipLoader, {});
|
|
12
22
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {WorkerObject} from '@loaders.gl/worker-utils';
|
|
2
|
+
import type {ConvertedAttributes} from './i3s-converter/types';
|
|
3
|
+
import type {Matrix4, Vector3} from '@math.gl/core';
|
|
4
|
+
|
|
5
|
+
import {processOnWorker} from '@loaders.gl/worker-utils';
|
|
6
|
+
|
|
7
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
10
|
+
|
|
11
|
+
export type I3SAttributesWorkerOptions = {
|
|
12
|
+
useCartesianPositions: boolean;
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type B3DMAttributesData = {
|
|
17
|
+
gltfMaterials?: {id: string}[];
|
|
18
|
+
nodes: any;
|
|
19
|
+
cartographicOrigin: Vector3;
|
|
20
|
+
cartesianModelMatrix: Matrix4;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* I3S Attributes Worker to handle B3DM object
|
|
25
|
+
*/
|
|
26
|
+
export const I3SAttributesWorker = {
|
|
27
|
+
id: 'i3s-attributes',
|
|
28
|
+
name: 'I3S Attributes Worker',
|
|
29
|
+
module: 'tile-converter',
|
|
30
|
+
version: VERSION,
|
|
31
|
+
options: {
|
|
32
|
+
useCartesianPositions: false
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Performs I3S attributes transformation
|
|
38
|
+
*/
|
|
39
|
+
export function transformI3SAttributesOnWorker(
|
|
40
|
+
attributesData: B3DMAttributesData,
|
|
41
|
+
options: I3SAttributesWorkerOptions
|
|
42
|
+
): Promise<Map<string, ConvertedAttributes>> {
|
|
43
|
+
return processOnWorker(I3SAttributesWorker, attributesData, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {BoundingVolumes,
|
|
1
|
+
import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';
|
|
2
2
|
|
|
3
3
|
import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
|
|
4
4
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
5
5
|
import {
|
|
6
6
|
OrientedBoundingBox,
|
|
7
7
|
makeOrientedBoundingBoxFromPoints,
|
|
8
|
-
makeBoundingSphereFromPoints
|
|
8
|
+
makeBoundingSphereFromPoints,
|
|
9
|
+
BoundingSphere
|
|
9
10
|
} from '@math.gl/culling';
|
|
10
11
|
import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
|
|
11
12
|
import {Geoid} from '@math.gl/geoid';
|
|
12
|
-
import {Tileset3D} from '@loaders.gl/tiles';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Create bounding volumes object from tile and geoid height model.
|
|
@@ -101,34 +101,39 @@ export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
* Convert common coordinate to
|
|
105
|
-
* @param
|
|
106
|
-
* @
|
|
107
|
-
* @
|
|
104
|
+
* Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
|
|
105
|
+
* @param
|
|
106
|
+
* @param boundingVolume
|
|
107
|
+
* @returns - fullExtent object
|
|
108
108
|
*/
|
|
109
|
-
export function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
export function convertBoundingVolumeToI3SFullExtent(
|
|
110
|
+
boundingVolume: OrientedBoundingBox | BoundingSphere
|
|
111
|
+
): FullExtent {
|
|
112
|
+
let sphere: BoundingSphere;
|
|
113
|
+
if (boundingVolume instanceof BoundingSphere) {
|
|
114
|
+
sphere = boundingVolume;
|
|
115
|
+
} else {
|
|
116
|
+
sphere = boundingVolume.getBoundingSphere();
|
|
113
117
|
}
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
118
|
+
const center: Vector3 = sphere.center;
|
|
119
|
+
const radius: number = sphere.radius;
|
|
120
|
+
const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(
|
|
121
|
+
new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),
|
|
117
122
|
new Vector3()
|
|
118
123
|
);
|
|
119
|
-
const
|
|
120
|
-
new Vector3(
|
|
124
|
+
const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(
|
|
125
|
+
new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),
|
|
121
126
|
new Vector3()
|
|
122
127
|
);
|
|
123
|
-
const isFirstRight = rightTop[0] < leftBottom[0];
|
|
124
|
-
const isFirstTop = rightTop[1] < leftBottom[1];
|
|
125
128
|
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
return {
|
|
130
|
+
xmin: vertexMin[0],
|
|
131
|
+
xmax: vertexMax[0],
|
|
132
|
+
ymin: vertexMin[1],
|
|
133
|
+
ymax: vertexMax[1],
|
|
134
|
+
zmin: vertexMin[2],
|
|
135
|
+
zmax: vertexMax[2]
|
|
136
|
+
};
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {GeometryAttributes,
|
|
1
|
+
import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';
|
|
2
2
|
import {concatenateTypedArrays} from '@loaders.gl/loader-utils';
|
|
3
3
|
|
|
4
4
|
const VALUES_PER_VERTEX = 3;
|
|
@@ -9,8 +9,9 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
|
9
9
|
* @param attributes
|
|
10
10
|
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
11
11
|
*/
|
|
12
|
-
export function generateAttributes(attributes:
|
|
13
|
-
const {positions, normals, texCoords, colors, featureIndices
|
|
12
|
+
export function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {
|
|
13
|
+
const {positions, normals, texCoords, colors, featureIndices} = attributes;
|
|
14
|
+
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
14
15
|
|
|
15
16
|
if (!featureIndices.length) {
|
|
16
17
|
return {
|