@loaders.gl/tile-converter 4.4.0-alpha.2 → 4.4.0-alpha.9
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.min.cjs +89 -98
- package/dist/i3s-server/bin/i3s-server.min.cjs +78 -78
- package/package.json +16 -16
- package/src/3d-tiles-converter/3d-tiles-converter.ts +11 -7
- package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -5
- package/src/converter-cli.ts +2 -2
- package/src/i3s-converter/helpers/geometry-converter.ts +17 -1
- package/src/i3s-converter/helpers/load-3d-tiles.ts +24 -9
- package/src/i3s-converter/i3s-converter.ts +25 -9
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/lib/utils/compress-util.ts +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -115
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -388
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts +0 -88
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js +0 -380
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -13
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -19
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +0 -37
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -98
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +0 -10
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -50
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +0 -15
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -39
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/converter-cli.d.ts +0 -2
- package/dist/converter-cli.d.ts.map +0 -1
- package/dist/converter-cli.js +0 -290
- package/dist/deps-installer/deps-installer.d.ts +0 -19
- package/dist/deps-installer/deps-installer.d.ts.map +0 -1
- package/dist/deps-installer/deps-installer.js +0 -95
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +0 -84
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +0 -219
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +0 -26
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -165
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +0 -39
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -118
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +0 -9
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -21
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +0 -54
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -193
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +0 -8
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -226
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +0 -60
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1309
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +0 -28
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -122
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +0 -33
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -121
- package/dist/i3s-converter/helpers/node-debug.d.ts +0 -8
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js +0 -116
- package/dist/i3s-converter/helpers/node-index-document.d.ts +0 -111
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js +0 -269
- package/dist/i3s-converter/helpers/node-pages.d.ts +0 -156
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js +0 -285
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +0 -22
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -104
- package/dist/i3s-converter/helpers/progress.d.ts +0 -90
- package/dist/i3s-converter/helpers/progress.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/progress.js +0 -148
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +0 -32
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -34
- package/dist/i3s-converter/i3s-converter.d.ts +0 -312
- package/dist/i3s-converter/i3s-converter.d.ts.map +0 -1
- package/dist/i3s-converter/i3s-converter.js +0 -1191
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +0 -7
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -80
- package/dist/i3s-converter/json-templates/layers.d.ts +0 -70
- package/dist/i3s-converter/json-templates/layers.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js +0 -132
- package/dist/i3s-converter/json-templates/metadata.d.ts +0 -22
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js +0 -21
- package/dist/i3s-converter/json-templates/node.d.ts +0 -61
- package/dist/i3s-converter/json-templates/node.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/node.js +0 -82
- package/dist/i3s-converter/json-templates/scene-server.d.ts +0 -28
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js +0 -27
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +0 -14
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -122
- package/dist/i3s-converter/json-templates/store.d.ts +0 -95
- package/dist/i3s-converter/json-templates/store.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/store.js +0 -100
- package/dist/i3s-converter/types.d.ts +0 -226
- package/dist/i3s-converter/types.d.ts.map +0 -1
- package/dist/i3s-converter/types.js +0 -37
- package/dist/i3s-server/app.d.ts +0 -3
- package/dist/i3s-server/app.d.ts.map +0 -1
- package/dist/i3s-server/app.js +0 -31
- package/dist/i3s-server/bin/www.d.ts +0 -3
- package/dist/i3s-server/bin/www.d.ts.map +0 -1
- package/dist/i3s-server/bin/www.js +0 -46
- package/dist/i3s-server/controllers/slpk-controller.d.ts +0 -13
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js +0 -32
- package/dist/i3s-server/routes/slpk-router.d.ts +0 -3
- package/dist/i3s-server/routes/slpk-router.d.ts.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js +0 -40
- package/dist/i3s-server/utils/create-scene-server.d.ts +0 -17
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js +0 -18
- package/dist/i3s-server/utils/server-utils.d.ts +0 -21
- package/dist/i3s-server/utils/server-utils.d.ts.map +0 -1
- package/dist/i3s-server/utils/server-utils.js +0 -60
- package/dist/index.cjs +0 -6228
- package/dist/index.cjs.map +0 -7
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +0 -463
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +0 -285
- package/dist/lib/utils/cli-utils.d.ts +0 -34
- package/dist/lib/utils/cli-utils.d.ts.map +0 -1
- package/dist/lib/utils/cli-utils.js +0 -76
- package/dist/lib/utils/compress-util.d.ts +0 -8
- package/dist/lib/utils/compress-util.d.ts.map +0 -1
- package/dist/lib/utils/compress-util.js +0 -25
- package/dist/lib/utils/conversion-dump.d.ts +0 -147
- package/dist/lib/utils/conversion-dump.d.ts.map +0 -1
- package/dist/lib/utils/conversion-dump.js +0 -257
- package/dist/lib/utils/file-utils.d.ts +0 -57
- package/dist/lib/utils/file-utils.d.ts.map +0 -1
- package/dist/lib/utils/file-utils.js +0 -140
- package/dist/lib/utils/geometry-utils.d.ts +0 -9
- package/dist/lib/utils/geometry-utils.d.ts.map +0 -1
- package/dist/lib/utils/geometry-utils.js +0 -14
- package/dist/lib/utils/lod-conversion-utils.d.ts +0 -42
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js +0 -71
- package/dist/lib/utils/queue.d.ts +0 -7
- package/dist/lib/utils/queue.d.ts.map +0 -1
- package/dist/lib/utils/queue.js +0 -14
- package/dist/lib/utils/statistic-utils.d.ts +0 -20
- package/dist/lib/utils/statistic-utils.d.ts.map +0 -1
- package/dist/lib/utils/statistic-utils.js +0 -88
- package/dist/lib/utils/write-queue.d.ts +0 -44
- package/dist/lib/utils/write-queue.d.ts.map +0 -1
- package/dist/lib/utils/write-queue.js +0 -82
- package/dist/pgm-loader.d.ts +0 -28
- package/dist/pgm-loader.d.ts.map +0 -1
- package/dist/pgm-loader.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.4.0-alpha.
|
|
3
|
+
"version": "4.4.0-alpha.9",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,20 +51,20 @@
|
|
|
51
51
|
"copy-certificates": "cp -R src/i3s-server/certs dist/i3s-server"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@loaders.gl/3d-tiles": "4.4.0-alpha.
|
|
55
|
-
"@loaders.gl/compression": "4.4.0-alpha.
|
|
56
|
-
"@loaders.gl/crypto": "4.4.0-alpha.
|
|
57
|
-
"@loaders.gl/draco": "4.4.0-alpha.
|
|
58
|
-
"@loaders.gl/gltf": "4.4.0-alpha.
|
|
59
|
-
"@loaders.gl/i3s": "4.4.0-alpha.
|
|
60
|
-
"@loaders.gl/images": "4.4.0-alpha.
|
|
61
|
-
"@loaders.gl/loader-utils": "4.4.0-alpha.
|
|
62
|
-
"@loaders.gl/math": "4.4.0-alpha.
|
|
63
|
-
"@loaders.gl/polyfills": "4.4.0-alpha.
|
|
64
|
-
"@loaders.gl/textures": "4.4.0-alpha.
|
|
65
|
-
"@loaders.gl/tiles": "4.4.0-alpha.
|
|
66
|
-
"@loaders.gl/worker-utils": "4.4.0-alpha.
|
|
67
|
-
"@loaders.gl/zip": "4.4.0-alpha.
|
|
54
|
+
"@loaders.gl/3d-tiles": "4.4.0-alpha.9",
|
|
55
|
+
"@loaders.gl/compression": "4.4.0-alpha.9",
|
|
56
|
+
"@loaders.gl/crypto": "4.4.0-alpha.9",
|
|
57
|
+
"@loaders.gl/draco": "4.4.0-alpha.9",
|
|
58
|
+
"@loaders.gl/gltf": "4.4.0-alpha.9",
|
|
59
|
+
"@loaders.gl/i3s": "4.4.0-alpha.9",
|
|
60
|
+
"@loaders.gl/images": "4.4.0-alpha.9",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.9",
|
|
62
|
+
"@loaders.gl/math": "4.4.0-alpha.9",
|
|
63
|
+
"@loaders.gl/polyfills": "4.4.0-alpha.9",
|
|
64
|
+
"@loaders.gl/textures": "4.4.0-alpha.9",
|
|
65
|
+
"@loaders.gl/tiles": "4.4.0-alpha.9",
|
|
66
|
+
"@loaders.gl/worker-utils": "4.4.0-alpha.9",
|
|
67
|
+
"@loaders.gl/zip": "4.4.0-alpha.9",
|
|
68
68
|
"@math.gl/core": "^4.1.0",
|
|
69
69
|
"@math.gl/culling": "^4.1.0",
|
|
70
70
|
"@math.gl/geoid": "^4.1.0",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "e9e6710379718c7663e97eba868c76e15de4cb84"
|
|
97
97
|
}
|
|
@@ -51,10 +51,12 @@ export default class Tiles3DConverter {
|
|
|
51
51
|
workerSource: {[key: string]: string} = {};
|
|
52
52
|
slpkFilesystem: ZipFileSystem | null = null;
|
|
53
53
|
loaderOptions: I3SLoaderOptions = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
core: {
|
|
55
|
+
_nodeWorkers: true,
|
|
56
|
+
reuseWorkers: true,
|
|
57
|
+
// TODO: converter freezes in the end because of i3s-content-worker
|
|
58
|
+
worker: false
|
|
59
|
+
},
|
|
58
60
|
i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false},
|
|
59
61
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
60
62
|
'i3s-content': {
|
|
@@ -451,9 +453,11 @@ export default class Tiles3DConverter {
|
|
|
451
453
|
const inputUrl = attributeUrls[index];
|
|
452
454
|
const attribute = attributeStorageInfo[index];
|
|
453
455
|
const options = {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
i3s: {
|
|
457
|
+
attributeName: attribute.name,
|
|
458
|
+
attributeType: this._getAttributeType(attribute)
|
|
459
|
+
}
|
|
460
|
+
}; // as const satisfies I3SLoaderOptions;
|
|
457
461
|
|
|
458
462
|
promises.push(loadFromArchive(inputUrl, I3SAttributeLoader, options, this.slpkFilesystem));
|
|
459
463
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
I3SLoaderOptions,
|
|
8
8
|
parseSLPKArchive
|
|
9
9
|
} from '@loaders.gl/i3s';
|
|
10
|
-
import {
|
|
10
|
+
import {NodeFile} from '@loaders.gl/loader-utils';
|
|
11
11
|
import {ZipFileSystem, makeZipCDHeaderIterator} from '@loaders.gl/zip';
|
|
12
12
|
|
|
13
13
|
export type SLPKUrlParts = {slpkFileName: string; internalFileName: string};
|
|
@@ -75,7 +75,7 @@ export async function openSLPK(url: string): Promise<ZipFileSystem | null> {
|
|
|
75
75
|
const slpkUrlParts = url.split('.slpk');
|
|
76
76
|
if (slpkUrlParts.length === 2) {
|
|
77
77
|
const slpkFileName = `${slpkUrlParts[0]}.slpk`;
|
|
78
|
-
const fileProvider = new
|
|
78
|
+
const fileProvider = new NodeFile(slpkFileName);
|
|
79
79
|
const archive = await parseSLPKArchive(fileProvider, undefined, slpkFileName);
|
|
80
80
|
const fileSystem = new ZipFileSystem(archive);
|
|
81
81
|
return fileSystem;
|
|
@@ -99,7 +99,7 @@ export async function loadFromArchive(
|
|
|
99
99
|
if (fileSystem !== null) {
|
|
100
100
|
const content = await load(url, loader, {
|
|
101
101
|
...loadOptions,
|
|
102
|
-
fetch: fileSystem.fetch.bind(fileSystem)
|
|
102
|
+
core: {...loadOptions?.core, fetch: fileSystem.fetch.bind(fileSystem)}
|
|
103
103
|
});
|
|
104
104
|
return content;
|
|
105
105
|
}
|
|
@@ -112,11 +112,11 @@ export async function loadFromArchive(
|
|
|
112
112
|
* @returns number of nodes
|
|
113
113
|
*/
|
|
114
114
|
export async function getNodeCount(fileSystem: ZipFileSystem | null): Promise<number> {
|
|
115
|
-
if (!fileSystem?.
|
|
115
|
+
if (!fileSystem?.file) {
|
|
116
116
|
return 0;
|
|
117
117
|
}
|
|
118
118
|
const nodeSet = new Set();
|
|
119
|
-
const filesIterator = makeZipCDHeaderIterator(fileSystem.
|
|
119
|
+
const filesIterator = makeZipCDHeaderIterator(fileSystem.file);
|
|
120
120
|
for await (const file of filesIterator) {
|
|
121
121
|
const filename = file.fileName;
|
|
122
122
|
const nodeNumberSearchResult = /^nodes\/(\d+)\//.exec(filename);
|
package/src/converter-cli.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
validateOptionsWithEqual
|
|
13
13
|
} from './lib/utils/cli-utils';
|
|
14
14
|
import {addOneFile, composeHashFile, makeZipCDHeaderIterator} from '@loaders.gl/zip';
|
|
15
|
-
import {
|
|
15
|
+
import {NodeFile} from '@loaders.gl/loader-utils';
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
import {copyFile} from 'node:fs/promises';
|
|
18
18
|
|
|
@@ -141,7 +141,7 @@ async function main() {
|
|
|
141
141
|
if (finalPath !== validatedOptions.tileset) {
|
|
142
142
|
await copyFile(validatedOptions.tileset, finalPath);
|
|
143
143
|
}
|
|
144
|
-
const hashTable = await composeHashFile(makeZipCDHeaderIterator(new
|
|
144
|
+
const hashTable = await composeHashFile(makeZipCDHeaderIterator(new NodeFile(finalPath)));
|
|
145
145
|
await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
|
|
146
146
|
|
|
147
147
|
return;
|
|
@@ -18,6 +18,11 @@ import type {
|
|
|
18
18
|
import {Vector3, Matrix4, Vector4} from '@math.gl/core';
|
|
19
19
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
20
20
|
|
|
21
|
+
/* @ts-expect-error TS2732: Cannot find module 'node:module' or its corresponding type declarations. */
|
|
22
|
+
import {createRequire} from 'node:module';
|
|
23
|
+
/* @ts-expect-error TS2732: Cannot find module 'node:module' or its corresponding type declarations. */
|
|
24
|
+
import {dirname, join} from 'node:path';
|
|
25
|
+
|
|
21
26
|
import {DracoWriterWorker} from '@loaders.gl/draco';
|
|
22
27
|
import {assert, encode} from '@loaders.gl/core';
|
|
23
28
|
import {
|
|
@@ -1629,12 +1634,23 @@ async function generateCompressedGeometry(
|
|
|
1629
1634
|
},
|
|
1630
1635
|
['draco-writer']: {
|
|
1631
1636
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
1632
|
-
workerUrl:
|
|
1637
|
+
workerUrl: getLocalDracoWriterWorkerUrl()
|
|
1633
1638
|
}
|
|
1634
1639
|
}
|
|
1635
1640
|
);
|
|
1636
1641
|
}
|
|
1637
1642
|
|
|
1643
|
+
function getLocalDracoWriterWorkerUrl(): string {
|
|
1644
|
+
try {
|
|
1645
|
+
const require = createRequire(import.meta.url);
|
|
1646
|
+
const packageJsonPath = require.resolve('@loaders.gl/draco/package.json');
|
|
1647
|
+
return join(dirname(packageJsonPath), 'src/workers/draco-writer-worker-node.cjs');
|
|
1648
|
+
} catch {
|
|
1649
|
+
// Fall back to monorepo-local path
|
|
1650
|
+
return './modules/draco/src/workers/draco-writer-worker-node.cjs';
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1638
1654
|
/**
|
|
1639
1655
|
* Generates ordered feature indices based on face range
|
|
1640
1656
|
* @param featureIndex
|
|
@@ -6,14 +6,16 @@ import type {
|
|
|
6
6
|
} from '@loaders.gl/3d-tiles';
|
|
7
7
|
import {Tiles3DArchive} from '@loaders.gl/3d-tiles';
|
|
8
8
|
import {LoaderWithParser, load} from '@loaders.gl/core';
|
|
9
|
-
import {
|
|
9
|
+
import type {ReadableFile} from '@loaders.gl/loader-utils';
|
|
10
|
+
import {HttpFile, NodeFile, isBrowser} from '@loaders.gl/loader-utils';
|
|
10
11
|
import {
|
|
11
12
|
CD_HEADER_SIGNATURE,
|
|
12
13
|
ZipFileSystem,
|
|
13
14
|
parseHashTable,
|
|
14
15
|
parseZipCDFileHeader,
|
|
15
16
|
parseZipLocalFileHeader,
|
|
16
|
-
searchFromTheEnd
|
|
17
|
+
searchFromTheEnd,
|
|
18
|
+
readRange
|
|
17
19
|
} from '@loaders.gl/zip';
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -113,14 +115,19 @@ export async function loadFromArchive(
|
|
|
113
115
|
}
|
|
114
116
|
if (filename) {
|
|
115
117
|
const tz3Path = `${tz3UrlParts[0]}.3tz`;
|
|
116
|
-
const fileProvider =
|
|
118
|
+
const fileProvider = createReadableFile(tz3Path);
|
|
117
119
|
const hashTable = await loadHashTable(fileProvider);
|
|
118
120
|
const archive = new Tiles3DArchive(fileProvider, hashTable, tz3Path);
|
|
119
121
|
const fileSystem = new ZipFileSystem(archive);
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// const loadOptionsWithoutDeprecatedFetch = {...loadOptions} as Tiles3DLoaderOptions & {
|
|
123
|
+
// fetch?: unknown;
|
|
124
|
+
// };
|
|
125
|
+
// delete loadOptionsWithoutDeprecatedFetch.fetch;
|
|
126
|
+
// const mergedOptions = {
|
|
127
|
+
// ...loadOptionsWithoutDeprecatedFetch,
|
|
128
|
+
// core: {...loadOptions?.core, fetch: fileSystem.fetch.bind(fileSystem)}
|
|
129
|
+
// }
|
|
130
|
+
const content = await load(filename, loader, loadOptions);
|
|
124
131
|
await fileSystem.destroy();
|
|
125
132
|
return content;
|
|
126
133
|
}
|
|
@@ -136,13 +143,20 @@ export function isNestedTileset(tile: Tiles3DTileJSONPostprocessed) {
|
|
|
136
143
|
return tile?.type === 'json' || tile?.type === '3tz';
|
|
137
144
|
}
|
|
138
145
|
|
|
146
|
+
function createReadableFile(path: string): ReadableFile {
|
|
147
|
+
if (path.startsWith('http://') || path.startsWith('https://')) {
|
|
148
|
+
return new HttpFile(path);
|
|
149
|
+
}
|
|
150
|
+
return isBrowser ? new HttpFile(path) : new NodeFile(path);
|
|
151
|
+
}
|
|
152
|
+
|
|
139
153
|
/**
|
|
140
154
|
* Load hash file from 3TZ
|
|
141
155
|
* @param fileProvider - binary reader of 3TZ
|
|
142
156
|
* @returns hash table of the 3TZ file content or undefined if the hash file is not presented inside
|
|
143
157
|
*/
|
|
144
158
|
async function loadHashTable(
|
|
145
|
-
fileProvider:
|
|
159
|
+
fileProvider: ReadableFile
|
|
146
160
|
): Promise<undefined | Record<string, bigint>> {
|
|
147
161
|
let hashTable: undefined | Record<string, bigint>;
|
|
148
162
|
|
|
@@ -163,7 +177,8 @@ async function loadHashTable(
|
|
|
163
177
|
}
|
|
164
178
|
|
|
165
179
|
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
166
|
-
const hashFile = await
|
|
180
|
+
const hashFile = await readRange(
|
|
181
|
+
fileProvider,
|
|
167
182
|
fileDataOffset,
|
|
168
183
|
fileDataOffset + localFileHeader.compressedSize
|
|
169
184
|
);
|
|
@@ -135,9 +135,11 @@ export default class I3SConverter {
|
|
|
135
135
|
refreshTokenTime: [number, number] = [0, 0];
|
|
136
136
|
sourceTileset: Tiles3DTilesetJSONPostprocessed | null = null;
|
|
137
137
|
loadOptions: Tiles3DLoaderOptions = {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
core: {
|
|
139
|
+
_nodeWorkers: true,
|
|
140
|
+
reuseWorkers: true,
|
|
141
|
+
useLocalLibraries: true
|
|
142
|
+
},
|
|
141
143
|
basis: {
|
|
142
144
|
format: 'rgba32',
|
|
143
145
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
@@ -145,7 +147,6 @@ export default class I3SConverter {
|
|
|
145
147
|
},
|
|
146
148
|
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
147
149
|
draco: {workerUrl: './modules/draco/dist/draco-worker-node.js'},
|
|
148
|
-
fetch: {},
|
|
149
150
|
modules: {}
|
|
150
151
|
};
|
|
151
152
|
geoidHeightModel: Geoid | null = null;
|
|
@@ -266,7 +267,16 @@ export default class I3SConverter {
|
|
|
266
267
|
tilesetUrl = preloadOptions.url;
|
|
267
268
|
}
|
|
268
269
|
if (preloadOptions.headers) {
|
|
269
|
-
this.loadOptions.
|
|
270
|
+
this.loadOptions.core ||= {};
|
|
271
|
+
const existingFetch = this.loadOptions.core.fetch;
|
|
272
|
+
if (typeof existingFetch === 'function') {
|
|
273
|
+
this.loadOptions.core.fetch = (url: string, requestInit?: RequestInit) =>
|
|
274
|
+
existingFetch(url, {...(requestInit || {}), headers: preloadOptions.headers});
|
|
275
|
+
} else {
|
|
276
|
+
const existingRequestInit =
|
|
277
|
+
existingFetch && typeof existingFetch === 'object' ? existingFetch : {};
|
|
278
|
+
this.loadOptions.core.fetch = {...existingRequestInit, headers: preloadOptions.headers};
|
|
279
|
+
}
|
|
270
280
|
}
|
|
271
281
|
this.sourceTileset = await loadFromArchive(tilesetUrl, this.Loader, this.loadOptions);
|
|
272
282
|
|
|
@@ -1570,10 +1580,16 @@ export default class I3SConverter {
|
|
|
1570
1580
|
|
|
1571
1581
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
1572
1582
|
if (preloadOptions.headers) {
|
|
1573
|
-
this.loadOptions.
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1583
|
+
this.loadOptions.core ||= {};
|
|
1584
|
+
const existingFetch = this.loadOptions.core.fetch;
|
|
1585
|
+
if (typeof existingFetch === 'function') {
|
|
1586
|
+
this.loadOptions.core.fetch = (url: string, requestInit?: RequestInit) =>
|
|
1587
|
+
existingFetch(url, {...(requestInit || {}), headers: preloadOptions.headers});
|
|
1588
|
+
} else {
|
|
1589
|
+
const existingRequestInit =
|
|
1590
|
+
existingFetch && typeof existingFetch === 'object' ? existingFetch : {};
|
|
1591
|
+
this.loadOptions.core.fetch = {...existingRequestInit, headers: preloadOptions.headers};
|
|
1592
|
+
}
|
|
1577
1593
|
console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console
|
|
1578
1594
|
}
|
|
1579
1595
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@loaders.gl/polyfills';
|
|
2
2
|
import {parseSLPKArchive, SLPKArchive} from '@loaders.gl/i3s';
|
|
3
|
-
import {
|
|
3
|
+
import {NodeFile} from '@loaders.gl/loader-utils';
|
|
4
4
|
|
|
5
5
|
let slpkArchive: SLPKArchive;
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ let slpkArchive: SLPKArchive;
|
|
|
10
10
|
*/
|
|
11
11
|
export async function loadArchive(fullLayerPath: string): Promise<void> {
|
|
12
12
|
slpkArchive = await parseSLPKArchive(
|
|
13
|
-
new
|
|
13
|
+
new NodeFile(fullLayerPath),
|
|
14
14
|
(msg) => console.log(msg) // eslint-disable-line no-console
|
|
15
15
|
);
|
|
16
16
|
// eslint-disable-next-line no-console
|
|
@@ -22,6 +22,7 @@ export function compressFileWithGzip(pathFile: string): Promise<string> {
|
|
|
22
22
|
console.log(`${compressedPathFile}: compression error!`); // eslint-disable-line no-undef,no-console
|
|
23
23
|
reject(error);
|
|
24
24
|
});
|
|
25
|
+
// @ts-ignore Seems typescript upgrade triggered this
|
|
25
26
|
input.pipe(gzip).pipe(output);
|
|
26
27
|
});
|
|
27
28
|
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type { AttributeStorageInfo, I3STilesetHeader } from '@loaders.gl/i3s';
|
|
2
|
-
import { Geoid } from '@math.gl/geoid';
|
|
3
|
-
import { I3SLoaderOptions } from '@loaders.gl/i3s/src/i3s-loader';
|
|
4
|
-
import { ZipFileSystem } from "../../../zip/src.js";
|
|
5
|
-
import { ConversionDump } from "../lib/utils/conversion-dump.js";
|
|
6
|
-
import { Progress } from "../i3s-converter/helpers/progress.js";
|
|
7
|
-
import { PromptModule } from 'inquirer';
|
|
8
|
-
/**
|
|
9
|
-
* Converter from i3s to 3d-tiles
|
|
10
|
-
*/
|
|
11
|
-
export default class Tiles3DConverter {
|
|
12
|
-
options: any;
|
|
13
|
-
tilesetPath: string;
|
|
14
|
-
vertexCounter: number;
|
|
15
|
-
conversionStartTime: [number, number];
|
|
16
|
-
geoidHeightModel: Geoid | null;
|
|
17
|
-
sourceTileset: I3STilesetHeader | null;
|
|
18
|
-
attributeStorageInfo?: AttributeStorageInfo[] | null;
|
|
19
|
-
workerSource: {
|
|
20
|
-
[key: string]: string;
|
|
21
|
-
};
|
|
22
|
-
slpkFilesystem: ZipFileSystem | null;
|
|
23
|
-
loaderOptions: I3SLoaderOptions;
|
|
24
|
-
conversionDump: ConversionDump;
|
|
25
|
-
progress: Progress;
|
|
26
|
-
fileExt: string;
|
|
27
|
-
constructor();
|
|
28
|
-
/**
|
|
29
|
-
* Convert i3s format data to 3dTiles
|
|
30
|
-
* @param options
|
|
31
|
-
* @param options.inputUrl the url to read the tileset from
|
|
32
|
-
* @param options.outputPath the output filename
|
|
33
|
-
* @param options.outputVersion the version of 3DTiles
|
|
34
|
-
* @param options.tilesetName the output name of the tileset
|
|
35
|
-
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
36
|
-
* @param options.maxDepth The max tree depth of conversion
|
|
37
|
-
*/
|
|
38
|
-
convert(options: {
|
|
39
|
-
inputUrl: string;
|
|
40
|
-
outputPath: string;
|
|
41
|
-
tilesetName: string;
|
|
42
|
-
outputVersion?: string;
|
|
43
|
-
maxDepth?: number;
|
|
44
|
-
egmFilePath: string;
|
|
45
|
-
inquirer?: {
|
|
46
|
-
prompt: PromptModule;
|
|
47
|
-
};
|
|
48
|
-
analyze?: boolean;
|
|
49
|
-
}): Promise<string | undefined>;
|
|
50
|
-
/**
|
|
51
|
-
* Preprocess stage of the tile converter. Calculate number of nodes
|
|
52
|
-
* @returns true - the conversion is possible, false - the tileset's content is not supported
|
|
53
|
-
*/
|
|
54
|
-
private preprocessConversion;
|
|
55
|
-
/**
|
|
56
|
-
* Convert particular I3S Node
|
|
57
|
-
* @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
58
|
-
* @param parentNode object in resulting tileset
|
|
59
|
-
* @param level a current level of a tree depth
|
|
60
|
-
* @param childNodeInfo child node to convert
|
|
61
|
-
*/
|
|
62
|
-
private convertChildNode;
|
|
63
|
-
/**
|
|
64
|
-
* The recursive function of traversal of a nodes tree
|
|
65
|
-
* @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
66
|
-
* @param parentNode object in resulting tileset
|
|
67
|
-
* @param level a current level of a tree depth
|
|
68
|
-
*/
|
|
69
|
-
private _addChildren;
|
|
70
|
-
/**
|
|
71
|
-
* Load a child node having information from the node header
|
|
72
|
-
* @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
73
|
-
* @param childNodeInfo child information from 3DNodeIndexDocument
|
|
74
|
-
* (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
|
|
75
|
-
*/
|
|
76
|
-
private _loadChildNode;
|
|
77
|
-
/**
|
|
78
|
-
* Create child and child's boundingVolume for the converted node
|
|
79
|
-
* @param sourceChild
|
|
80
|
-
* @returns child and child's boundingVolume
|
|
81
|
-
*/
|
|
82
|
-
private _createChildAndBoundingVolume;
|
|
83
|
-
/**
|
|
84
|
-
* Make an url of a resource from its relative url having the base url
|
|
85
|
-
* @param baseUrl the base url. A resulting url will be related from this url
|
|
86
|
-
* @param relativeUrl a realtive url of a resource
|
|
87
|
-
*/
|
|
88
|
-
private _relativeUrlToFullUrl;
|
|
89
|
-
/**
|
|
90
|
-
* Do loading all attributes related to particular node.
|
|
91
|
-
* @param sourceChild
|
|
92
|
-
* @param attributeStorageInfo
|
|
93
|
-
* @returns Promise of attributes object.
|
|
94
|
-
*/
|
|
95
|
-
private _loadChildAttributes;
|
|
96
|
-
/**
|
|
97
|
-
* Returns attribute type for loading attributes
|
|
98
|
-
* @param attribute
|
|
99
|
-
* Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
|
|
100
|
-
* There is an 'Oid32' type if attribute has objectIds property.
|
|
101
|
-
* Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
|
|
102
|
-
*/
|
|
103
|
-
private _getAttributeType;
|
|
104
|
-
/**
|
|
105
|
-
* Make simple arrays from attribute typed arrays.
|
|
106
|
-
* @param attributesList
|
|
107
|
-
*/
|
|
108
|
-
private _replaceNestedArrays;
|
|
109
|
-
/**
|
|
110
|
-
* Print statistics in the end of conversion
|
|
111
|
-
* @param params - output files data
|
|
112
|
-
*/
|
|
113
|
-
private _finishConversion;
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=3d-tiles-converter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAGpB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAiBrC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAC/C,OAAO,EAAC,cAAc,EAAwB,wCAAqC;AACnF,OAAO,EAAC,QAAQ,EAAC,6CAA0C;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAItC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAC;IACrD,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IAC3C,cAAc,EAAE,aAAa,GAAG,IAAI,CAAQ;IAC5C,aAAa,EAAE,gBAAgB,CAU7B;IACF,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;;IAgBhB;;;;;;;;;OASG;IAEU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE;YAAC,MAAM,EAAE,YAAY,CAAA;SAAC,CAAC;QAClC,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA8G/B;;;OAGG;YACW,oBAAoB;IA8BlC;;;;;;OAMG;YAEW,gBAAgB;IAiF9B;;;;;OAKG;YACW,YAAY;IAa1B;;;;;OAKG;YACW,cAAc;IA4B5B;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IAsBrC;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;CAgBhC"}
|