@loaders.gl/tile-converter 4.3.0-alpha.3 → 4.3.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/converter-cli.js +6 -1
- package/dist/converter.min.cjs +92 -93
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +9 -5
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +4 -2
- package/dist/i3s-converter/i3s-converter.d.ts +1 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +9 -4
- package/dist/i3s-server/bin/i3s-server.min.cjs +63 -63
- package/dist/i3s-server/routes/slpk-router.js +7 -1
- package/dist/index.cjs +19 -9
- package/dist/index.cjs.map +2 -2
- package/dist/pgm-loader.js +1 -1
- package/package.json +16 -16
- package/src/converter-cli.ts +8 -1
- package/src/i3s-converter/helpers/coordinate-converter.ts +13 -7
- package/src/i3s-converter/helpers/geometry-converter.ts +6 -4
- package/src/i3s-converter/i3s-converter.ts +14 -8
- package/src/i3s-server/routes/slpk-router.ts +6 -1
package/dist/pgm-loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Geoid, parsePGM } from '@math.gl/geoid';
|
|
2
2
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
3
3
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
4
|
-
const VERSION = typeof "4.3.0-alpha.
|
|
4
|
+
const VERSION = typeof "4.3.0-alpha.3" !== 'undefined' ? "4.3.0-alpha.3" : 'latest';
|
|
5
5
|
export { Geoid };
|
|
6
6
|
/**
|
|
7
7
|
* Loader for PGM - Netpbm grayscale image format
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.3.0-alpha.
|
|
3
|
+
"version": "4.3.0-alpha.4",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,20 +53,20 @@
|
|
|
53
53
|
"copy-certificates": "cp -R src/i3s-server/certs dist/i3s-server"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@loaders.gl/3d-tiles": "4.3.0-alpha.
|
|
57
|
-
"@loaders.gl/compression": "4.3.0-alpha.
|
|
58
|
-
"@loaders.gl/crypto": "4.3.0-alpha.
|
|
59
|
-
"@loaders.gl/draco": "4.3.0-alpha.
|
|
60
|
-
"@loaders.gl/gltf": "4.3.0-alpha.
|
|
61
|
-
"@loaders.gl/i3s": "4.3.0-alpha.
|
|
62
|
-
"@loaders.gl/images": "4.3.0-alpha.
|
|
63
|
-
"@loaders.gl/loader-utils": "4.3.0-alpha.
|
|
64
|
-
"@loaders.gl/math": "4.3.0-alpha.
|
|
65
|
-
"@loaders.gl/polyfills": "4.3.0-alpha.
|
|
66
|
-
"@loaders.gl/textures": "4.3.0-alpha.
|
|
67
|
-
"@loaders.gl/tiles": "4.3.0-alpha.
|
|
68
|
-
"@loaders.gl/worker-utils": "4.3.0-alpha.
|
|
69
|
-
"@loaders.gl/zip": "4.3.0-alpha.
|
|
56
|
+
"@loaders.gl/3d-tiles": "4.3.0-alpha.4",
|
|
57
|
+
"@loaders.gl/compression": "4.3.0-alpha.4",
|
|
58
|
+
"@loaders.gl/crypto": "4.3.0-alpha.4",
|
|
59
|
+
"@loaders.gl/draco": "4.3.0-alpha.4",
|
|
60
|
+
"@loaders.gl/gltf": "4.3.0-alpha.4",
|
|
61
|
+
"@loaders.gl/i3s": "4.3.0-alpha.4",
|
|
62
|
+
"@loaders.gl/images": "4.3.0-alpha.4",
|
|
63
|
+
"@loaders.gl/loader-utils": "4.3.0-alpha.4",
|
|
64
|
+
"@loaders.gl/math": "4.3.0-alpha.4",
|
|
65
|
+
"@loaders.gl/polyfills": "4.3.0-alpha.4",
|
|
66
|
+
"@loaders.gl/textures": "4.3.0-alpha.4",
|
|
67
|
+
"@loaders.gl/tiles": "4.3.0-alpha.4",
|
|
68
|
+
"@loaders.gl/worker-utils": "4.3.0-alpha.4",
|
|
69
|
+
"@loaders.gl/zip": "4.3.0-alpha.4",
|
|
70
70
|
"@math.gl/core": "^4.0.0",
|
|
71
71
|
"@math.gl/culling": "^4.0.0",
|
|
72
72
|
"@math.gl/geoid": "^4.0.0",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@loaders.gl/core": "^4.0.0"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "4900ac4c4de20366c050b80cef04dc5b52d167af"
|
|
98
98
|
}
|
package/src/converter-cli.ts
CHANGED
|
@@ -36,6 +36,8 @@ type TileConversionOptions = {
|
|
|
36
36
|
* default: "./deps/egm2008-5.pgm". A model file can be loaded from GeographicLib
|
|
37
37
|
* https://geographiclib.sourceforge.io/html/geoid.html */
|
|
38
38
|
egm: string;
|
|
39
|
+
/** 3DTiles->I3S only. Whether the converter uses Earth Gravity Model (*.pgm) */
|
|
40
|
+
noEgm: boolean;
|
|
39
41
|
/** 3DTile->I3S only. Token for Cesium ION tileset authentication. */
|
|
40
42
|
token?: string;
|
|
41
43
|
/** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */
|
|
@@ -187,6 +189,7 @@ function printHelp(): void {
|
|
|
187
189
|
console.log(
|
|
188
190
|
'--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"'
|
|
189
191
|
);
|
|
192
|
+
console.log('--no-egm [Disable Geod transformation via the EGM file]');
|
|
190
193
|
console.log('--token [Token for Cesium ION tilesets authentication]');
|
|
191
194
|
console.log('--no-draco [Disable draco compression for geometry]');
|
|
192
195
|
console.log(
|
|
@@ -321,7 +324,8 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
321
324
|
validate: false,
|
|
322
325
|
slpk: false,
|
|
323
326
|
addHash: false,
|
|
324
|
-
quiet: false
|
|
327
|
+
quiet: false,
|
|
328
|
+
noEgm: false
|
|
325
329
|
};
|
|
326
330
|
|
|
327
331
|
// eslint-disable-next-line complexity
|
|
@@ -361,6 +365,9 @@ function parseOptions(args: string[]): TileConversionOptions {
|
|
|
361
365
|
case '--egm':
|
|
362
366
|
opts.egm = getStringValue(index, args);
|
|
363
367
|
break;
|
|
368
|
+
case '--no-egm':
|
|
369
|
+
opts.noEgm = getBooleanValue(index, args);
|
|
370
|
+
break;
|
|
364
371
|
case '--token':
|
|
365
372
|
opts.token = getStringValue(index, args);
|
|
366
373
|
break;
|
|
@@ -18,7 +18,7 @@ import {Geoid} from '@math.gl/geoid';
|
|
|
18
18
|
*/
|
|
19
19
|
export function createBoundingVolumes(
|
|
20
20
|
sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,
|
|
21
|
-
geoidHeightModel: Geoid
|
|
21
|
+
geoidHeightModel: Geoid | null
|
|
22
22
|
): BoundingVolumes {
|
|
23
23
|
let radius;
|
|
24
24
|
let halfSize;
|
|
@@ -28,9 +28,13 @@ export function createBoundingVolumes(
|
|
|
28
28
|
sourceBoundingVolume.center,
|
|
29
29
|
new Vector3()
|
|
30
30
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
|
|
32
|
+
if (geoidHeightModel) {
|
|
33
|
+
cartographicCenter[2] =
|
|
34
|
+
cartographicCenter[2] -
|
|
35
|
+
geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
if (sourceBoundingVolume instanceof OrientedBoundingBox) {
|
|
35
39
|
halfSize = sourceBoundingVolume.halfSize;
|
|
36
40
|
radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
|
|
@@ -60,7 +64,7 @@ export function createBoundingVolumes(
|
|
|
60
64
|
*/
|
|
61
65
|
export function createBoundingVolumesFromGeometry(
|
|
62
66
|
cartesianPositions: Float32Array,
|
|
63
|
-
geoidHeightModel: Geoid
|
|
67
|
+
geoidHeightModel: Geoid | null
|
|
64
68
|
): {mbs: Mbs; obb: Obb} {
|
|
65
69
|
const positionVectors = convertPositionsToVectors(cartesianPositions);
|
|
66
70
|
|
|
@@ -70,8 +74,10 @@ export function createBoundingVolumesFromGeometry(
|
|
|
70
74
|
const mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());
|
|
71
75
|
const obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
if (geoidHeightModel) {
|
|
78
|
+
mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
|
|
79
|
+
obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
|
|
80
|
+
}
|
|
75
81
|
|
|
76
82
|
return {
|
|
77
83
|
mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],
|
|
@@ -121,7 +121,7 @@ export default async function convertB3dmToI3sGeometry({
|
|
|
121
121
|
draco: boolean;
|
|
122
122
|
generateBoundingVolumes: boolean;
|
|
123
123
|
shouldMergeMaterials: boolean;
|
|
124
|
-
geoidHeightModel: Geoid;
|
|
124
|
+
geoidHeightModel: Geoid | null;
|
|
125
125
|
libraries: Record<string, string>;
|
|
126
126
|
metadataClass?: string;
|
|
127
127
|
}): Promise<I3SConvertedResources[] | null> {
|
|
@@ -197,7 +197,7 @@ export default async function convertB3dmToI3sGeometry({
|
|
|
197
197
|
*/
|
|
198
198
|
function _generateBoundingVolumesFromGeometry(
|
|
199
199
|
convertedAttributesMap: Map<string, ConvertedAttributes>,
|
|
200
|
-
geoidHeightModel: Geoid
|
|
200
|
+
geoidHeightModel: Geoid | null
|
|
201
201
|
) {
|
|
202
202
|
for (const attributes of convertedAttributesMap.values()) {
|
|
203
203
|
const boundingVolumes = createBoundingVolumesFromGeometry(
|
|
@@ -211,8 +211,10 @@ function _generateBoundingVolumesFromGeometry(
|
|
|
211
211
|
for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
|
|
212
212
|
const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
|
|
213
213
|
Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
|
|
214
|
-
|
|
215
|
-
scratchVector[2]
|
|
214
|
+
if (geoidHeightModel) {
|
|
215
|
+
scratchVector[2] =
|
|
216
|
+
scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
|
|
217
|
+
}
|
|
216
218
|
scratchVector = scratchVector.subtract(cartographicOrigin);
|
|
217
219
|
attributes.positions.set(scratchVector, index);
|
|
218
220
|
}
|
|
@@ -203,6 +203,7 @@ export default class I3SConverter {
|
|
|
203
203
|
inquirer?: Promise<unknown>;
|
|
204
204
|
metadataClass?: string;
|
|
205
205
|
analyze?: boolean;
|
|
206
|
+
noEgm?: boolean;
|
|
206
207
|
}): Promise<string> {
|
|
207
208
|
if (isBrowser) {
|
|
208
209
|
console.log(BROWSER_ERROR_MESSAGE); // eslint-disable-line no-console
|
|
@@ -226,7 +227,8 @@ export default class I3SConverter {
|
|
|
226
227
|
mergeMaterials = true,
|
|
227
228
|
inquirer,
|
|
228
229
|
metadataClass,
|
|
229
|
-
analyze = false
|
|
230
|
+
analyze = false,
|
|
231
|
+
noEgm = false
|
|
230
232
|
} = options;
|
|
231
233
|
this.options = {
|
|
232
234
|
outputPath,
|
|
@@ -253,9 +255,13 @@ export default class I3SConverter {
|
|
|
253
255
|
this.writeQueue = new WriteQueue(this.conversionDump);
|
|
254
256
|
this.writeQueue.startListening();
|
|
255
257
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
if (!noEgm) {
|
|
259
|
+
console.log('--no-egm option selected, skip loading egm file'); // eslint-disable-line
|
|
260
|
+
} else {
|
|
261
|
+
console.log('Loading egm file...'); // eslint-disable-line
|
|
262
|
+
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
263
|
+
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
264
|
+
}
|
|
259
265
|
|
|
260
266
|
if (slpk) {
|
|
261
267
|
this.nodePages.useWriteFunction(writeFileForSlpk);
|
|
@@ -486,7 +492,7 @@ export default class I3SConverter {
|
|
|
486
492
|
this.sourceTileset?.root?.boundingVolume?.region
|
|
487
493
|
);
|
|
488
494
|
|
|
489
|
-
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel
|
|
495
|
+
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
490
496
|
|
|
491
497
|
await this.nodePages.push({
|
|
492
498
|
index: 0,
|
|
@@ -793,7 +799,7 @@ export default class I3SConverter {
|
|
|
793
799
|
transformationMatrix,
|
|
794
800
|
null
|
|
795
801
|
);
|
|
796
|
-
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel
|
|
802
|
+
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
797
803
|
const nodes: NodeIndexDocument[] = [];
|
|
798
804
|
for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
|
|
799
805
|
const {node} = await this._generateNodeIndexDocument(
|
|
@@ -846,7 +852,7 @@ export default class I3SConverter {
|
|
|
846
852
|
transformationMatrix,
|
|
847
853
|
null
|
|
848
854
|
);
|
|
849
|
-
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel
|
|
855
|
+
const boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
|
|
850
856
|
|
|
851
857
|
const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
|
|
852
858
|
this.createAttributeStorageInfo(tileContent, propertyTable);
|
|
@@ -974,7 +980,7 @@ export default class I3SConverter {
|
|
|
974
980
|
draco: this.options.draco,
|
|
975
981
|
generateBoundingVolumes: this.generateBoundingVolumes,
|
|
976
982
|
shouldMergeMaterials: this.options.mergeMaterials,
|
|
977
|
-
geoidHeightModel: this.geoidHeightModel
|
|
983
|
+
geoidHeightModel: this.geoidHeightModel,
|
|
978
984
|
libraries: this.loadOptions.modules as Record<string, string>,
|
|
979
985
|
metadataClass: this.options.metadataClass
|
|
980
986
|
});
|
|
@@ -25,7 +25,12 @@ router.get('*', (req, res, next) => {
|
|
|
25
25
|
async function routerCallback(req, res, next) {
|
|
26
26
|
const file = await getFileByUrl(req.path.replace(/\/+$/, ''));
|
|
27
27
|
if (file) {
|
|
28
|
-
|
|
28
|
+
try {
|
|
29
|
+
const json = JSON.parse(textDecoder.decode(file));
|
|
30
|
+
res.send(json);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
res.send(Buffer.from(file));
|
|
33
|
+
}
|
|
29
34
|
} else {
|
|
30
35
|
res.status(404);
|
|
31
36
|
res.send('File not found');
|