@loaders.gl/tile-converter 4.2.0-alpha.3 → 4.2.0-alpha.5
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 +3 -3
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +329 -293
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +257 -200
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
- package/dist/3d-tiles-converter/helpers/load-i3s.js +106 -75
- 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 +255 -234
- package/dist/converter.min.cjs +80 -90
- package/dist/deps-installer/deps-installer.js +73 -59
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +207 -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 +145 -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.js +168 -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 +204 -212
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +1148 -829
- 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 +111 -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 +3 -3
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +248 -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 -194
- 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.js +134 -83
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +24 -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 +1044 -898
- 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/www.js +14 -7
- package/dist/i3s-server/controllers/index-controller.js +18 -15
- package/dist/i3s-server/controllers/slpk-controller.js +22 -11
- package/dist/i3s-server/routes/index.js +9 -8
- package/dist/i3s-server/routes/slpk-router.js +18 -17
- package/dist/i3s-server/utils/create-scene-server.js +15 -10
- package/dist/i3s-server/utils/server-utils.js +49 -32
- package/dist/index.cjs +292 -851
- 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.js +63 -36
- package/dist/lib/utils/compress-util.js +20 -15
- package/dist/lib/utils/conversion-dump.d.ts +1 -1
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +209 -187
- package/dist/lib/utils/file-utils.js +122 -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.js +64 -59
- 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 +68 -86
- package/dist/pgm-loader.js +17 -13
- package/dist/slpk-extractor/slpk-extractor.js +59 -50
- package/dist/slpk-extractor-cli.js +82 -59
- package/package.json +18 -18
- 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
|
@@ -1,47 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get string option value from cli arguments
|
|
3
|
+
* @param index - option's name index in the argument's array.
|
|
4
|
+
* The value of the option should be next to name of the option.
|
|
5
|
+
* @param args - cli arguments array
|
|
6
|
+
* @returns - string value of the option
|
|
7
|
+
*/
|
|
1
8
|
export function getStringValue(index, args) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
if (index + 1 >= args.length) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
const value = args[index + 1];
|
|
13
|
+
if (value.indexOf('--') === 0) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
10
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Modyfy URL path to be compatible with fetch
|
|
20
|
+
* @param index - option's name index in the argument's array.
|
|
21
|
+
* The value of the option should be next to name of the option.
|
|
22
|
+
* @param args - cli arguments array
|
|
23
|
+
* @returns - string value of the option
|
|
24
|
+
*/
|
|
11
25
|
export function getURLValue(index, args) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
const value = getStringValue(index, args);
|
|
27
|
+
console.log(`Input tileset value: ${value}`);
|
|
28
|
+
console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
|
|
29
|
+
return value.replace(/\\/g, '/');
|
|
16
30
|
}
|
|
17
31
|
export function validateOptionsWithEqual(args) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
return args.reduce((acc, curr) => {
|
|
33
|
+
const equalSignIndex = curr.indexOf('=');
|
|
34
|
+
const beforeEqual = curr.slice(0, equalSignIndex);
|
|
35
|
+
const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
|
|
36
|
+
const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
|
|
37
|
+
if (condition) {
|
|
38
|
+
return acc.concat(beforeEqual, afterEqual);
|
|
39
|
+
}
|
|
40
|
+
return acc.concat(curr);
|
|
41
|
+
}, []);
|
|
28
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Get integer option value from cli arguments
|
|
45
|
+
* @param index - option's name index in the argument's array
|
|
46
|
+
* The value of the option should be next to name of the option.
|
|
47
|
+
* @param args - cli arguments array
|
|
48
|
+
* @returns - number value of the option
|
|
49
|
+
*/
|
|
29
50
|
export function getIntegerValue(index, args) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
51
|
+
const stringValue = getStringValue(index, args);
|
|
52
|
+
const result = Number.parseInt(stringValue);
|
|
53
|
+
if (isFinite(result)) {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
return NaN;
|
|
36
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Get boolean option value from cli arguments
|
|
60
|
+
* @param index - option's name index in the argument's array
|
|
61
|
+
* The value of the option should be next to name of the option.
|
|
62
|
+
* @param args - cli arguments array
|
|
63
|
+
* @returns - boolean value of the option
|
|
64
|
+
*/
|
|
37
65
|
export function getBooleanValue(index, args) {
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
const stringValue = getStringValue(index, args).toLowerCase().trim();
|
|
67
|
+
if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!stringValue || stringValue === 'true') {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
40
73
|
return false;
|
|
41
|
-
}
|
|
42
|
-
if (!stringValue || stringValue === 'true') {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
74
|
}
|
|
47
|
-
//# sourceMappingURL=cli-utils.js.map
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { createGzip } from 'zlib';
|
|
2
2
|
import { createReadStream, createWriteStream } from 'fs';
|
|
3
|
+
/**
|
|
4
|
+
* Compress file to gzip file
|
|
5
|
+
*
|
|
6
|
+
* @param pathFile - the path to the file
|
|
7
|
+
* @return the path to the gzip file
|
|
8
|
+
*/
|
|
3
9
|
export function compressFileWithGzip(pathFile) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const compressedPathFile = `${pathFile}.gz`;
|
|
11
|
+
const gzip = createGzip();
|
|
12
|
+
const input = createReadStream(pathFile);
|
|
13
|
+
const output = createWriteStream(compressedPathFile);
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
input.on('end', () => {
|
|
16
|
+
console.log(`${compressedPathFile} compressed and saved.`); // eslint-disable-line no-undef,no-console
|
|
17
|
+
resolve(compressedPathFile);
|
|
18
|
+
});
|
|
19
|
+
input.on('error', (error) => {
|
|
20
|
+
console.log(`${compressedPathFile}: compression error!`); // eslint-disable-line no-undef,no-console
|
|
21
|
+
reject(error);
|
|
22
|
+
});
|
|
23
|
+
input.pipe(gzip).pipe(output);
|
|
12
24
|
});
|
|
13
|
-
input.on('error', error => {
|
|
14
|
-
console.log(`${compressedPathFile}: compression error!`);
|
|
15
|
-
reject(error);
|
|
16
|
-
});
|
|
17
|
-
input.pipe(gzip).pipe(output);
|
|
18
|
-
});
|
|
19
25
|
}
|
|
20
|
-
//# sourceMappingURL=compress-util.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoundingVolumes, I3SMaterialDefinition, TextureSetDefinitionFormats } from '@loaders.gl/i3s';
|
|
2
|
-
import { AttributeMetadataInfoObject } from
|
|
2
|
+
import { AttributeMetadataInfoObject } from "../../i3s-converter/helpers/attribute-metadata-info.js";
|
|
3
3
|
export type ConversionDumpOptions = {
|
|
4
4
|
inputUrl: string;
|
|
5
5
|
outputPath: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-dump.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/conversion-dump.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAE,qBAAqB,EAAE,2BAA2B,EAAC,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAC,2BAA2B,EAAC
|
|
1
|
+
{"version":3,"file":"conversion-dump.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/conversion-dump.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,eAAe,EAAE,qBAAqB,EAAE,2BAA2B,EAAC,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAC,2BAA2B,EAAC,+DAA4D;AAKhG,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,uBAAuB,EAAE,OAAO,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAA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
8
8
|
export class ConversionDump {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
tilesConverted,
|
|
56
|
-
textureSetDefinitions,
|
|
57
|
-
attributeMetadataInfo,
|
|
58
|
-
materialDefinitions
|
|
59
|
-
} = dump;
|
|
60
|
-
const ajv = new Ajv();
|
|
61
|
-
const dumpJsonValidate = ajv.compile(dumpJsonSchema);
|
|
62
|
-
const isDumpValid = dumpJsonValidate(dump);
|
|
63
|
-
if (isDumpValid && isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {
|
|
64
|
-
this.tilesConverted = tilesConverted;
|
|
65
|
-
this.textureSetDefinitions = textureSetDefinitions;
|
|
66
|
-
this.attributeMetadataInfo = attributeMetadataInfo;
|
|
67
|
-
this.materialDefinitions = materialDefinitions;
|
|
68
|
-
this.restored = true;
|
|
69
|
-
return;
|
|
9
|
+
constructor() {
|
|
10
|
+
/**Restored/resumed dump indicator */
|
|
11
|
+
this.restored = false;
|
|
12
|
+
this.tilesConverted = {};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a dump with convertion options
|
|
16
|
+
* @param currentOptions - converter options
|
|
17
|
+
*/
|
|
18
|
+
async createDump(currentOptions) {
|
|
19
|
+
const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials = true, metadataClass, analyze = false } = currentOptions;
|
|
20
|
+
this.options = {
|
|
21
|
+
tilesetName,
|
|
22
|
+
slpk,
|
|
23
|
+
egmFilePath,
|
|
24
|
+
inputUrl,
|
|
25
|
+
outputPath,
|
|
26
|
+
draco,
|
|
27
|
+
maxDepth,
|
|
28
|
+
token,
|
|
29
|
+
generateTextures,
|
|
30
|
+
generateBoundingVolumes,
|
|
31
|
+
mergeMaterials,
|
|
32
|
+
metadataClass,
|
|
33
|
+
analyze
|
|
34
|
+
};
|
|
35
|
+
const dumpFilename = join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
36
|
+
if (await isFileExists(dumpFilename)) {
|
|
37
|
+
try {
|
|
38
|
+
const dump = await openJson(join(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
39
|
+
const { options, tilesConverted, textureSetDefinitions, attributeMetadataInfo, materialDefinitions } = dump;
|
|
40
|
+
const ajv = new Ajv();
|
|
41
|
+
const dumpJsonValidate = ajv.compile(dumpJsonSchema);
|
|
42
|
+
const isDumpValid = dumpJsonValidate(dump);
|
|
43
|
+
if (isDumpValid && isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {
|
|
44
|
+
this.tilesConverted = tilesConverted;
|
|
45
|
+
this.textureSetDefinitions = textureSetDefinitions;
|
|
46
|
+
this.attributeMetadataInfo = attributeMetadataInfo;
|
|
47
|
+
this.materialDefinitions = materialDefinitions;
|
|
48
|
+
this.restored = true;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.log("Can't open dump file", error);
|
|
54
|
+
}
|
|
70
55
|
}
|
|
71
|
-
|
|
72
|
-
console.log("Can't open dump file", error);
|
|
73
|
-
}
|
|
56
|
+
await this.deleteDumpFile();
|
|
74
57
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Reset a dump
|
|
60
|
+
*/
|
|
61
|
+
reset() {
|
|
62
|
+
this.restored = false;
|
|
63
|
+
this.tilesConverted = {};
|
|
64
|
+
if (this.textureSetDefinitions) {
|
|
65
|
+
delete this.textureSetDefinitions;
|
|
66
|
+
}
|
|
67
|
+
if (this.attributeMetadataInfo) {
|
|
68
|
+
delete this.attributeMetadataInfo;
|
|
69
|
+
}
|
|
70
|
+
if (this.materialDefinitions) {
|
|
71
|
+
delete this.materialDefinitions;
|
|
72
|
+
}
|
|
82
73
|
}
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Update conversion status in the dump file
|
|
76
|
+
*/
|
|
77
|
+
async updateDumpFile() {
|
|
78
|
+
if (this.options?.outputPath && this.options.tilesetName) {
|
|
79
|
+
try {
|
|
80
|
+
const time = process.hrtime();
|
|
81
|
+
await writeFile(join(this.options.outputPath, this.options.tilesetName), JSON.stringify({
|
|
82
|
+
options: this.options,
|
|
83
|
+
tilesConverted: this.tilesConverted,
|
|
84
|
+
textureSetDefinitions: this.textureSetDefinitions,
|
|
85
|
+
attributeMetadataInfo: this.attributeMetadataInfo,
|
|
86
|
+
materialDefinitions: this.materialDefinitions
|
|
87
|
+
}), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`);
|
|
88
|
+
await renameFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`), join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.log("Can't update dump file", error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Delete a dump file
|
|
97
|
+
*/
|
|
98
|
+
async deleteDumpFile() {
|
|
99
|
+
if (this.options?.outputPath &&
|
|
100
|
+
this.options.tilesetName &&
|
|
101
|
+
(await isFileExists(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)))) {
|
|
102
|
+
await removeFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
|
|
103
|
+
}
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
options: this.options,
|
|
97
|
-
tilesConverted: this.tilesConverted,
|
|
98
|
-
textureSetDefinitions: this.textureSetDefinitions,
|
|
99
|
-
attributeMetadataInfo: this.attributeMetadataInfo,
|
|
100
|
-
materialDefinitions: this.materialDefinitions
|
|
101
|
-
}), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`);
|
|
102
|
-
await renameFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`), join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.log("Can't update dump file", error);
|
|
105
|
-
}
|
|
105
|
+
/**
|
|
106
|
+
* Get record from the tilesConverted Map
|
|
107
|
+
* @param fileName - source filename
|
|
108
|
+
* @returns existing object from the tilesConverted Map
|
|
109
|
+
*/
|
|
110
|
+
getRecord(fileName) {
|
|
111
|
+
return this.tilesConverted[fileName];
|
|
106
112
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Set a record for the dump file
|
|
115
|
+
* @param fileName - key - source filename
|
|
116
|
+
* @param object - value
|
|
117
|
+
*/
|
|
118
|
+
setRecord(fileName, object) {
|
|
119
|
+
this.tilesConverted[fileName] = object;
|
|
112
120
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.setRecord(filename, {
|
|
133
|
-
nodes
|
|
134
|
-
});
|
|
121
|
+
/**
|
|
122
|
+
* Add a node into the dump file for the source file record
|
|
123
|
+
* @param fileName - source filename
|
|
124
|
+
* @param nodeId - nodeId of the node
|
|
125
|
+
*/
|
|
126
|
+
async addNode(filename, nodeId, dumpMetadata) {
|
|
127
|
+
const { nodes } = this.getRecord(filename) || { nodes: [] };
|
|
128
|
+
nodes.push({ nodeId, done: false, dumpMetadata });
|
|
129
|
+
if (nodes.length === 1) {
|
|
130
|
+
this.setRecord(filename, { nodes });
|
|
131
|
+
}
|
|
132
|
+
await this.updateDumpFile();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Clear dump record got the source filename
|
|
136
|
+
* @param fileName - source filename
|
|
137
|
+
*/
|
|
138
|
+
clearDumpRecord(filename) {
|
|
139
|
+
this.setRecord(filename, { nodes: [] });
|
|
135
140
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
addTexturesDefinitions(textureDefinitions) {
|
|
144
|
-
this.textureSetDefinitions = textureDefinitions;
|
|
145
|
-
}
|
|
146
|
-
updateDoneStatus(filename, nodeId, resourceType, value) {
|
|
147
|
-
var _this$tilesConverted$;
|
|
148
|
-
const nodeDump = (_this$tilesConverted$ = this.tilesConverted[filename]) === null || _this$tilesConverted$ === void 0 ? void 0 : _this$tilesConverted$.nodes.find(element => element.nodeId === nodeId);
|
|
149
|
-
if (nodeDump) {
|
|
150
|
-
if (!nodeDump.progress) {
|
|
151
|
-
nodeDump.progress = {};
|
|
152
|
-
}
|
|
153
|
-
nodeDump.progress[resourceType] = value;
|
|
154
|
-
if (!value) {
|
|
155
|
-
nodeDump.done = false;
|
|
156
|
-
}
|
|
141
|
+
/**
|
|
142
|
+
* Add textures definitions into the dump file
|
|
143
|
+
* @param textureDefinitions - textures definitions array
|
|
144
|
+
*/
|
|
145
|
+
addTexturesDefinitions(textureDefinitions) {
|
|
146
|
+
this.textureSetDefinitions = textureDefinitions;
|
|
157
147
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (!done) break;
|
|
148
|
+
/**
|
|
149
|
+
* Update done status object for the writing resources
|
|
150
|
+
* @param fileName - key - source filename
|
|
151
|
+
* @param nodeId - nodeId for the source filename
|
|
152
|
+
* @param resourceType - resource type to update status
|
|
153
|
+
* @param value - value
|
|
154
|
+
*/
|
|
155
|
+
updateDoneStatus(filename, nodeId, resourceType, value) {
|
|
156
|
+
const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
|
|
157
|
+
if (nodeDump) {
|
|
158
|
+
if (!nodeDump.progress) {
|
|
159
|
+
nodeDump.progress = {};
|
|
160
|
+
}
|
|
161
|
+
nodeDump.progress[resourceType] = value;
|
|
162
|
+
if (!value) {
|
|
163
|
+
nodeDump.done = false;
|
|
175
164
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Update dump file according to writing results
|
|
169
|
+
* @param changedRecords - array of parameters ids for the written resources
|
|
170
|
+
* @param writeResults - array of writing resource files results
|
|
171
|
+
*/
|
|
172
|
+
async updateConvertedTilesDump(changedRecords, writeResults) {
|
|
173
|
+
for (let i = 0; i < changedRecords.length; i++) {
|
|
174
|
+
if (changedRecords[i] && 'value' in writeResults[i]) {
|
|
175
|
+
const { sourceId, resourceType, outputId } = changedRecords[i];
|
|
176
|
+
if (!sourceId || !resourceType || !outputId)
|
|
177
|
+
continue;
|
|
178
|
+
for (const node of this.tilesConverted[sourceId].nodes) {
|
|
179
|
+
if (node.nodeId === outputId && node.progress) {
|
|
180
|
+
node.progress[resourceType] = true;
|
|
181
|
+
let done = false;
|
|
182
|
+
for (const key in node.progress) {
|
|
183
|
+
done = node.progress[key];
|
|
184
|
+
if (!done)
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
node.done = done;
|
|
188
|
+
if (node.done) {
|
|
189
|
+
delete node.progress;
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
179
194
|
}
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
195
|
}
|
|
183
|
-
|
|
196
|
+
await this.updateDumpFile();
|
|
184
197
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Update 3d-tiles-converter dump file
|
|
200
|
+
* @param filename - source filename
|
|
201
|
+
* @param nodeId - nodeId
|
|
202
|
+
* @param done - conversion status
|
|
203
|
+
*/
|
|
204
|
+
async updateConvertedNodesDumpFile(filename, nodeId, done) {
|
|
205
|
+
const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
|
|
206
|
+
if (nodeDump) {
|
|
207
|
+
nodeDump.done = done;
|
|
208
|
+
await this.updateDumpFile();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Check is source file conversion complete
|
|
213
|
+
* @param filename - source filename
|
|
214
|
+
* @returns true if source file conversion complete
|
|
215
|
+
*/
|
|
216
|
+
isFileConversionComplete(filename) {
|
|
217
|
+
let result = true;
|
|
218
|
+
for (const node of this.tilesConverted[filename]?.nodes || []) {
|
|
219
|
+
if (!node.done) {
|
|
220
|
+
result = false;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return result && this.tilesConverted[filename]?.nodes?.length > 0;
|
|
193
225
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (!node.done) {
|
|
201
|
-
result = false;
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
226
|
+
/**
|
|
227
|
+
* Set materialDefinitions into a dump
|
|
228
|
+
* @param materialDefinitions - Array materialDefinitions
|
|
229
|
+
*/
|
|
230
|
+
setMaterialsDefinitions(materialDefinitions) {
|
|
231
|
+
this.materialDefinitions = materialDefinitions;
|
|
204
232
|
}
|
|
205
|
-
return result && ((_this$tilesConverted$4 = this.tilesConverted[filename]) === null || _this$tilesConverted$4 === void 0 ? void 0 : (_this$tilesConverted$5 = _this$tilesConverted$4.nodes) === null || _this$tilesConverted$5 === void 0 ? void 0 : _this$tilesConverted$5.length) > 0;
|
|
206
|
-
}
|
|
207
|
-
setMaterialsDefinitions(materialDefinitions) {
|
|
208
|
-
this.materialDefinitions = materialDefinitions;
|
|
209
|
-
}
|
|
210
233
|
}
|
|
211
|
-
//# sourceMappingURL=conversion-dump.js.map
|