@loaders.gl/tile-converter 4.2.0-alpha.4 → 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.
Files changed (144) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +3 -3
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +329 -293
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +257 -200
  5. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
  6. package/dist/3d-tiles-converter/helpers/load-i3s.js +106 -75
  7. package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
  8. package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
  9. package/dist/constants.js +0 -1
  10. package/dist/converter-cli.js +255 -234
  11. package/dist/converter.min.cjs +80 -90
  12. package/dist/deps-installer/deps-installer.js +72 -58
  13. package/dist/i3s-converter/helpers/attribute-metadata-info.js +207 -153
  14. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  15. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  16. package/dist/i3s-converter/helpers/batch-ids-extensions.js +145 -103
  17. package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
  18. package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
  19. package/dist/i3s-converter/helpers/feature-attributes.js +168 -105
  20. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
  21. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  22. package/dist/i3s-converter/helpers/geometry-attributes.js +204 -212
  23. package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
  24. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  25. package/dist/i3s-converter/helpers/geometry-converter.js +1148 -829
  26. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  27. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  28. package/dist/i3s-converter/helpers/gltf-attributes.js +111 -97
  29. package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
  30. package/dist/i3s-converter/helpers/node-debug.js +98 -54
  31. package/dist/i3s-converter/helpers/node-index-document.d.ts +3 -3
  32. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  33. package/dist/i3s-converter/helpers/node-index-document.js +248 -177
  34. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  35. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  36. package/dist/i3s-converter/helpers/node-pages.js +299 -194
  37. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
  38. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  39. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
  40. package/dist/i3s-converter/helpers/progress.js +134 -83
  41. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +1 -1
  42. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  43. package/dist/i3s-converter/helpers/tileset-traversal.js +24 -13
  44. package/dist/i3s-converter/i3s-converter.d.ts +7 -7
  45. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  46. package/dist/i3s-converter/i3s-converter.js +1044 -898
  47. package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
  48. package/dist/i3s-converter/json-templates/layers.js +120 -121
  49. package/dist/i3s-converter/json-templates/metadata.js +19 -20
  50. package/dist/i3s-converter/json-templates/node.js +73 -71
  51. package/dist/i3s-converter/json-templates/scene-server.js +25 -26
  52. package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
  53. package/dist/i3s-converter/json-templates/store.js +96 -94
  54. package/dist/i3s-converter/types.js +35 -23
  55. package/dist/i3s-server/app.js +15 -12
  56. package/dist/i3s-server/bin/www.js +14 -7
  57. package/dist/i3s-server/controllers/index-controller.js +18 -15
  58. package/dist/i3s-server/controllers/slpk-controller.js +22 -11
  59. package/dist/i3s-server/routes/index.js +9 -8
  60. package/dist/i3s-server/routes/slpk-router.js +18 -17
  61. package/dist/i3s-server/utils/create-scene-server.js +15 -10
  62. package/dist/i3s-server/utils/server-utils.js +49 -32
  63. package/dist/index.cjs +292 -851
  64. package/dist/index.cjs.map +7 -0
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +0 -1
  68. package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
  69. package/dist/lib/utils/cli-utils.js +63 -36
  70. package/dist/lib/utils/compress-util.js +20 -15
  71. package/dist/lib/utils/conversion-dump.d.ts +1 -1
  72. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  73. package/dist/lib/utils/conversion-dump.js +209 -187
  74. package/dist/lib/utils/file-utils.js +122 -74
  75. package/dist/lib/utils/geometry-utils.js +13 -7
  76. package/dist/lib/utils/lod-conversion-utils.js +65 -33
  77. package/dist/lib/utils/queue.js +12 -13
  78. package/dist/lib/utils/statistic-utills.d.ts +6 -23
  79. package/dist/lib/utils/statistic-utills.js +64 -59
  80. package/dist/lib/utils/write-queue.d.ts +2 -2
  81. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  82. package/dist/lib/utils/write-queue.js +68 -86
  83. package/dist/pgm-loader.js +16 -12
  84. package/dist/slpk-extractor/slpk-extractor.js +59 -50
  85. package/dist/slpk-extractor-cli.js +82 -59
  86. package/package.json +18 -18
  87. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  88. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  89. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  90. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  91. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  92. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  93. package/dist/constants.js.map +0 -1
  94. package/dist/converter-cli.js.map +0 -1
  95. package/dist/deps-installer/deps-installer.js.map +0 -1
  96. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
  97. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  98. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  99. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  100. package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
  101. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  102. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  103. package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  104. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  105. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  106. package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
  107. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  108. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  109. package/dist/i3s-converter/helpers/progress.js.map +0 -1
  110. package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  111. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  112. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  113. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  114. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  115. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  116. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  117. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  118. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  119. package/dist/i3s-converter/types.js.map +0 -1
  120. package/dist/i3s-server/README.md +0 -63
  121. package/dist/i3s-server/app.js.map +0 -1
  122. package/dist/i3s-server/bin/www.js.map +0 -1
  123. package/dist/i3s-server/certs/cert.pem +0 -19
  124. package/dist/i3s-server/certs/key.pem +0 -27
  125. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  126. package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
  127. package/dist/i3s-server/routes/index.js.map +0 -1
  128. package/dist/i3s-server/routes/slpk-router.js.map +0 -1
  129. package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
  130. package/dist/i3s-server/utils/server-utils.js.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
  133. package/dist/lib/utils/cli-utils.js.map +0 -1
  134. package/dist/lib/utils/compress-util.js.map +0 -1
  135. package/dist/lib/utils/conversion-dump.js.map +0 -1
  136. package/dist/lib/utils/file-utils.js.map +0 -1
  137. package/dist/lib/utils/geometry-utils.js.map +0 -1
  138. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  139. package/dist/lib/utils/queue.js.map +0 -1
  140. package/dist/lib/utils/statistic-utills.js.map +0 -1
  141. package/dist/lib/utils/write-queue.js.map +0 -1
  142. package/dist/pgm-loader.js.map +0 -1
  143. package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
  144. 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
