@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.0-alpha.6
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-converter/3d-tiles-converter.d.ts +4 -4
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +349 -293
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +261 -200
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +83 -77
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
- package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
- package/dist/constants.js +0 -1
- package/dist/converter-cli.js +257 -234
- package/dist/converter.min.cjs +95 -105
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +78 -59
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +210 -153
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +146 -103
- package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
- package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +170 -105
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +205 -212
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +17 -3
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +1189 -830
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +109 -97
- package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
- package/dist/i3s-converter/helpers/node-debug.js +98 -54
- package/dist/i3s-converter/helpers/node-index-document.d.ts +11 -4
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +255 -177
- package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +299 -193
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
- package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/progress.js +139 -83
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +9 -2
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +33 -13
- package/dist/i3s-converter/i3s-converter.d.ts +7 -7
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +1165 -895
- package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
- package/dist/i3s-converter/json-templates/layers.js +120 -121
- package/dist/i3s-converter/json-templates/metadata.js +19 -20
- package/dist/i3s-converter/json-templates/node.js +73 -71
- package/dist/i3s-converter/json-templates/scene-server.js +25 -26
- package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
- package/dist/i3s-converter/json-templates/store.js +96 -94
- package/dist/i3s-converter/types.js +35 -23
- package/dist/i3s-server/app.js +15 -12
- package/dist/i3s-server/bin/i3s-server.min.cjs +69 -69
- package/dist/i3s-server/bin/www.js +16 -7
- package/dist/i3s-server/controllers/index-controller.js +18 -15
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.js +24 -11
- package/dist/i3s-server/routes/index.js +13 -9
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
- package/dist/i3s-server/routes/slpk-router.js +26 -19
- package/dist/i3s-server/utils/create-scene-server.js +15 -10
- package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
- package/dist/i3s-server/utils/server-utils.js +52 -32
- package/dist/index.cjs +616 -967
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
- package/dist/lib/utils/cli-utils.d.ts.map +1 -1
- package/dist/lib/utils/cli-utils.js +65 -36
- package/dist/lib/utils/compress-util.js +20 -15
- package/dist/lib/utils/conversion-dump.d.ts +10 -2
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +242 -197
- package/dist/lib/utils/file-utils.d.ts +1 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +120 -74
- package/dist/lib/utils/geometry-utils.js +13 -7
- package/dist/lib/utils/lod-conversion-utils.js +65 -33
- package/dist/lib/utils/queue.js +12 -13
- package/dist/lib/utils/statistic-utills.d.ts +6 -23
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/statistic-utills.js +58 -55
- package/dist/lib/utils/write-queue.d.ts +2 -2
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +72 -86
- package/dist/pgm-loader.js +17 -13
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +60 -50
- package/dist/slpk-extractor-cli.d.ts.map +1 -1
- package/dist/slpk-extractor-cli.js +90 -59
- package/dist/slpk-extractor.min.cjs +1 -1
- package/package.json +27 -26
- package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
- package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
- package/src/converter-cli.ts +4 -2
- package/src/deps-installer/deps-installer.ts +7 -0
- package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
- package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
- package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
- package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
- package/src/i3s-converter/helpers/node-index-document.ts +18 -10
- package/src/i3s-converter/helpers/node-pages.ts +27 -29
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
- package/src/i3s-converter/helpers/progress.ts +1 -0
- package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
- package/src/i3s-converter/i3s-converter.ts +173 -114
- package/src/i3s-converter/json-templates/node.ts +1 -1
- package/src/i3s-server/bin/www.ts +6 -4
- package/src/i3s-server/controllers/slpk-controller.ts +4 -2
- package/src/i3s-server/routes/index.ts +10 -7
- package/src/i3s-server/routes/slpk-router.ts +22 -16
- package/src/i3s-server/utils/server-utils.ts +6 -4
- package/src/lib/utils/cli-utils.ts +2 -0
- package/src/lib/utils/conversion-dump.ts +35 -20
- package/src/lib/utils/file-utils.ts +11 -11
- package/src/lib/utils/statistic-utills.ts +5 -6
- package/src/lib/utils/write-queue.ts +2 -2
- package/src/slpk-extractor/slpk-extractor.ts +2 -1
- package/src/slpk-extractor-cli.ts +16 -8
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/converter-cli.js.map +0 -1
- package/dist/deps-installer/deps-installer.js.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
- package/dist/i3s-converter/helpers/progress.js.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
- package/dist/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/i3s-converter/types.js.map +0 -1
- package/dist/i3s-server/README.md +0 -63
- package/dist/i3s-server/app.js.map +0 -1
- package/dist/i3s-server/bin/www.js.map +0 -1
- package/dist/i3s-server/certs/cert.pem +0 -19
- package/dist/i3s-server/certs/key.pem +0 -27
- package/dist/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
- package/dist/i3s-server/routes/index.js.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
- package/dist/i3s-server/utils/server-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
- package/dist/lib/utils/cli-utils.js.map +0 -1
- package/dist/lib/utils/compress-util.js.map +0 -1
- package/dist/lib/utils/conversion-dump.js.map +0 -1
- package/dist/lib/utils/file-utils.js.map +0 -1
- package/dist/lib/utils/geometry-utils.js.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/lib/utils/queue.js.map +0 -1
- package/dist/lib/utils/statistic-utills.js.map +0 -1
- package/dist/lib/utils/write-queue.js.map +0 -1
- package/dist/pgm-loader.js.map +0 -1
- package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
- package/dist/slpk-extractor-cli.js.map +0 -1
- package/src/lib/utils/statistic-utills.d.ts +0 -25
|
@@ -5,25 +5,31 @@ import {createSceneServer} from '../utils/create-scene-server';
|
|
|
5
5
|
const textDecoder = new TextDecoder();
|
|
6
6
|
|
|
7
7
|
export const sceneServerRouter = express.Router();
|
|
8
|
-
sceneServerRouter.get('*',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
sceneServerRouter.get('*', (req, res, next) => {
|
|
9
|
+
async function routerCallback(req, res, next) {
|
|
10
|
+
const file = await getFileByUrl('/');
|
|
11
|
+
if (file) {
|
|
12
|
+
const layer = JSON.parse(textDecoder.decode(file));
|
|
13
|
+
const sceneServerResponse = createSceneServer(layer.name, layer);
|
|
14
|
+
res.send(sceneServerResponse);
|
|
15
|
+
} else {
|
|
16
|
+
res.status(404);
|
|
17
|
+
res.send('File not found');
|
|
18
|
+
}
|
|
17
19
|
}
|
|
20
|
+
routerCallback(req, res, next);
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
export const router = express.Router();
|
|
21
|
-
router.get('*',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
router.get('*', (req, res, next) => {
|
|
25
|
+
async function routerCallback(req, res, next) {
|
|
26
|
+
const file = await getFileByUrl(req.path.replace(/\/+$/, ''));
|
|
27
|
+
if (file) {
|
|
28
|
+
res.send(Buffer.from(file));
|
|
29
|
+
} else {
|
|
30
|
+
res.status(404);
|
|
31
|
+
res.send('File not found');
|
|
32
|
+
}
|
|
28
33
|
}
|
|
34
|
+
routerCallback(req, res, next);
|
|
29
35
|
});
|
|
@@ -32,7 +32,9 @@ export function normalizePort(val: string): number | string | false {
|
|
|
32
32
|
*/
|
|
33
33
|
export function formErrorHandler(
|
|
34
34
|
optionalPort: string | number
|
|
35
|
+
// eslint-disable-next-line no-undef
|
|
35
36
|
): (error: NodeJS.ErrnoException) => void {
|
|
37
|
+
// eslint-disable-next-line no-undef
|
|
36
38
|
return function onError(error: NodeJS.ErrnoException) {
|
|
37
39
|
if (error.syscall !== 'listen') {
|
|
38
40
|
throw error;
|
|
@@ -43,12 +45,12 @@ export function formErrorHandler(
|
|
|
43
45
|
// handle specific listen errors with friendly messages
|
|
44
46
|
switch (error.code) {
|
|
45
47
|
case 'EACCES':
|
|
46
|
-
console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console
|
|
47
|
-
process.exit(1); // eslint-disable-line no-process-exit
|
|
48
|
+
console.error(`${bind} requires elevated privileges`); // eslint-disable-line no-console
|
|
49
|
+
process.exit(1); // eslint-disable-line no-process-exit
|
|
48
50
|
break;
|
|
49
51
|
case 'EADDRINUSE':
|
|
50
|
-
console.error(`${bind} is already in use`); // eslint-disable-line no-console
|
|
51
|
-
process.exit(1); // eslint-disable-line no-process-exit
|
|
52
|
+
console.error(`${bind} is already in use`); // eslint-disable-line no-console
|
|
53
|
+
process.exit(1); // eslint-disable-line no-process-exit
|
|
52
54
|
break;
|
|
53
55
|
default:
|
|
54
56
|
throw error;
|
|
@@ -25,7 +25,9 @@ export function getStringValue(index: number, args: string[]): string {
|
|
|
25
25
|
*/
|
|
26
26
|
export function getURLValue(index: number, args: string[]): string {
|
|
27
27
|
const value = getStringValue(index, args);
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
28
29
|
console.log(`Input tileset value: ${value}`);
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
29
31
|
console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
|
|
30
32
|
return value.replace(/\\/g, '/');
|
|
31
33
|
}
|
|
@@ -52,7 +52,7 @@ export type TextureSetDefinition = {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export class ConversionDump {
|
|
55
|
-
/**Restored/resumed dump indicator */
|
|
55
|
+
/** Restored/resumed dump indicator */
|
|
56
56
|
restored: boolean = false;
|
|
57
57
|
/** Conversion options */
|
|
58
58
|
private options?: ConversionDumpOptions;
|
|
@@ -138,7 +138,8 @@ export class ConversionDump {
|
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
} catch (error) {
|
|
141
|
-
|
|
141
|
+
// prettier-ignore
|
|
142
|
+
console.log('Can\'t open dump file', error); // eslint-disable-line no-console
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
await this.deleteDumpFile();
|
|
@@ -192,7 +193,8 @@ export class ConversionDump {
|
|
|
192
193
|
)
|
|
193
194
|
);
|
|
194
195
|
} catch (error) {
|
|
195
|
-
|
|
196
|
+
// prettier-ignore
|
|
197
|
+
console.log('Can\'t update dump file', error); // eslint-disable-line no-console
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
}
|
|
@@ -305,30 +307,43 @@ export class ConversionDump {
|
|
|
305
307
|
async updateConvertedTilesDump(
|
|
306
308
|
changedRecords: {outputId?: number | string; sourceId?: string; resourceType?: string}[],
|
|
307
309
|
writeResults: PromiseSettledResult<string | null>[]
|
|
308
|
-
) {
|
|
310
|
+
): Promise<void> {
|
|
309
311
|
for (let i = 0; i < changedRecords.length; i++) {
|
|
310
312
|
if (changedRecords[i] && 'value' in writeResults[i]) {
|
|
311
313
|
const {sourceId, resourceType, outputId} = changedRecords[i];
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
this.updateNodes(sourceId, outputId, resourceType);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
await this.updateDumpFile();
|
|
318
|
+
}
|
|
316
319
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Update done status for a node
|
|
322
|
+
* @param sourceId - source resource Id
|
|
323
|
+
* @param outputId - output node/tile Id
|
|
324
|
+
* @param resourceType - type of resource
|
|
325
|
+
* @returns void
|
|
326
|
+
*/
|
|
327
|
+
private updateNodes(sourceId?: string, outputId?: string | number, resourceType?: string) {
|
|
328
|
+
if (!sourceId || !resourceType || !outputId) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
for (const node of this.tilesConverted[sourceId].nodes) {
|
|
332
|
+
if (node.nodeId === outputId && node.progress) {
|
|
333
|
+
node.progress[resourceType] = true;
|
|
334
|
+
|
|
335
|
+
let done = false;
|
|
336
|
+
for (const key in node.progress) {
|
|
337
|
+
done = node.progress[key];
|
|
338
|
+
if (!done) break;
|
|
328
339
|
}
|
|
340
|
+
node.done = done;
|
|
341
|
+
if (node.done) {
|
|
342
|
+
delete node.progress;
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
329
345
|
}
|
|
330
346
|
}
|
|
331
|
-
await this.updateDumpFile();
|
|
332
347
|
}
|
|
333
348
|
|
|
334
349
|
/**
|
|
@@ -20,7 +20,7 @@ export async function writeFile(
|
|
|
20
20
|
if (data instanceof Promise) {
|
|
21
21
|
toWriteData = new Uint8Array(await data);
|
|
22
22
|
} else if (data instanceof ArrayBuffer) {
|
|
23
|
-
toWriteData = new Uint8Array(data
|
|
23
|
+
toWriteData = new Uint8Array(data);
|
|
24
24
|
} else {
|
|
25
25
|
toWriteData = data;
|
|
26
26
|
}
|
|
@@ -31,7 +31,7 @@ export async function writeFile(
|
|
|
31
31
|
} catch (err) {
|
|
32
32
|
throw err;
|
|
33
33
|
}
|
|
34
|
-
console.log(`${pathFile} saved.`); // eslint-disable-line
|
|
34
|
+
console.log(`${pathFile} saved.`); // eslint-disable-line no-console
|
|
35
35
|
return pathFile;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -57,15 +57,13 @@ export async function writeFileForSlpk(
|
|
|
57
57
|
if (!compressList.includes(pathFile)) {
|
|
58
58
|
compressList.push(pathFile);
|
|
59
59
|
return `${pathFile}.gz`;
|
|
60
|
-
} else {
|
|
61
|
-
return null;
|
|
62
60
|
}
|
|
63
|
-
|
|
64
|
-
const pathGzFile = await compressFileWithGzip(pathFile);
|
|
65
|
-
// After compression, we don't need an uncompressed file
|
|
66
|
-
await removeFile(pathFile);
|
|
67
|
-
return pathGzFile;
|
|
61
|
+
return null;
|
|
68
62
|
}
|
|
63
|
+
const pathGzFile = await compressFileWithGzip(pathFile);
|
|
64
|
+
// After compression, we don't need an uncompressed file
|
|
65
|
+
await removeFile(pathFile);
|
|
66
|
+
return pathGzFile;
|
|
69
67
|
}
|
|
70
68
|
return pathFile;
|
|
71
69
|
}
|
|
@@ -79,7 +77,7 @@ export async function writeFileForSlpk(
|
|
|
79
77
|
export async function openJson(path: string, fileName: string): Promise<{[key: string]: any}> {
|
|
80
78
|
return new Promise((resolve, reject) => {
|
|
81
79
|
let count = 0;
|
|
82
|
-
console.log(`load ${path}/${fileName}.`); // eslint-disable-line
|
|
80
|
+
console.log(`load ${path}/${fileName}.`); // eslint-disable-line no-console
|
|
83
81
|
const intervalId = setInterval(() => {
|
|
84
82
|
const pathFile = join(path, fileName);
|
|
85
83
|
load(pathFile, JSONLoader)
|
|
@@ -119,6 +117,7 @@ export async function isFileExists(fileName: string): Promise<boolean> {
|
|
|
119
117
|
*/
|
|
120
118
|
export function removeDir(path: string) {
|
|
121
119
|
// (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
|
|
120
|
+
// @ts-ignore
|
|
122
121
|
return fs.rm(path, {recursive: true});
|
|
123
122
|
}
|
|
124
123
|
|
|
@@ -148,6 +147,7 @@ export async function renameFile(oldPath: string, newPath: string): Promise<void
|
|
|
148
147
|
try {
|
|
149
148
|
await fs.rename(oldPath, newPath);
|
|
150
149
|
} catch (err) {
|
|
151
|
-
|
|
150
|
+
// prettier-ignore
|
|
151
|
+
console.log('Can\'t rename file', err); // eslint-disable-line no-console
|
|
152
152
|
}
|
|
153
153
|
}
|
|
@@ -14,13 +14,12 @@ export function timeConverter(time: number | [number, number]): string {
|
|
|
14
14
|
const timeInSeconds = Math.floor(time / milliSecondsInSecond);
|
|
15
15
|
const milliseconds = time - timeInSeconds * milliSecondsInSecond;
|
|
16
16
|
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
17
|
-
} else {
|
|
18
|
-
// time - high-resolution real time in a [seconds, nanoseconds] tuple Array
|
|
19
|
-
const nanoSecondsInMillisecond = 1e6;
|
|
20
|
-
const timeInSeconds = time[0];
|
|
21
|
-
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
22
|
-
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
23
17
|
}
|
|
18
|
+
// time - high-resolution real time in a [seconds, nanoseconds] tuple Array
|
|
19
|
+
const nanoSecondsInMillisecond = 1e6;
|
|
20
|
+
const timeInSeconds = time[0];
|
|
21
|
+
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
22
|
+
return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
function timeConverterFromSecondsAndMilliseconds(timeInSeconds: number, milliseconds: number) {
|
|
@@ -30,7 +30,7 @@ export type WriteQueueItem = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {
|
|
33
|
-
private intervalId?: NodeJS.
|
|
33
|
+
private intervalId?: NodeJS.Timer; // eslint-disable-line no-undef
|
|
34
34
|
private conversionDump: ConversionDump;
|
|
35
35
|
public writePromise: Promise<void> | null = null;
|
|
36
36
|
public fileMap: {[key: string]: string} = {};
|
|
@@ -65,7 +65,7 @@ export default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
startListening() {
|
|
68
|
-
this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
|
|
68
|
+
this.intervalId = setInterval(() => this.startWrite.bind(this), this.listeningInterval);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
stopListening() {
|
|
@@ -33,6 +33,7 @@ export default class SLPKExtractor {
|
|
|
33
33
|
*/
|
|
34
34
|
public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {
|
|
35
35
|
if (isBrowser) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
36
37
|
console.log(BROWSER_ERROR_MESSAGE);
|
|
37
38
|
return BROWSER_ERROR_MESSAGE;
|
|
38
39
|
}
|
|
@@ -71,7 +72,7 @@ export default class SLPKExtractor {
|
|
|
71
72
|
return path.join(path.dirname(fileName), 'index.json.gz');
|
|
72
73
|
}
|
|
73
74
|
// finds path with name part and extention part
|
|
74
|
-
|
|
75
|
+
const parts = /^(.*\/[^\/\.]*)(\..+)$/.exec(fileName);
|
|
75
76
|
if (!parts) {
|
|
76
77
|
return null;
|
|
77
78
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import '@loaders.gl/polyfills';
|
|
3
2
|
import SLPKExtractor from './slpk-extractor/slpk-extractor';
|
|
4
3
|
import {getURLValue, validateOptionsWithEqual} from './lib/utils/cli-utils';
|
|
@@ -41,18 +40,21 @@ async function main() {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
main().catch((error) => {
|
|
44
|
-
console.log(error);
|
|
45
|
-
process.exit(1); // eslint-disable-line
|
|
43
|
+
console.log(error); // eslint-disable-line no-console
|
|
44
|
+
process.exit(1); // eslint-disable-line no-process-exit
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* Output for `npx slpk-extractor --help`
|
|
50
49
|
*/
|
|
51
50
|
function printHelp(): void {
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
52
|
console.log('cli: converter slpk to I3S...');
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
53
54
|
console.log('--output [Output folder, default: "data" folder]');
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
54
56
|
console.log('--tileset [SLPK file]');
|
|
55
|
-
process.exit(0); // eslint-disable-line
|
|
57
|
+
process.exit(0); // eslint-disable-line no-process-exit
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/**
|
|
@@ -60,9 +62,12 @@ function printHelp(): void {
|
|
|
60
62
|
* @param options validated slpk-extractor options
|
|
61
63
|
*/
|
|
62
64
|
async function convert(options: ValidatedSLPKExtractionOptions) {
|
|
63
|
-
|
|
64
|
-
console.log(
|
|
65
|
-
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.log('------------------------------------------------');
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log('Starting conversion of SLPK');
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
console.log('------------------------------------------------');
|
|
66
71
|
const slpkExtractor = new SLPKExtractor();
|
|
67
72
|
slpkExtractor.extract({
|
|
68
73
|
inputUrl: options.tileset,
|
|
@@ -80,7 +85,9 @@ function validateOptions(options: SLPKExtractionOptions): ValidatedSLPKExtractio
|
|
|
80
85
|
const mandatoryOptionsWithExceptions: {
|
|
81
86
|
[key: string]: () => void;
|
|
82
87
|
} = {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
83
89
|
output: () => console.log('Missed: --output [Output path name]'),
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
84
91
|
tileset: () => console.log('Missed: --tileset [SLPK file]')
|
|
85
92
|
};
|
|
86
93
|
const exceptions: (() => void)[] = [];
|
|
@@ -92,7 +99,7 @@ function validateOptions(options: SLPKExtractionOptions): ValidatedSLPKExtractio
|
|
|
92
99
|
}
|
|
93
100
|
if (exceptions.length) {
|
|
94
101
|
exceptions.forEach((exeption) => exeption());
|
|
95
|
-
process.exit(1);
|
|
102
|
+
process.exit(1); // eslint-disable-line no-process-exit
|
|
96
103
|
}
|
|
97
104
|
return <ValidatedSLPKExtractionOptions>options;
|
|
98
105
|
}
|
|
@@ -119,6 +126,7 @@ function parseOptions(args: string[]): SLPKExtractionOptions {
|
|
|
119
126
|
printHelp();
|
|
120
127
|
break;
|
|
121
128
|
default:
|
|
129
|
+
// eslint-disable-next-line no-console
|
|
122
130
|
console.warn(`Unknown option ${arg}`);
|
|
123
131
|
process.exit(0); // eslint-disable-line
|
|
124
132
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-converter.js","names":["join","process","transform","load","isBrowser","I3SLoader","I3SAttributeLoader","COORDINATE_SYSTEM","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","createObbFromMbs","WorkerFarm","BROWSER_ERROR_MESSAGE","B3dmConverter","getNodeCount","loadFromArchive","loadI3SContent","openSLPK","ConversionDump","Progress","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","workerSource","slpkFilesystem","loaderOptions","_nodeWorkers","reuseWorkers","worker","i3s","coordinateSystem","LNGLAT_OFFSETS","decodeTextures","workerUrl","conversionDump","progress","convert","_this$sourceTileset","console","log","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","inquirer","analyze","hrtime","preprocessResult","preprocessConversion","startMonitoring","isTileset","rootNode","root","obb","mbs","createDump","restored","result","prompt","name","type","message","resumeConversion","reset","e","rootTile","boundingVolume","box","geometricError","children","refine","_addChildren","tileset","JSON","stringify","deleteDumpFile","stopMonitoring","_finishConversion","slpk","destroy","workerFarm","getWorkerFarm","nodesCount","stepsTotal","convertChildNode","parentSourceNode","parentNode","level","childNodeInfo","nextParentNode","sourceChild","_loadChildNode","contentUrl","isFileConversionComplete","id","child","_createChildAndBoundingVolume","push","content","vertexCount","featureAttributes","_loadChildAttributes","i3sAttributesData","tileContent","textureFormat","b3dmConverter","b3dm","addNode","Uint8Array","updateConvertedNodesDumpFile","stepsDone","timeRemainingString","timeRemaining","getTimeRemainingString","percentString","getPercentString","progressString","_this$sourceTileset2","header","nodePagesTile","formTileFromNodePages","parseInt","nodeUrl","_relativeUrlToFullUrl","url","href","isTileHeader","loadContent","uri","baseUrl","arguments","length","undefined","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","promises","attributeUrls","index","attribute","attributeName","attributeType","_getAttributeType","attributesList","Promise","all","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime"],"sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"sourcesContent":["import type {\n AttributeStorageInfo,\n FeatureAttribute,\n NodeReference,\n I3STilesetHeader\n} from '@loaders.gl/i3s';\nimport type {Tile3DBoundingVolume, Tiles3DTileJSON} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {load, isBrowser} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';\nimport {Geoid} from '@math.gl/geoid';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {WorkerFarm} from '@loaders.gl/worker-utils';\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport B3dmConverter, {I3SAttributesData} from './helpers/b3dm-converter';\nimport {I3STileHeader} from '@loaders.gl/i3s/src/types';\nimport {getNodeCount, loadFromArchive, loadI3SContent, openSLPK} from './helpers/load-i3s';\nimport {I3SLoaderOptions} from '@loaders.gl/i3s/src/i3s-loader';\nimport {ZipFileSystem} from '../../../zip/src';\nimport {ConversionDump, ConversionDumpOptions} from '../lib/utils/conversion-dump';\nimport {Progress} from '../i3s-converter/helpers/progress';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: Geoid | null;\n sourceTileset: I3STilesetHeader | null;\n attributeStorageInfo?: AttributeStorageInfo[] | null;\n workerSource: {[key: string]: string} = {};\n slpkFilesystem: ZipFileSystem | null = null;\n loaderOptions: I3SLoaderOptions = {\n _nodeWorkers: true,\n reuseWorkers: true,\n // TODO: converter freezes in the end because of i3s-content-worker\n worker: false,\n i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false},\n // We need to load local fs workers because nodejs can't load workers from the Internet\n 'i3s-content': {\n workerUrl: './modules/i3s/dist/i3s-content-worker-node.js'\n }\n };\n conversionDump: ConversionDump;\n progress: Progress;\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n this.workerSource = {};\n this.conversionDump = new ConversionDump();\n this.progress = new Progress();\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n public async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth?: number;\n egmFilePath: string;\n inquirer?: Promise<unknown>;\n analyze?: boolean;\n }): Promise<any> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath, inquirer, analyze} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth, inquirer};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n this.slpkFilesystem = await openSLPK(inputUrl);\n\n let preprocessResult = true;\n if (analyze || this.slpkFilesystem) {\n preprocessResult = await this.preprocessConversion();\n if (!preprocessResult || analyze) {\n return;\n }\n }\n\n this.progress.startMonitoring();\n\n this.sourceTileset = await loadFromArchive(\n inputUrl,\n I3SLoader,\n {\n ...this.loaderOptions,\n // @ts-expect-error `isTileset` can be boolean of 'auto' but TS expects a string\n i3s: {...this.loaderOptions.i3s, isTileset: true}\n },\n this.slpkFilesystem\n );\n\n if (!this.sourceTileset) {\n return;\n }\n\n const rootNode = this.sourceTileset?.root;\n if (!rootNode.obb) {\n rootNode.obb = createObbFromMbs(rootNode.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = this.sourceTileset.attributeStorageInfo;\n\n await this.conversionDump.createDump(options as ConversionDumpOptions);\n if (this.conversionDump.restored && this.options.inquirer) {\n const result = await this.options.inquirer.prompt([\n {\n name: 'resumeConversion',\n type: 'confirm',\n message:\n 'Dump file of the previous conversion exists, do you want to resume that conversion?'\n }\n ]);\n if (!result.resumeConversion) {\n this.conversionDump.reset();\n }\n }\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n if (!this.conversionDump.restored) {\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n }\n\n const rootTile: Tiles3DTileJSON = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(rootNode),\n children: [],\n refine: 'REPLACE'\n };\n\n await this._addChildren(rootNode, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate());\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n await this.conversionDump.deleteDumpFile();\n\n this.progress.stopMonitoring();\n\n await this._finishConversion({slpk: false, outputPath, tilesetName});\n\n if (this.slpkFilesystem) {\n this.slpkFilesystem.destroy();\n }\n\n // Clean up worker pools\n const workerFarm = WorkerFarm.getWorkerFarm({});\n workerFarm.destroy();\n }\n\n /**\n * Preprocess stage of the tile converter. Calculate number of nodes\n * @returns true - the conversion is possible, false - the tileset's content is not supported\n */\n private async preprocessConversion(): Promise<boolean> {\n console.log(`Analyze source layer`);\n const nodesCount = await getNodeCount(this.slpkFilesystem);\n this.progress.stepsTotal = nodesCount;\n\n console.log(`------------------------------------------------`);\n console.log(`Preprocess results:`);\n if (this.slpkFilesystem) {\n console.log(`Node count: ${nodesCount}`);\n if (nodesCount === 0) {\n console.log('Node count is 0. The conversion will be interrupted.');\n console.log(`------------------------------------------------`);\n return false;\n }\n } else {\n console.log(`Node count cannot be calculated for the remote dataset`);\n }\n\n console.log(`------------------------------------------------`);\n return true;\n }\n\n /**\n * Convert particular I3S Node\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n * @param childNodeInfo child node to convert\n */\n private async convertChildNode(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number,\n childNodeInfo: NodeReference\n ): Promise<void> {\n let nextParentNode = parentNode;\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n if (sourceChild.contentUrl) {\n if (\n this.conversionDump.restored &&\n this.conversionDump.isFileConversionComplete(`${sourceChild.id}.b3dm`) &&\n (sourceChild.obb || sourceChild.mbs)\n ) {\n const {child} = this._createChildAndBoundingVolume(sourceChild);\n parentNode.children.push(child);\n await this._addChildren(sourceChild, child, level + 1);\n return;\n }\n const content = await loadI3SContent(\n this.sourceTileset,\n sourceChild,\n this.loaderOptions,\n this.slpkFilesystem\n );\n\n if (!content) {\n await this._addChildren(sourceChild, parentNode, level + 1);\n return;\n }\n\n this.vertexCounter += content?.vertexCount || 0;\n\n let featureAttributes: FeatureAttribute | null = null;\n if (this.attributeStorageInfo) {\n featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);\n }\n\n const {child, boundingVolume} = this._createChildAndBoundingVolume(sourceChild);\n\n const i3sAttributesData: I3SAttributesData = {\n tileContent: content,\n box: boundingVolume.box || [],\n textureFormat: sourceChild.textureFormat\n };\n\n const b3dmConverter = new B3dmConverter();\n const b3dm = await b3dmConverter.convert(i3sAttributesData, featureAttributes);\n\n await this.conversionDump.addNode(`${sourceChild.id}.b3dm`, sourceChild.id);\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n await this.conversionDump.updateConvertedNodesDumpFile(\n `${sourceChild.id}.b3dm`,\n sourceChild.id,\n true\n );\n parentNode.children.push(child);\n nextParentNode = child;\n }\n\n this.progress.stepsDone += 1;\n let timeRemainingString = 'Calculating time left...';\n const timeRemaining = this.progress.getTimeRemainingString();\n if (timeRemaining) {\n timeRemainingString = `${timeRemaining} left`;\n }\n const percentString = this.progress.getPercentString();\n const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : '';\n console.log(`[converted${progressString}]: ${childNodeInfo.id}`); // eslint-disable-line\n\n await this._addChildren(sourceChild, nextParentNode, level + 1);\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: I3STileHeader,\n parentNode: Tiles3DTileJSON,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.children || []) {\n await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(\n parentNode: I3STileHeader,\n childNodeInfo: NodeReference\n ): Promise<I3STileHeader> {\n let header;\n if (this.sourceTileset?.nodePagesTile) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(\n parseInt(childNodeInfo.id)\n );\n } else {\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href!);\n // load metadata\n const options: I3SLoaderOptions = {\n i3s: {\n ...this.loaderOptions,\n // @ts-expect-error\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await loadFromArchive(nodeUrl, I3SLoader, options, this.slpkFilesystem);\n }\n return header;\n }\n\n /**\n * Create child and child's boundingVolume for the converted node\n * @param sourceChild\n * @returns child and child's boundingVolume\n */\n private _createChildAndBoundingVolume(sourceChild: I3STileHeader): {\n boundingVolume: Tile3DBoundingVolume;\n child: Tiles3DTileJSON;\n } {\n if (!sourceChild.obb) {\n sourceChild.obb = createObbFromMbs(sourceChild.mbs);\n }\n const boundingVolume: Tile3DBoundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)\n };\n const child: Tiles3DTileJSON = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: [],\n content: {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n }\n };\n return {boundingVolume, child};\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string = '', relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: I3STileHeader,\n attributeStorageInfo: AttributeStorageInfo[]\n ): Promise<FeatureAttribute> {\n const promises: any[] = [];\n const {attributeUrls = []} = sourceChild;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(loadFromArchive(inputUrl, I3SAttributeLoader, options, this.slpkFilesystem));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n}\n"],"mappings":"AAQA,SAAQA,IAAI,QAAO,MAAM;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAO,iBAAiB;AAAC,SAGzEC,SAAS;AAAA,SACTC,kBAAkB;AAAA,SAClBC,sCAAsC;AAAA,SACtCC,SAAS,EAAEC,SAAS;AAAA,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1
|
-
{"version":3,"file":"b3dm-converter.js","names":["encodeSync","GLTFScenegraph","GLTFWriter","Tile3DWriter","Matrix4","Vector3","Ellipsoid","convertTextureAtlas","generateSyntheticIndices","Z_UP_TO_Y_UP_MATRIX","scratchVector","KHR_MATERIALS_UNLIT","METALLIC_FACTOR_DEFAULT","ROUGHNESS_FACTOR_DEFAULT","B3dmConverter","constructor","rtcCenter","i3sTile","convert","i3sAttributesData","featureAttributes","arguments","length","undefined","gltf","buildGLTF","b3dm","gltfEncoded","Uint8Array","type","featuresLength","_getFeaturesLength","batchTable","tileContent","textureFormat","box","material","attributes","indices","originalIndices","modelMatrix","gltfBuilder","textureIndex","_addI3sTextureToGLTF","pbrMetallicRoughness","metallicFactor","roughnessFactor","addObjectExtension","addExtension","pbrMaterialInfo","_convertI3sMaterialToGLTFMaterial","materialIndex","addMaterial","positions","positionsValue","value","uvRegions","texCoords","cartesianOrigin","cartographicOrigin","WGS84","cartesianToCartographic","_normalizePositions","_createBatchIds","normals","_checkNormals","size","meshIndex","addMesh","mode","transformMatrix","_generateTransformMatrix","nodeIndex","addNode","matrix","sceneIndex","addScene","nodeIndices","setDefaultScene","createBinaryChunk","gltfBuffer","texture","selectedTexture","baseColorTexture","source","image","mimeType","_deduceMimeTypeFromFormat","imageIndex","addImage","addTexture","colors","newPositionsValue","Float32Array","index","vertex","subarray","cartesianOriginVector","vertexVector","Array","from","transform","add","cartographicToCartesian","subtract","set","translateOriginMatrix","translate","result","multiplyLeft","i3sContent","featureIds","OBJECTID","objectIds","i","featureId","batchId","indexOf","_BATCHID","byteOffset","format","console","warn","isTextureIndexExists","alphaMode","doubleSided","texCoord","baseColorFactor","_setGLTFTexture","materialDefinition","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","firstKey","Object","keys","find"],"sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"sourcesContent":["import type {I3STileContent} from '@loaders.gl/i3s';\nimport {encodeSync} from '@loaders.gl/core';\nimport {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';\nimport {Tile3DWriter} from '@loaders.gl/3d-tiles';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {convertTextureAtlas} from './texture-atlas';\nimport {generateSyntheticIndices} from '../../lib/utils/geometry-utils';\n\nconst Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);\nconst scratchVector = new Vector3();\nconst KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';\nconst METALLIC_FACTOR_DEFAULT = 1.0;\nconst ROUGHNESS_FACTOR_DEFAULT = 1.0;\n\nexport type I3SAttributesData = {\n tileContent: I3STileContent;\n box: number[];\n textureFormat: string;\n};\n\n/**\n * Converts content of an I3S node to *.b3dm's file content\n */\nexport default class B3dmConverter {\n // @ts-expect-error\n rtcCenter: Float32Array;\n i3sTile: any;\n\n /**\n * The starter of content conversion\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded content\n */\n async convert(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any = null\n ): Promise<ArrayBuffer> {\n const gltf = await this.buildGLTF(i3sAttributesData, featureAttributes);\n const b3dm = encodeSync(\n {\n gltfEncoded: new Uint8Array(gltf),\n type: 'b3dm',\n featuresLength: this._getFeaturesLength(featureAttributes),\n batchTable: featureAttributes\n },\n Tile3DWriter\n );\n return b3dm;\n }\n\n /**\n * Build and encode gltf\n * @param i3sTile - Tile3D instance for I3S node\n * @returns - encoded glb content\n */\n async buildGLTF(\n i3sAttributesData: I3SAttributesData,\n featureAttributes: any\n ): Promise<ArrayBuffer> {\n const {tileContent, textureFormat, box} = i3sAttributesData;\n const {material, attributes, indices: originalIndices, modelMatrix} = tileContent;\n const gltfBuilder = new GLTFScenegraph();\n\n const textureIndex = await this._addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder);\n\n // Add KHR_MATERIALS_UNLIT extension in the following cases:\n // - metallicFactor or roughnessFactor are set to default values\n // - metallicFactor or roughnessFactor are not set\n const pbrMetallicRoughness = material?.pbrMetallicRoughness;\n if (\n pbrMetallicRoughness &&\n (pbrMetallicRoughness.metallicFactor === undefined ||\n pbrMetallicRoughness.metallicFactor === METALLIC_FACTOR_DEFAULT) &&\n (pbrMetallicRoughness.roughnessFactor === undefined ||\n pbrMetallicRoughness.roughnessFactor === ROUGHNESS_FACTOR_DEFAULT)\n ) {\n gltfBuilder.addObjectExtension(material, KHR_MATERIALS_UNLIT, {});\n gltfBuilder.addExtension(KHR_MATERIALS_UNLIT);\n }\n\n const pbrMaterialInfo = this._convertI3sMaterialToGLTFMaterial(material, textureIndex);\n const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);\n\n const positions = attributes.positions;\n const positionsValue = positions.value;\n\n if (attributes.uvRegions && attributes.texCoords) {\n attributes.texCoords.value = convertTextureAtlas(\n attributes.texCoords.value,\n attributes.uvRegions.value\n );\n }\n\n const cartesianOrigin = new Vector3(box);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n\n attributes.positions.value = this._normalizePositions(\n positionsValue,\n cartesianOrigin,\n cartographicOrigin,\n modelMatrix\n );\n this._createBatchIds(tileContent, featureAttributes);\n if (attributes.normals && !this._checkNormals(attributes.normals.value)) {\n delete attributes.normals;\n }\n const indices =\n originalIndices || generateSyntheticIndices(positionsValue.length / positions.size);\n const meshIndex = gltfBuilder.addMesh({\n attributes,\n indices,\n material: materialIndex,\n mode: 4\n });\n const transformMatrix = this._generateTransformMatrix(cartesianOrigin);\n const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});\n const sceneIndex = gltfBuilder.addScene({nodeIndices: [nodeIndex]});\n gltfBuilder.setDefaultScene(sceneIndex);\n\n gltfBuilder.createBinaryChunk();\n\n const gltfBuffer = encodeSync(gltfBuilder.gltf, GLTFWriter);\n\n return gltfBuffer;\n }\n\n /**\n * Update gltfBuilder with texture from I3S tile\n * @param {object} i3sTile - Tile3D object\n * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF\n * @returns {Promise<number | null>} - GLTF texture index\n */\n async _addI3sTextureToGLTF(tileContent, textureFormat, gltfBuilder) {\n const {texture, material, attributes} = tileContent;\n let textureIndex = null;\n let selectedTexture = texture;\n if (!texture && material) {\n selectedTexture =\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.baseColorTexture &&\n material.pbrMetallicRoughness.baseColorTexture.texture.source.image;\n }\n if (selectedTexture) {\n const mimeType = this._deduceMimeTypeFromFormat(textureFormat);\n const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);\n textureIndex = gltfBuilder.addTexture({imageIndex});\n delete attributes.colors;\n }\n return textureIndex;\n }\n\n /**\n * Generate a positions array which is correct for 3DTiles/GLTF format\n * @param {Float64Array} positionsValue - the input geometry positions array\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system\n * @param {number[]} modelMatrix - the model matrix of geometry\n * @returns {Float32Array} - the output geometry positions array\n */\n _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {\n const newPositionsValue = new Float32Array(positionsValue.length);\n for (let index = 0; index < positionsValue.length; index += 3) {\n const vertex = positionsValue.subarray(index, index + 3);\n const cartesianOriginVector = new Vector3(cartesianOrigin);\n let vertexVector = new Vector3(Array.from(vertex))\n .transform(modelMatrix)\n .add(cartographicOrigin);\n Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);\n vertexVector = scratchVector.subtract(cartesianOriginVector);\n newPositionsValue.set(vertexVector, index);\n }\n return newPositionsValue;\n }\n\n /**\n * Generate the transformation matrix for GLTF node:\n * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node\n * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)\n * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)\n * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system\n * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)\n */\n _generateTransformMatrix(cartesianOrigin) {\n const translateOriginMatrix = new Matrix4().translate(cartesianOrigin);\n const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);\n return result;\n }\n\n /**\n * Create _BATCHID attribute\n * @param {Object} i3sContent - the source object\n * @returns {void}\n */\n _createBatchIds(i3sContent, featureAttributes) {\n const {featureIds} = i3sContent;\n const {OBJECTID: objectIds} = featureAttributes || {};\n if (!featureIds || !objectIds) {\n return;\n }\n\n for (let i = 0; i < featureIds.length; i++) {\n const featureId = featureIds[i];\n const batchId = objectIds.indexOf(featureId);\n featureIds[i] = batchId;\n }\n\n i3sContent.attributes._BATCHID = {\n size: 1,\n byteOffset: 0,\n value: featureIds\n };\n }\n\n /**\n * Deduce mime type by format from `textureSetDefinition.formats[0].format`\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md\n * @param {string} format - format name\n * @returns {string} mime type.\n */\n _deduceMimeTypeFromFormat(format) {\n switch (format) {\n case 'jpg':\n return 'image/jpeg';\n case 'png':\n return 'image/png';\n case 'ktx2':\n return 'image/ktx2';\n default:\n console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef\n return 'image/jpeg';\n }\n }\n\n /**\n * Convert i3s material to GLTF compatible material\n * @param {object} material - i3s material definition\n * @param {number | null} textureIndex - texture index in GLTF\n * @returns {object} GLTF material\n */\n _convertI3sMaterialToGLTFMaterial(material, textureIndex) {\n const isTextureIndexExists = textureIndex !== null;\n\n if (!material) {\n material = {\n alphaMode: 'OPAQUE',\n doubleSided: false,\n pbrMetallicRoughness: {\n metallicFactor: 0,\n roughnessFactor: 1\n }\n };\n\n if (isTextureIndexExists) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else {\n material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];\n }\n\n return material;\n }\n\n if (textureIndex !== null) {\n material = this._setGLTFTexture(material, textureIndex);\n }\n\n return material;\n }\n\n /**\n * Set texture properties in material with GLTF textureIndex\n * @param {object} materialDefinition - i3s material definition\n * @param {number} textureIndex - texture index in GLTF\n * @returns {void}\n */\n _setGLTFTexture(materialDefinition, textureIndex) {\n const material = {\n ...materialDefinition,\n pbrMetallicRoughness: {...materialDefinition.pbrMetallicRoughness}\n };\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.baseColorTexture\n ) {\n material.pbrMetallicRoughness.baseColorTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.emissiveTexture) {\n material.emissiveTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (\n materialDefinition.pbrMetallicRoughness &&\n materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.normalTexture) {\n material.normalTexture = {\n index: textureIndex,\n texCoord: 0\n };\n } else if (materialDefinition.occlusionTexture) {\n material.occlusionTexture = {\n index: textureIndex,\n texCoord: 0\n };\n }\n return material;\n }\n\n /*\n * Returns Features length based on attribute array in attribute object.\n * @param {Object} attributes\n * @returns {Number} Features length .\n */\n _getFeaturesLength(attributes) {\n if (!attributes) {\n return 0;\n }\n const firstKey = Object.keys(attributes)[0];\n return firstKey ? attributes[firstKey].length : 0;\n }\n\n /* Checks that normals buffer is correct\n * @param {TypedArray} normals\n * @returns {boolean} true - normals are correct; false - normals are incorrect\n */\n _checkNormals(normals) {\n // If all normals === 0, the resulting tileset is all in black colors on Cesium\n return normals.find((value) => value);\n }\n}\n"],"mappings":"AACA,SAAQA,UAAU,QAAO,kBAAkB;AAC3C,SAAQC,cA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names":["Vector3","Ellipsoid","OrientedBoundingBox","i3sObbTo3dTilesObb","i3SObb","geoidHeightModel","tiles3DCenter","center","getHeight","cartesianCenter","WGS84","cartographicToCartesian","tiles3DObb","fromCenterHalfSizeQuaternion","halfSize","quaternion","halfAxes","toArray"],"sources":["../../../src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts"],"sourcesContent":["import {Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {OrientedBoundingBox} from '@math.gl/culling';\n// @ts-expect-error\nimport {GeoidHeightModel} from '@loaders.gl/tile-converter/lib/geoid-height-model';\n\n/**\n * Convert quaternion-based OBB to half-axes-based OBB\n * @param i3SObb quaternion based OBB\n * @param geoidHeightModel the Earth Gravity Model instance\n * @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box\n */\nexport function i3sObbTo3dTilesObb(\n i3SObb: {\n center: number[];\n halfSize: number[];\n quaternion: number[];\n },\n geoidHeightModel: GeoidHeightModel\n): number[] {\n const tiles3DCenter = [\n i3SObb.center[0],\n i3SObb.center[1],\n i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])\n ];\n const cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new Vector3());\n const tiles3DObb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(\n cartesianCenter,\n i3SObb.halfSize,\n i3SObb.quaternion\n );\n return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];\n}\n"],"mappings":"AAAA,SAAQA,OAAO,QAAO,eAAe;AACrC,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SAAQC,mBAAmB,QAAO,kBAAkB;AAUpD,OAAO,SAASC,kBAAkBA,CAChCC,MAIC,EACDC,gBAAkC,EACxB;EACV,MAAMC,aAAa,GAAG,CACpBF,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC,EAChBH,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC,EAChBH,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC,GAAGF,gBAAgB,CAACG,SAAS,CAACJ,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC,EAAEH,MAAM,CAACG,MAAM,CAAC,CAAC,CAAC,CAAC,CAClF;EACD,MAAME,eAAe,GAAGR,SAAS,CAACS,KAAK,CAACC,uBAAuB,CAACL,aAAa,EAAE,IAAIN,OAAO,CAAC,CAAC,CAAC;EAC7F,MAAMY,UAAU,GAAG,IAAIV,mBAAmB,CAAC,CAAC,CAACW,4BAA4B,CACvEJ,eAAe,EACfL,MAAM,CAACU,QAAQ,EACfV,MAAM,CAACW,UACT,CAAC;EACD,OAAO,CAAC,GAAGH,UAAU,CAACL,MAAM,EAAE,GAAGK,UAAU,CAACI,QAAQ,CAACC,OAAO,CAAC,CAAC,CAAC;AACjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-i3s.js","names":["load","I3SLoader","parseSLPKArchive","FileHandleFile","ZipFileSystem","makeZipCDHeaderIterator","loadI3SContent","sourceTileset","sourceTile","tilesetLoadOptions","slpkFilesystem","contentUrl","loadOptions","i3s","isTileset","isTileHeader","_tileOptions","attributeUrls","textureUrl","textureFormat","textureLoaderOptions","materialDefinition","isDracoGeometry","mbs","_tilesetOptions","store","attributeStorageInfo","fields","tileContent","loadFromArchive","openSLPK","url","slpkUrlParts","split","slpkFileName","getSlpkUrlParts","fileProvider","archive","undefined","fileSystem","loader","internalFileName","content","fetch","bind","result","length","slice","Error","getNodeCount","count","filesIterator","file","filename","fileName","indexOf"],"sources":["../../../src/3d-tiles-converter/helpers/load-i3s.ts"],"sourcesContent":["import {LoaderWithParser, load} from '@loaders.gl/core';\nimport {\n I3STileContent,\n I3STileHeader,\n I3STilesetHeader,\n I3SLoader,\n I3SLoaderOptions,\n parseSLPKArchive\n} from '@loaders.gl/i3s';\nimport {FileHandleFile} from '@loaders.gl/loader-utils';\nimport {ZipFileSystem, makeZipCDHeaderIterator} from '@loaders.gl/zip';\n\nexport type SLPKUrlParts = {slpkFileName: string; internalFileName: string};\n\n/**\n * Load I3S node content\n * @param sourceTileset - source layer JSON\n * @param sourceTile - source I3S node metadata\n * @param tilesetLoadOptions - load options for Tiles3DLoader\n * @param slpkFilesystem - loaded instance of ZipFileSystem for local convertion from SLPK file\n * @returns - 3DTiles tile content or null\n */\nexport const loadI3SContent = async (\n sourceTileset: I3STilesetHeader | null,\n sourceTile: I3STileHeader,\n tilesetLoadOptions: I3SLoaderOptions,\n slpkFilesystem: ZipFileSystem | null\n): Promise<I3STileContent | null> => {\n if (!sourceTileset || !sourceTile.contentUrl) {\n return null;\n }\n\n const loadOptions: I3SLoaderOptions = {\n ...tilesetLoadOptions,\n i3s: {\n ...tilesetLoadOptions.i3s,\n // @ts-expect-error\n isTileset: false,\n // @ts-expect-error\n isTileHeader: false,\n _tileOptions: {\n attributeUrls: sourceTile.attributeUrls || [],\n textureUrl: sourceTile.textureUrl,\n textureFormat: sourceTile.textureFormat,\n textureLoaderOptions: sourceTile.textureLoaderOptions,\n materialDefinition: sourceTile.materialDefinition,\n isDracoGeometry: sourceTile.isDracoGeometry,\n mbs: sourceTile.mbs\n },\n _tilesetOptions: {\n store: sourceTileset.store,\n // @ts-expect-error\n attributeStorageInfo: sourceTileset.attributeStorageInfo,\n // @ts-expect-error\n fields: sourceTileset.fields\n }\n }\n };\n const tileContent = await loadFromArchive(\n sourceTile.contentUrl,\n I3SLoader,\n loadOptions,\n slpkFilesystem\n );\n\n return tileContent;\n};\n\n/**\n * Load local SLPK file to ZipFileSystem instance\n * @param url - path to SLPK file\n * @returns instance of ZipFileSystem or null if url is not an SLPK file\n */\nexport async function openSLPK(url: string): Promise<ZipFileSystem | null> {\n const slpkUrlParts = url.split('.slpk');\n const {slpkFileName} = getSlpkUrlParts(url) || {};\n if (slpkFileName) {\n const slpkFileName = `${slpkUrlParts[0]}.slpk`;\n const fileProvider = new FileHandleFile(slpkFileName);\n const archive = await parseSLPKArchive(fileProvider, undefined, slpkFileName);\n const fileSystem = new ZipFileSystem(archive);\n return fileSystem;\n }\n return null;\n}\n\n/**\n * Load a resource with load options and .3tz format support\n * @param url - resource URL\n * @param loader - loader to parse data (Tiles3DLoader / CesiumIonLoader)\n * @param loadOptions - i3s loader options\n * @returns i3s resource\n */\nexport async function loadFromArchive(\n url: string,\n loader: LoaderWithParser,\n loadOptions: I3SLoaderOptions,\n fileSystem: ZipFileSystem | null\n) {\n const slpkUrlParts = getSlpkUrlParts(url);\n if (fileSystem !== null && slpkUrlParts !== null) {\n const {internalFileName} = slpkUrlParts;\n const content = await load(internalFileName, loader, {\n ...loadOptions,\n fetch: fileSystem.fetch.bind(fileSystem)\n });\n return content;\n }\n return await load(url, loader, loadOptions);\n}\n\n/**\n * Extract slpk file path and internal from the url\n * For example, for `./path/to/file.slpk/nodes/0` it returns\n * {\"slpkFileName\": \"./path/to/file.slpk\", \"internalFileName\": \"/nodes/0\" }\n * @param url full internal file path\n * @returns object with internal slpk file parts\n */\nfunction getSlpkUrlParts(url: string): SLPKUrlParts | null {\n const slpkUrlParts = url.split('.slpk');\n let result: SLPKUrlParts | null;\n // Not '.slpk'. The file will be loaded with global fetch function\n if (slpkUrlParts.length === 1) {\n result = null;\n } else if (slpkUrlParts.length === 2) {\n result = {slpkFileName: `${slpkUrlParts[0]}.slpk`, internalFileName: slpkUrlParts[1].slice(1)};\n } else {\n throw new Error('Unexpected URL format');\n }\n return result;\n}\n\n/**\n * Get nodes count inside SLPK\n * @param fileSystem - file system of SLPK\n * @returns number of nodes\n */\nexport async function getNodeCount(fileSystem: ZipFileSystem | null): Promise<number> {\n if (!fileSystem?.fileProvider) {\n return 0;\n }\n let count = 0;\n const filesIterator = makeZipCDHeaderIterator(fileSystem.fileProvider);\n for await (const file of filesIterator) {\n const filename = file.fileName;\n if (filename.indexOf('3dNodeIndexDocument.json.gz') >= 0) {\n count++;\n }\n }\n return count;\n}\n"],"mappings":"AAAA,SAA0BA,IAAI,QAAO,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AAY,CAAC,CAAC,CAAE,OAAM;MAAES,gBAAgB,EAAET,YAAY,CAAC,CAAC,CAAC,CAACe,KAAK,CAAC,CAAC;IAAC,CAAC;EAChG,CAAC,MAAM;IACL,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;EAC1C;EACA,OAAOH,MAAM;AACf;AAOA,OAAO,eAAeI,YAAYA,CAACV,UAAgC,EAAmB;EACpF,IAAI,EAACA,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEH,YAAY,GAAE;IAC7B,OAAO,CAAC;EACV;EACA,IAAIc,KAAK,GAAG,CAAC;EACb,MAAMC,aAAa,GAAG9C,uBAAuB,CAACkC,UAAU,CAACH,YAAY,CAAC;EACtE,WAAW,MAAMgB,IAAI,IAAID,aAAa,EAAE;IACtC,MAAME,QAAQ,GAAGD,IAAI,CAACE,QAAQ;IAC9B,IAAID,QAAQ,CAACE,OAAO,CAAC,6BAA6B,CAAC,IAAI,CAAC,EAAE;MACxDL,KAAK,EAAE;IACT;EACF;EACA,OAAOA,KAAK;AACd"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"texture-atlas.js","names":["convertTextureAtlas","texCoords","uvRegions","convertedTexCoords","Float32Array","length","normalisedRegions","normalizeRegions","index","uv","subarray","regions","slice","fractatedUV","fract","subtracted","multiplicationResult","convertedUV","Math","floor","MAX_UINT_16_VALUE","normalizedRegions"],"sources":["../../../src/3d-tiles-converter/helpers/texture-atlas.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/loader-utils';\n\n/**\n * Apply uvRegions to texture coordinates.\n * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md\n * Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n * @param texCoords\n * @param uvRegions\n */\nexport function convertTextureAtlas(texCoords: TypedArray, uvRegions: TypedArray): Float32Array {\n const convertedTexCoords = new Float32Array(texCoords.length);\n const normalisedRegions = normalizeRegions(uvRegions);\n\n for (let index = 0; index < texCoords.length; index += 2) {\n const uv = texCoords.subarray(index, index + 2);\n const regions = normalisedRegions.slice(index * 2, index * 2 + 4);\n // fract(texCoords)\n const fractatedUV = fract([uv[0], uv[1]]);\n // (uvRegions.zw - uvRegions.xy)\n const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy)\n const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];\n // fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n const convertedUV = [\n multiplicationResult[0] + regions[0],\n multiplicationResult[1] + regions[1]\n ];\n\n convertedTexCoords[index] = convertedUV[0];\n convertedTexCoords[index + 1] = convertedUV[1];\n }\n\n return convertedTexCoords;\n}\n\n/**\n * Do fractation of UV array.\n * @param uv\n */\nfunction fract(uv: [number, number]): [number, number] {\n return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];\n}\n\n/**\n * Normalize uvRegions by dividing by the maximum Uint16 value\n * @param regions\n */\nfunction normalizeRegions(regions: TypedArray): number[] {\n // The code is for Uint16Array because it is the spec requirement\n // https://github.com/Esri/i3s-spec/blob/master/docs/1.8/geometryUVRegion.cmn.md\n const MAX_UINT_16_VALUE = 65535;\n const normalizedRegions: number[] = [];\n\n for (let index = 0; index < regions.length; index++) {\n normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;\n }\n\n return normalizedRegions;\n}\n"],"mappings":"AASA,OAAO,SAASA,mBAAmBA,CAACC,SAAqB,EAAEC,SAAqB,EAAgB;EAC9F,MAAMC,kBAAkB,GAAG,IAAIC,YAAY,CAACH,SAAS,CAACI,MAAM,CAAC;EAC7D,MAAMC,iBAAiB,GAAGC,gBAAgB,CAACL,SAAS,CAAC;EAErD,KAAK,IAAIM,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,SAAS,CAACI,MAAM,EAAEG,KAAK,IAAI,CAAC,EAA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SAASF,gBAAgBA,CAACI,OAAmB,EAAY;EAGvD,MAAMS,iBAAiB,GAAG,KAAK;EAC/B,MAAMC,iBAA2B,GAAG,EAAE;EAEtC,KAAK,IAAIb,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGG,OAAO,CAACN,MAAM,EAAEG,KAAK,EAAE,EAAE;IACnDa,iBAAiB,CAACb,KAAK,CAAC,GAAGG,OAAO,CAACH,KAAK,CAAC,GAAGY,iBAAiB;EAC/D;EAEA,OAAOC,iBAAiB;AAC1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tileset.js","names":["transform","ASSET","version","path","default","TILE","boundingVolume","geometricError","refine","content","children","val","map","tile","TILESET","asset","root"],"sources":["../../../src/3d-tiles-converter/json-templates/tileset.ts"],"sourcesContent":["import transform from 'json-map-transform';\n\nconst ASSET = () => ({\n version: {\n path: 'version',\n default: '1.0'\n }\n});\n\nconst TILE = () => ({\n boundingVolume: {\n path: 'boundingVolume'\n },\n geometricError: {\n path: 'geometricError'\n },\n refine: {\n path: 'refine'\n },\n content: {\n path: 'content'\n },\n children: {\n path: 'children',\n transform: (val) => val.map((tile) => transform(tile, TILE()))\n }\n});\n\nexport const TILESET = () => ({\n asset: {\n path: 'asset',\n transform: (val) => transform(val, ASSET())\n },\n geometricError: {\n path: 'root',\n transform: (val) => val.geometricError\n },\n root: {\n path: 'root',\n transform: (val) => transform(val, TILE())\n }\n});\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,oBAAoB;AAE1C,MAAMC,KAAK,GAAGA,CAAA,MAAO;EACnBC,OAAO,EAAE;IACPC,IAAI,EAAE,SAAS;IACfC,OAAO,EAAE;EACX;AACF,CAAC,CAAC;AAEF,MAAMC,IAAI,GAAGA,CAAA,MAAO;EAClBC,cAAc,EAAE;IACdH,IAAI,EAAE;EACR,CAAC;EACDI,cAAc,EAAE;IACdJ,IAAI,EAAE;EACR,CAAC;EACDK,MAAM,EAAE;IACNL,IAAI,EAAE;EACR,CAAC;EACDM,OAAO,EAAE;IACPN,IAAI,EAAE;EACR,CAAC;EACDO,QAAQ,EAAE;IACRP,IAAI,EAAE,UAAU;IAChBH,SAAS,EAAGW,GAAG,IAAKA,GAAG,CAACC,GAAG,CAAEC,IAAI,IAAKb,SAAS,CAACa,IAAI,EAAER,IAAI,CAAC,CAAC,CAAC;EAC/D;AACF,CAAC,CAAC;AAEF,OAAO,MAAMS,OAAO,GAAGA,CAAA,MAAO;EAC5BC,KAAK,EAAE;IACLZ,IAAI,EAAE,OAAO;IACbH,SAAS,EAAGW,GAAG,IAAKX,SAAS,CAACW,GAAG,EAAEV,KAAK,CAAC,CAAC;EAC5C,CAAC;EACDM,cAAc,EAAE;IACdJ,IAAI,EAAE,MAAM;IACZH,SAAS,EAAGW,GAAG,IAAKA,GAAG,CAACJ;EAC1B,CAAC;EACDS,IAAI,EAAE;IACJb,IAAI,EAAE,MAAM;IACZH,SAAS,EAAGW,GAAG,IAAKX,SAAS,CAACW,GAAG,EAAEN,IAAI,CAAC,CAAC;EAC3C;AACF,CAAC,CAAC"}
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["BROWSER_ERROR_MESSAGE","DUMP_FILE_SUFFIX"],"sources":["../src/constants.ts"],"sourcesContent":["export const BROWSER_ERROR_MESSAGE =\n 'Tile converter does not work in browser, only in node js environment';\nexport const DUMP_FILE_SUFFIX = '.dump.json';\n"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,GAChC,sEAAsE;AACxE,OAAO,MAAMC,gBAAgB,GAAG,YAAY"}
|