@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.
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/3d-tiles-attributes-worker.js.map +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/3d-tiles-converter/3d-tiles-converter.js +5 -0
- 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 +147 -171
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +33 -22
- package/dist/es5/3d-tiles-converter/3d-tiles-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 +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +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 +84 -49
- 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 -24
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +7 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-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 +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +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 +57 -29
- 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 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/pgm-loader.js.map +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 +42 -18
- 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/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -7
- package/package.json +20 -18
- package/src/3d-tiles-converter/3d-tiles-converter.ts +7 -2
- 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-converter/helpers/geometry-converter.ts +4 -4
- package/src/i3s-converter/i3s-converter.ts +46 -29
- package/src/i3s-converter/json-templates/layers.ts +25 -0
- 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
|
@@ -234,15 +234,15 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
234
234
|
if (nodeMatrix) {
|
|
235
235
|
transformationMatrix = matrix.multiplyRight(nodeMatrix);
|
|
236
236
|
}
|
|
237
|
+
if (translation) {
|
|
238
|
+
transformationMatrix = transformationMatrix.translate(translation);
|
|
239
|
+
}
|
|
237
240
|
if (rotation) {
|
|
238
241
|
transformationMatrix = transformationMatrix.rotateXYZ(rotation);
|
|
239
242
|
}
|
|
240
243
|
if (scale) {
|
|
241
244
|
transformationMatrix = transformationMatrix.scale(scale);
|
|
242
245
|
}
|
|
243
|
-
if (translation) {
|
|
244
|
-
transformationMatrix = transformationMatrix.translate(translation);
|
|
245
|
-
}
|
|
246
246
|
return transformationMatrix;
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAEV,YAAY,EAYb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,2BAA2B,CAAC;AAM7F,OAAO,UAAU,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"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"}
|
|
@@ -30,7 +30,8 @@ const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
|
30
30
|
const draco_1 = require("@loaders.gl/draco");
|
|
31
31
|
const write_queue_1 = __importDefault(require("../lib/utils/write-queue"));
|
|
32
32
|
const i3s_attributes_worker_1 = require("../i3s-attributes-worker");
|
|
33
|
-
const
|
|
33
|
+
const constants_1 = require("../constants");
|
|
34
|
+
const ION_DEFAULT_TOKEN = process_1.default.env?.IonToken || // eslint-disable-line
|
|
34
35
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line
|
|
35
36
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
36
37
|
const _3D_TILES = '3DTILES';
|
|
@@ -87,6 +88,10 @@ class I3SConverter {
|
|
|
87
88
|
* @param options.validate -enable validation
|
|
88
89
|
*/
|
|
89
90
|
async convert(options) {
|
|
91
|
+
if (core_1.isBrowser) {
|
|
92
|
+
console.log(constants_1.BROWSER_ERROR_MESSAGE);
|
|
93
|
+
return constants_1.BROWSER_ERROR_MESSAGE;
|
|
94
|
+
}
|
|
90
95
|
this.conversionStartTime = process_1.default.hrtime();
|
|
91
96
|
const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes } = options;
|
|
92
97
|
this.options = { maxDepth, slpk, sevenZipExe, egmFilePath, draco, token, inputUrl };
|
|
@@ -103,21 +108,28 @@ class I3SConverter {
|
|
|
103
108
|
this.nodePages.useWriteFunction(file_utils_1.writeFileForSlpk);
|
|
104
109
|
}
|
|
105
110
|
await this.loadWorkers();
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
try {
|
|
112
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
113
|
+
const tilesetOptions = { loadOptions: { basis: { format: 'rgba32' } } };
|
|
114
|
+
if (preloadOptions.headers) {
|
|
115
|
+
tilesetOptions.loadOptions.fetch = { headers: preloadOptions.headers };
|
|
116
|
+
}
|
|
117
|
+
Object.assign(tilesetOptions, preloadOptions);
|
|
118
|
+
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
119
|
+
// console.log(tilesetJson); // eslint-disable-line
|
|
120
|
+
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
121
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
122
|
+
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
123
|
+
return sourceTilesetJson;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
// Clean up worker pools
|
|
130
|
+
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
131
|
+
workerFarm.destroy();
|
|
110
132
|
}
|
|
111
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
112
|
-
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
113
|
-
// console.log(tilesetJson); // eslint-disable-line
|
|
114
|
-
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
115
|
-
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
116
|
-
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
117
|
-
// Clean up worker pools
|
|
118
|
-
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
119
|
-
workerFarm.destroy();
|
|
120
|
-
return sourceTilesetJson;
|
|
121
133
|
}
|
|
122
134
|
/**
|
|
123
135
|
* Convert and save the layer and embedded tiles
|
|
@@ -179,7 +191,8 @@ class I3SConverter {
|
|
|
179
191
|
nodePages: {
|
|
180
192
|
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
181
193
|
},
|
|
182
|
-
compressGeometry: this.options.draco
|
|
194
|
+
compressGeometry: this.options.draco,
|
|
195
|
+
fullExtent
|
|
183
196
|
};
|
|
184
197
|
this.layers0 = (0, json_map_transform_1.default)(layers0data, (0, layers_1.LAYERS)());
|
|
185
198
|
}
|
|
@@ -694,7 +707,12 @@ class I3SConverter {
|
|
|
694
707
|
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
695
708
|
if (this.generateTextures) {
|
|
696
709
|
formats.push({ name: '1', format: 'ktx2' });
|
|
697
|
-
const ktx2TextureData =
|
|
710
|
+
const ktx2TextureData = (0, core_1.encode)(texture.image, textures_1.KTX2BasisWriterWorker, {
|
|
711
|
+
...textures_1.KTX2BasisWriterWorker.options,
|
|
712
|
+
source: this.workerSource.ktx2,
|
|
713
|
+
reuseWorkers: true,
|
|
714
|
+
_nodeWorkers: true
|
|
715
|
+
});
|
|
698
716
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
699
717
|
}
|
|
700
718
|
break;
|
|
@@ -704,7 +722,7 @@ class I3SConverter {
|
|
|
704
722
|
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
705
723
|
if (this.generateTextures) {
|
|
706
724
|
formats.push({ name: '0', format: 'jpg' });
|
|
707
|
-
const decodedFromKTX2TextureData =
|
|
725
|
+
const decodedFromKTX2TextureData = (0, core_1.encode)(texture.image.data[0], images_1.ImageWriter);
|
|
708
726
|
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
709
727
|
}
|
|
710
728
|
}
|
|
@@ -1046,6 +1064,12 @@ class I3SConverter {
|
|
|
1046
1064
|
const source = await sourceResponse.text();
|
|
1047
1065
|
this.workerSource.draco = source;
|
|
1048
1066
|
}
|
|
1067
|
+
if (this.generateTextures) {
|
|
1068
|
+
const url = (0, worker_utils_1.getWorkerURL)(textures_1.KTX2BasisWriterWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1069
|
+
const sourceResponse = await (0, core_1.fetchFile)(url);
|
|
1070
|
+
const source = await sourceResponse.text();
|
|
1071
|
+
this.workerSource.ktx2 = source;
|
|
1072
|
+
}
|
|
1049
1073
|
const i3sAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(i3s_attributes_worker_1.I3SAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1050
1074
|
const sourceResponse = await (0, core_1.fetchFile)(i3sAttributesWorkerUrl);
|
|
1051
1075
|
const source = await sourceResponse.text();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"AA0IA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFjB,CAAC"}
|
|
@@ -113,6 +113,26 @@ const NODE_PAGES = () => ({
|
|
|
113
113
|
default: 'maxScreenThresholdSQ'
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
+
const FULL_EXTENT = () => ({
|
|
117
|
+
xmin: {
|
|
118
|
+
path: 'xmin'
|
|
119
|
+
},
|
|
120
|
+
ymin: {
|
|
121
|
+
path: 'ymin'
|
|
122
|
+
},
|
|
123
|
+
xmax: {
|
|
124
|
+
path: 'xmax'
|
|
125
|
+
},
|
|
126
|
+
ymax: {
|
|
127
|
+
path: 'ymax'
|
|
128
|
+
},
|
|
129
|
+
zmin: {
|
|
130
|
+
path: 'zmin'
|
|
131
|
+
},
|
|
132
|
+
zmax: {
|
|
133
|
+
path: 'zmax'
|
|
134
|
+
}
|
|
135
|
+
});
|
|
116
136
|
const LAYERS = () => ({
|
|
117
137
|
version: {
|
|
118
138
|
path: 'version',
|
|
@@ -145,6 +165,10 @@ const LAYERS = () => ({
|
|
|
145
165
|
path: 'store',
|
|
146
166
|
transform: (val) => (0, json_map_transform_1.default)(val, store_1.STORE)
|
|
147
167
|
},
|
|
168
|
+
fullExtent: {
|
|
169
|
+
path: 'fullExtent',
|
|
170
|
+
transform: (val) => (0, json_map_transform_1.default)(val, FULL_EXTENT())
|
|
171
|
+
},
|
|
148
172
|
heightModelInfo: {
|
|
149
173
|
path: 'heightModelInfo',
|
|
150
174
|
transform: (val) => (0, json_map_transform_1.default)(val, HEIGHT_MODEL_INFO())
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
2
|
-
export { default as NodePages } from './i3s-converter/helpers/node-pages';
|
|
3
2
|
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
4
|
-
export { DepsInstaller } from './deps-installer/deps-installer';
|
|
5
|
-
export { prepareDataForAttributesConversion } from './i3s-converter/helpers/gltf-attributes';
|
|
6
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Tiles3DConverter = exports.I3SConverter = void 0;
|
|
7
7
|
var i3s_converter_1 = require("./i3s-converter/i3s-converter");
|
|
8
8
|
Object.defineProperty(exports, "I3SConverter", { enumerable: true, get: function () { return __importDefault(i3s_converter_1).default; } });
|
|
9
|
-
var node_pages_1 = require("./i3s-converter/helpers/node-pages");
|
|
10
|
-
Object.defineProperty(exports, "NodePages", { enumerable: true, get: function () { return __importDefault(node_pages_1).default; } });
|
|
11
9
|
var _3d_tiles_converter_1 = require("./3d-tiles-converter/3d-tiles-converter");
|
|
12
10
|
Object.defineProperty(exports, "Tiles3DConverter", { enumerable: true, get: function () { return __importDefault(_3d_tiles_converter_1).default; } });
|
|
13
|
-
var deps_installer_1 = require("./deps-installer/deps-installer");
|
|
14
|
-
Object.defineProperty(exports, "DepsInstaller", { enumerable: true, get: function () { return deps_installer_1.DepsInstaller; } });
|
|
15
|
-
var gltf_attributes_1 = require("./i3s-converter/helpers/gltf-attributes");
|
|
16
|
-
Object.defineProperty(exports, "prepareDataForAttributesConversion", { enumerable: true, get: function () { return gltf_attributes_1.prepareDataForAttributesConversion; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "3.2.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,30 +30,32 @@
|
|
|
30
30
|
"README.md"
|
|
31
31
|
],
|
|
32
32
|
"browser": {
|
|
33
|
-
"fs": false
|
|
33
|
+
"fs": false,
|
|
34
|
+
"path": false,
|
|
35
|
+
"process": false,
|
|
36
|
+
"archiver": false
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"pre-build": "npm run build-bundle && npm run build-converter-bundle && npm run build-i3s-attributes-worker && npm run build-3d-tiles-attributes-worker",
|
|
37
40
|
"build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
|
|
38
41
|
"build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
|
|
39
|
-
"build-bin": "BABEL_ENV=es5 babel scripts --config-file ../../babel.config.js --out-dir dist/scripts",
|
|
40
42
|
"build-i3s-attributes-worker": "esbuild src/workers/i3s-attributes-worker.ts --outfile=dist/i3s-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
41
43
|
"build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@loaders.gl/3d-tiles": "3.2.0
|
|
45
|
-
"@loaders.gl/crypto": "3.2.0
|
|
46
|
-
"@loaders.gl/draco": "3.2.0
|
|
47
|
-
"@loaders.gl/gltf": "3.2.0
|
|
48
|
-
"@loaders.gl/i3s": "3.2.0
|
|
49
|
-
"@loaders.gl/images": "3.2.0
|
|
50
|
-
"@loaders.gl/loader-utils": "3.2.0
|
|
51
|
-
"@loaders.gl/polyfills": "3.2.0
|
|
52
|
-
"@loaders.gl/schema": "3.2.0
|
|
53
|
-
"@loaders.gl/textures": "3.2.0
|
|
54
|
-
"@loaders.gl/tiles": "3.2.0
|
|
55
|
-
"@loaders.gl/worker-utils": "3.2.0
|
|
56
|
-
"@loaders.gl/zip": "3.2.0
|
|
46
|
+
"@loaders.gl/3d-tiles": "3.2.0",
|
|
47
|
+
"@loaders.gl/crypto": "3.2.0",
|
|
48
|
+
"@loaders.gl/draco": "3.2.0",
|
|
49
|
+
"@loaders.gl/gltf": "3.2.0",
|
|
50
|
+
"@loaders.gl/i3s": "3.2.0",
|
|
51
|
+
"@loaders.gl/images": "3.2.0",
|
|
52
|
+
"@loaders.gl/loader-utils": "3.2.0",
|
|
53
|
+
"@loaders.gl/polyfills": "3.2.0",
|
|
54
|
+
"@loaders.gl/schema": "3.2.0",
|
|
55
|
+
"@loaders.gl/textures": "3.2.0",
|
|
56
|
+
"@loaders.gl/tiles": "3.2.0",
|
|
57
|
+
"@loaders.gl/worker-utils": "3.2.0",
|
|
58
|
+
"@loaders.gl/zip": "3.2.0",
|
|
57
59
|
"@luma.gl/engine": "^8.5.4",
|
|
58
60
|
"@math.gl/core": "^3.5.1",
|
|
59
61
|
"@math.gl/culling": "^3.5.1",
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
"uuid": "^8.1.0"
|
|
72
74
|
},
|
|
73
75
|
"peerDependencies": {
|
|
74
|
-
"@loaders.gl/core": "3.2.0-alpha.
|
|
76
|
+
"@loaders.gl/core": "3.2.0-alpha.3"
|
|
75
77
|
},
|
|
76
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "6660dc9291526752c40063b73a3f9dd97cc0ccc5"
|
|
77
79
|
}
|
|
@@ -4,7 +4,7 @@ import type {Node3D} from '@loaders.gl/3d-tiles';
|
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
import process from 'process';
|
|
6
6
|
import transform from 'json-map-transform';
|
|
7
|
-
import {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';
|
|
7
|
+
import {fetchFile, getLoaderOptions, load, isBrowser} from '@loaders.gl/core';
|
|
8
8
|
import {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';
|
|
9
9
|
import {Tileset3D, Tile3D} from '@loaders.gl/tiles';
|
|
10
10
|
import {Geoid} from '@math.gl/geoid';
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
/*transform3DTilesAttributesOnWorker*/
|
|
24
24
|
} from '../3d-tiles-attributes-worker';
|
|
25
25
|
import {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';
|
|
26
|
+
import {BROWSER_ERROR_MESSAGE} from '../constants';
|
|
26
27
|
|
|
27
28
|
const I3S = 'I3S';
|
|
28
29
|
|
|
@@ -63,9 +64,13 @@ export default class Tiles3DConverter {
|
|
|
63
64
|
inputUrl: string;
|
|
64
65
|
outputPath: string;
|
|
65
66
|
tilesetName: string;
|
|
66
|
-
maxDepth
|
|
67
|
+
maxDepth?: number;
|
|
67
68
|
egmFilePath: string;
|
|
68
69
|
}): Promise<any> {
|
|
70
|
+
if (isBrowser) {
|
|
71
|
+
console.log(BROWSER_ERROR_MESSAGE);
|
|
72
|
+
return BROWSER_ERROR_MESSAGE;
|
|
73
|
+
}
|
|
69
74
|
const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;
|
|
70
75
|
this.conversionStartTime = process.hrtime();
|
|
71
76
|
this.options = {maxDepth};
|
package/src/constants.ts
ADDED
|
@@ -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
|
+
}
|