- if (index + 1 >= args.length) {
3
- return '';
4
- }
5
- const value = args[index + 1];
6
- if (value.indexOf('--') === 0) {
7
- return '';
8
- }
9
- return value;
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
- const value = getStringValue(index, args);
13
- console.log(`Input tileset value: ${value}`);
14
- console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
15
- return value.replace(/\\/g, '/');
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
- return args.reduce((acc, curr) => {
19
- const equalSignIndex = curr.indexOf('=');
20
- const beforeEqual = curr.slice(0, equalSignIndex);
21
- const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
22
- const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
23
- if (condition) {
24
- return acc.concat(beforeEqual, afterEqual);
25
- }
26
- return acc.concat(curr);
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
- const stringValue = getStringValue(index, args);
31
- const result = Number.parseInt(stringValue);
32
- if (isFinite(result)) {
33
- return result;
34
- }
35
- return NaN;
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
- const stringValue = getStringValue(index, args).toLowerCase().trim();
39
- if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
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
- const compressedPathFile = `${pathFile}.gz`;
5
- const gzip = createGzip();
6
- const input = createReadStream(pathFile);
7
- const output = createWriteStream(compressedPathFile);
8
- return new Promise((resolve, reject) => {
9
- input.on('end', () => {
10
- console.log(`${compressedPathFile} compressed and saved.`);
11
- resolve(compressedPathFile);
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 '../../i3s-converter/helpers/attribute-metadata-info';
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,MAAM,qDAAqD,CAAC;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,CAAC;CAClB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,eAA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mBAAmB,EAAE,qBAAqB,EAAE,GAAG,IAAI;CAG5E"}
@@ -6,206 +6,228 @@ import process from 'process';
6
6
  import Ajv from 'ajv';
7
7
  import { dumpJsonSchema } from "../json-schemas/conversion-dump-json-schema.js";
8
8
  export class ConversionDump {
9
- constructor() {
10
- this.restored = false;
11
- this.options = void 0;
12
- this.tilesConverted = void 0;
13
- this.textureSetDefinitions = void 0;
14
- this.attributeMetadataInfo = void 0;
15
- this.materialDefinitions = void 0;
16
- this.tilesConverted = {};
17
- }
18
- async createDump(currentOptions) {
19
- const {
20
- tilesetName,
21
- slpk,
22
- egmFilePath,
23
- inputUrl,
24
- outputPath,
25
- draco = true,
26
- maxDepth,
27
- token,
28
- generateTextures,
29
- generateBoundingVolumes,
30
- mergeMaterials = true,
31
- metadataClass,
32
- analyze = false
33
- } = currentOptions;
34
- this.options = {
35
- tilesetName,
36
- slpk,
37
- egmFilePath,
38
- inputUrl,
39
- outputPath,
40
- draco,
41
- maxDepth,
42
- token,
43
- generateTextures,
44
- generateBoundingVolumes,
45
- mergeMaterials,
46
- metadataClass,
47
- analyze
48
- };
49
- const dumpFilename = join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
50
- if (await isFileExists(dumpFilename)) {
51
- try {
52
- const dump = await openJson(join(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
53
- const {
54
- options,
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
- } catch (error) {
72
- console.log("Can't open dump file", error);
73
- }
56
+ await this.deleteDumpFile();
74
57
  }
75
- await this.deleteDumpFile();
76
- }
77
- reset() {
78
- this.restored = false;
79
- this.tilesConverted = {};
80
- if (this.textureSetDefinitions) {
81
- delete this.textureSetDefinitions;
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
- if (this.attributeMetadataInfo) {
84
- delete this.attributeMetadataInfo;
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
- if (this.materialDefinitions) {
87
- delete this.materialDefinitions;
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
- async updateDumpFile() {
91
- var _this$options;
92
- if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.outputPath && this.options.tilesetName) {
93
- try {
94
- const time = process.hrtime();
95
- await writeFile(join(this.options.outputPath, this.options.tilesetName), JSON.stringify({
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
- async deleteDumpFile() {
109
- var _this$options2;
110
- if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.outputPath && this.options.tilesetName && (await isFileExists(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)))) {
111
- await removeFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
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
- getRecord(fileName) {
115
- return this.tilesConverted[fileName];
116
- }
117
- setRecord(fileName, object) {
118
- this.tilesConverted[fileName] = object;
119
- }
120
- async addNode(filename, nodeId, dumpMetadata) {
121
- const {
122
- nodes
123
- } = this.getRecord(filename) || {
124
- nodes: []
125
- };
126
- nodes.push({
127
- nodeId,
128
- done: false,
129
- dumpMetadata
130
- });
131
- if (nodes.length === 1) {
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
- await this.updateDumpFile();
137
- }
138
- clearDumpRecord(filename) {
139
- this.setRecord(filename, {
140
- nodes: []
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
- async updateConvertedTilesDump(changedRecords, writeResults) {
160
- for (let i = 0; i < changedRecords.length; i++) {
161
- if (changedRecords[i] && 'value' in writeResults[i]) {
162
- const {
163
- sourceId,
164
- resourceType,
165
- outputId
166
- } = changedRecords[i];
167
- if (!sourceId || !resourceType || !outputId) continue;
168
- for (const node of this.tilesConverted[sourceId].nodes) {
169
- if (node.nodeId === outputId && node.progress) {
170
- node.progress[resourceType] = true;
171
- let done = false;
172
- for (const key in node.progress) {
173
- done = node.progress[key];
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
- node.done = done;
177
- if (node.done) {
178
- delete node.progress;
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
- await this.updateDumpFile();
186
- }
187
- async updateConvertedNodesDumpFile(filename, nodeId, done) {
188
- var _this$tilesConverted$2;
189
- const nodeDump = (_this$tilesConverted$2 = this.tilesConverted[filename]) === null || _this$tilesConverted$2 === void 0 ? void 0 : _this$tilesConverted$2.nodes.find(element => element.nodeId === nodeId);
190
- if (nodeDump) {
191
- nodeDump.done = done;
192
- await this.updateDumpFile();
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
- isFileConversionComplete(filename) {
196
- var _this$tilesConverted$4, _this$tilesConverted$5;
197
- let result = true;
198
- for (const node of ((_this$tilesConverted$3 = this.tilesConverted[filename]) === null || _this$tilesConverted$3 === void 0 ? void 0 : _this$tilesConverted$3.nodes) || []) {
199
- var _this$tilesConverted$3;
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