@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.
Files changed (192) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -4
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +349 -293
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +261 -200
  6. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
  7. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/load-i3s.js +83 -77
  9. package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
  10. package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
  11. package/dist/constants.js +0 -1
  12. package/dist/converter-cli.js +257 -234
  13. package/dist/converter.min.cjs +95 -105
  14. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  15. package/dist/deps-installer/deps-installer.js +78 -59
  16. package/dist/i3s-converter/helpers/attribute-metadata-info.js +210 -153
  17. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  18. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  19. package/dist/i3s-converter/helpers/batch-ids-extensions.js +146 -103
  20. package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
  21. package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
  22. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  23. package/dist/i3s-converter/helpers/feature-attributes.js +170 -105
  24. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
  25. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  26. package/dist/i3s-converter/helpers/geometry-attributes.js +205 -212
  27. package/dist/i3s-converter/helpers/geometry-converter.d.ts +17 -3
  28. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  29. package/dist/i3s-converter/helpers/geometry-converter.js +1189 -830
  30. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  31. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  32. package/dist/i3s-converter/helpers/gltf-attributes.js +109 -97
  33. package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
  34. package/dist/i3s-converter/helpers/node-debug.js +98 -54
  35. package/dist/i3s-converter/helpers/node-index-document.d.ts +11 -4
  36. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  37. package/dist/i3s-converter/helpers/node-index-document.js +255 -177
  38. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  39. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  40. package/dist/i3s-converter/helpers/node-pages.js +299 -193
  41. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
  42. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  43. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
  44. package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
  45. package/dist/i3s-converter/helpers/progress.js +139 -83
  46. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +9 -2
  47. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  48. package/dist/i3s-converter/helpers/tileset-traversal.js +33 -13
  49. package/dist/i3s-converter/i3s-converter.d.ts +7 -7
  50. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  51. package/dist/i3s-converter/i3s-converter.js +1165 -895
  52. package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
  53. package/dist/i3s-converter/json-templates/layers.js +120 -121
  54. package/dist/i3s-converter/json-templates/metadata.js +19 -20
  55. package/dist/i3s-converter/json-templates/node.js +73 -71
  56. package/dist/i3s-converter/json-templates/scene-server.js +25 -26
  57. package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
  58. package/dist/i3s-converter/json-templates/store.js +96 -94
  59. package/dist/i3s-converter/types.js +35 -23
  60. package/dist/i3s-server/app.js +15 -12
  61. package/dist/i3s-server/bin/i3s-server.min.cjs +69 -69
  62. package/dist/i3s-server/bin/www.js +16 -7
  63. package/dist/i3s-server/controllers/index-controller.js +18 -15
  64. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  65. package/dist/i3s-server/controllers/slpk-controller.js +24 -11
  66. package/dist/i3s-server/routes/index.js +13 -9
  67. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  68. package/dist/i3s-server/routes/slpk-router.js +26 -19
  69. package/dist/i3s-server/utils/create-scene-server.js +15 -10
  70. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
  71. package/dist/i3s-server/utils/server-utils.js +52 -32
  72. package/dist/index.cjs +616 -967
  73. package/dist/index.cjs.map +7 -0
  74. package/dist/index.d.ts +2 -2
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +0 -1
  77. package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
  78. package/dist/lib/utils/cli-utils.d.ts.map +1 -1
  79. package/dist/lib/utils/cli-utils.js +65 -36
  80. package/dist/lib/utils/compress-util.js +20 -15
  81. package/dist/lib/utils/conversion-dump.d.ts +10 -2
  82. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  83. package/dist/lib/utils/conversion-dump.js +242 -197
  84. package/dist/lib/utils/file-utils.d.ts +1 -1
  85. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  86. package/dist/lib/utils/file-utils.js +120 -74
  87. package/dist/lib/utils/geometry-utils.js +13 -7
  88. package/dist/lib/utils/lod-conversion-utils.js +65 -33
  89. package/dist/lib/utils/queue.js +12 -13
  90. package/dist/lib/utils/statistic-utills.d.ts +6 -23
  91. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  92. package/dist/lib/utils/statistic-utills.js +58 -55
  93. package/dist/lib/utils/write-queue.d.ts +2 -2
  94. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  95. package/dist/lib/utils/write-queue.js +72 -86
  96. package/dist/pgm-loader.js +17 -13
  97. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
  98. package/dist/slpk-extractor/slpk-extractor.js +60 -50
  99. package/dist/slpk-extractor-cli.d.ts.map +1 -1
  100. package/dist/slpk-extractor-cli.js +90 -59
  101. package/dist/slpk-extractor.min.cjs +1 -1
  102. package/package.json +27 -26
  103. package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
  104. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
  105. package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
  106. package/src/converter-cli.ts +4 -2
  107. package/src/deps-installer/deps-installer.ts +7 -0
  108. package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
  109. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
  110. package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
  111. package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
  112. package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
  113. package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
  114. package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
  115. package/src/i3s-converter/helpers/node-index-document.ts +18 -10
  116. package/src/i3s-converter/helpers/node-pages.ts +27 -29
  117. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
  118. package/src/i3s-converter/helpers/progress.ts +1 -0
  119. package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
  120. package/src/i3s-converter/i3s-converter.ts +173 -114
  121. package/src/i3s-converter/json-templates/node.ts +1 -1
  122. package/src/i3s-server/bin/www.ts +6 -4
  123. package/src/i3s-server/controllers/slpk-controller.ts +4 -2
  124. package/src/i3s-server/routes/index.ts +10 -7
  125. package/src/i3s-server/routes/slpk-router.ts +22 -16
  126. package/src/i3s-server/utils/server-utils.ts +6 -4
  127. package/src/lib/utils/cli-utils.ts +2 -0
  128. package/src/lib/utils/conversion-dump.ts +35 -20
  129. package/src/lib/utils/file-utils.ts +11 -11
  130. package/src/lib/utils/statistic-utills.ts +5 -6
  131. package/src/lib/utils/write-queue.ts +2 -2
  132. package/src/slpk-extractor/slpk-extractor.ts +2 -1
  133. package/src/slpk-extractor-cli.ts +16 -8
  134. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  135. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  136. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  137. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  138. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  139. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  140. package/dist/constants.js.map +0 -1
  141. package/dist/converter-cli.js.map +0 -1
  142. package/dist/deps-installer/deps-installer.js.map +0 -1
  143. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
  144. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  145. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  146. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  147. package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
  148. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  149. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  150. package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  151. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  152. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  153. package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
  154. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  155. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  156. package/dist/i3s-converter/helpers/progress.js.map +0 -1
  157. package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  158. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  159. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  160. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  161. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  162. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  163. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  164. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  165. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  166. package/dist/i3s-converter/types.js.map +0 -1
  167. package/dist/i3s-server/README.md +0 -63
  168. package/dist/i3s-server/app.js.map +0 -1
  169. package/dist/i3s-server/bin/www.js.map +0 -1
  170. package/dist/i3s-server/certs/cert.pem +0 -19
  171. package/dist/i3s-server/certs/key.pem +0 -27
  172. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  173. package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
  174. package/dist/i3s-server/routes/index.js.map +0 -1
  175. package/dist/i3s-server/routes/slpk-router.js.map +0 -1
  176. package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
  177. package/dist/i3s-server/utils/server-utils.js.map +0 -1
  178. package/dist/index.js.map +0 -1
  179. package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
  180. package/dist/lib/utils/cli-utils.js.map +0 -1
  181. package/dist/lib/utils/compress-util.js.map +0 -1
  182. package/dist/lib/utils/conversion-dump.js.map +0 -1
  183. package/dist/lib/utils/file-utils.js.map +0 -1
  184. package/dist/lib/utils/geometry-utils.js.map +0 -1
  185. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  186. package/dist/lib/utils/queue.js.map +0 -1
  187. package/dist/lib/utils/statistic-utills.js.map +0 -1
  188. package/dist/lib/utils/write-queue.js.map +0 -1
  189. package/dist/pgm-loader.js.map +0 -1
  190. package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
  191. package/dist/slpk-extractor-cli.js.map +0 -1
  192. package/src/lib/utils/statistic-utills.d.ts +0 -25
@@ -1 +1 @@
1
- {"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/cli-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CASpE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAKjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOrE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAStE"}
1
+ {"version":3,"file":"cli-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/cli-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CASpE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOjE;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAWjE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOrE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAStE"}
@@ -1,47 +1,76 @@
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
+ // eslint-disable-next-line no-console
28
+ console.log(`Input tileset value: ${value}`);
29
+ // eslint-disable-next-line no-console
30
+ console.log(`Modified tileset value: ${value.replace(/\\/g, '/')}`);
31
+ return value.replace(/\\/g, '/');
16
32
  }
17
33
  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
- }, []);
34
+ return args.reduce((acc, curr) => {
35
+ const equalSignIndex = curr.indexOf('=');
36
+ const beforeEqual = curr.slice(0, equalSignIndex);
37
+ const afterEqual = curr.slice(equalSignIndex + 1, curr.length);
38
+ const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;
39
+ if (condition) {
40
+ return acc.concat(beforeEqual, afterEqual);
41
+ }
42
+ return acc.concat(curr);
43
+ }, []);
28
44
  }
45
+ /**
46
+ * Get integer option value from cli arguments
47
+ * @param index - option's name index in the argument's array
48
+ * The value of the option should be next to name of the option.
49
+ * @param args - cli arguments array
50
+ * @returns - number value of the option
51
+ */
29
52
  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;
53
+ const stringValue = getStringValue(index, args);
54
+ const result = Number.parseInt(stringValue);
55
+ if (isFinite(result)) {
56
+ return result;
57
+ }
58
+ return NaN;
36
59
  }
60
+ /**
61
+ * Get boolean option value from cli arguments
62
+ * @param index - option's name index in the argument's array
63
+ * The value of the option should be next to name of the option.
64
+ * @param args - cli arguments array
65
+ * @returns - boolean value of the option
66
+ */
37
67
  export function getBooleanValue(index, args) {
38
- const stringValue = getStringValue(index, args).toLowerCase().trim();
39
- if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
68
+ const stringValue = getStringValue(index, args).toLowerCase().trim();
69
+ if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {
70
+ return false;
71
+ }
72
+ if (!stringValue || stringValue === 'true') {
73
+ return true;
74
+ }
40
75
  return false;
41
- }
42
- if (!stringValue || stringValue === 'true') {
43
- return true;
44
- }
45
- return false;
46
76
  }
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;
@@ -39,7 +39,7 @@ export type TextureSetDefinition = {
39
39
  atlas?: boolean;
40
40
  };
41
41
  export declare class ConversionDump {
42
- /**Restored/resumed dump indicator */
42
+ /** Restored/resumed dump indicator */
43
43
  restored: boolean;
44
44
  /** Conversion options */
45
45
  private options?;
@@ -115,6 +115,14 @@ export declare class ConversionDump {
115
115
  sourceId?: string;
116
116
  resourceType?: string;
117
117
  }[], writeResults: PromiseSettledResult<string | null>[]): Promise<void>;
118
+ /**
119
+ * Update done status for a node
120
+ * @param sourceId - source resource Id
121
+ * @param outputId - output node/tile Id
122
+ * @param resourceType - type of resource
123
+ * @returns void
124
+ */
125
+ private updateNodes;
118
126
  /**
119
127
  * Update 3d-tiles-converter dump file
120
128
  * @param filename - source filename
@@ -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,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,OAA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,251 @@ 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
+ /** Restored/resumed dump indicator */
10
+ restored = false;
11
+ /** Conversion options */
12
+ options;
13
+ /** Tiles conversion progress status map */
14
+ tilesConverted;
15
+ /** Textures formats definitions */
16
+ textureSetDefinitions;
17
+ /** Attributes Metadata */
18
+ attributeMetadataInfo;
19
+ /** Array of materials definitions */
20
+ materialDefinitions;
21
+ constructor() {
22
+ this.tilesConverted = {};
23
+ }
24
+ /**
25
+ * Create a dump with convertion options
26
+ * @param currentOptions - converter options
27
+ */
28
+ async createDump(currentOptions) {
29
+ const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials = true, metadataClass, analyze = false } = currentOptions;
30
+ this.options = {
31
+ tilesetName,
32
+ slpk,
33
+ egmFilePath,
34
+ inputUrl,
35
+ outputPath,
36
+ draco,
37
+ maxDepth,
38
+ token,
39
+ generateTextures,
40
+ generateBoundingVolumes,
41
+ mergeMaterials,
42
+ metadataClass,
43
+ analyze
44
+ };
45
+ const dumpFilename = join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
46
+ if (await isFileExists(dumpFilename)) {
47
+ try {
48
+ const dump = await openJson(join(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
49
+ const { options, tilesConverted, textureSetDefinitions, attributeMetadataInfo, materialDefinitions } = dump;
50
+ const ajv = new Ajv();
51
+ const dumpJsonValidate = ajv.compile(dumpJsonSchema);
52
+ const isDumpValid = dumpJsonValidate(dump);
53
+ if (isDumpValid && isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {
54
+ this.tilesConverted = tilesConverted;
55
+ this.textureSetDefinitions = textureSetDefinitions;
56
+ this.attributeMetadataInfo = attributeMetadataInfo;
57
+ this.materialDefinitions = materialDefinitions;
58
+ this.restored = true;
59
+ return;
60
+ }
61
+ }
62
+ catch (error) {
63
+ // prettier-ignore
64
+ console.log('Can\'t open dump file', error); // eslint-disable-line no-console
65
+ }
66
+ }
67
+ await this.deleteDumpFile();
68
+ }
69
+ /**
70
+ * Reset a dump
71
+ */
72
+ reset() {
73
+ this.restored = false;
74
+ this.tilesConverted = {};
75
+ if (this.textureSetDefinitions) {
76
+ delete this.textureSetDefinitions;
77
+ }
78
+ if (this.attributeMetadataInfo) {
79
+ delete this.attributeMetadataInfo;
80
+ }
81
+ if (this.materialDefinitions) {
82
+ delete this.materialDefinitions;
83
+ }
84
+ }
85
+ /**
86
+ * Update conversion status in the dump file
87
+ */
88
+ async updateDumpFile() {
89
+ if (this.options?.outputPath && this.options.tilesetName) {
90
+ try {
91
+ const time = process.hrtime();
92
+ await writeFile(join(this.options.outputPath, this.options.tilesetName), JSON.stringify({
93
+ options: this.options,
94
+ tilesConverted: this.tilesConverted,
95
+ textureSetDefinitions: this.textureSetDefinitions,
96
+ attributeMetadataInfo: this.attributeMetadataInfo,
97
+ materialDefinitions: this.materialDefinitions
98
+ }), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`);
99
+ 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}`));
100
+ }
101
+ catch (error) {
102
+ // prettier-ignore
103
+ console.log('Can\'t update dump file', error); // eslint-disable-line no-console
104
+ }
105
+ }
106
+ }
107
+ /**
108
+ * Delete a dump file
109
+ */
110
+ async deleteDumpFile() {
111
+ if (this.options?.outputPath &&
112
+ this.options.tilesetName &&
113
+ (await isFileExists(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)))) {
114
+ await removeFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
115
+ }
116
+ }
117
+ /**
118
+ * Get record from the tilesConverted Map
119
+ * @param fileName - source filename
120
+ * @returns existing object from the tilesConverted Map
121
+ */
122
+ getRecord(fileName) {
123
+ return this.tilesConverted[fileName];
124
+ }
125
+ /**
126
+ * Set a record for the dump file
127
+ * @param fileName - key - source filename
128
+ * @param object - value
129
+ */
130
+ setRecord(fileName, object) {
131
+ this.tilesConverted[fileName] = object;
132
+ }
133
+ /**
134
+ * Add a node into the dump file for the source file record
135
+ * @param fileName - source filename
136
+ * @param nodeId - nodeId of the node
137
+ */
138
+ async addNode(filename, nodeId, dumpMetadata) {
139
+ const { nodes } = this.getRecord(filename) || { nodes: [] };
140
+ nodes.push({ nodeId, done: false, dumpMetadata });
141
+ if (nodes.length === 1) {
142
+ this.setRecord(filename, { nodes });
143
+ }
144
+ await this.updateDumpFile();
145
+ }
146
+ /**
147
+ * Clear dump record got the source filename
148
+ * @param fileName - source filename
149
+ */
150
+ clearDumpRecord(filename) {
151
+ this.setRecord(filename, { nodes: [] });
152
+ }
153
+ /**
154
+ * Add textures definitions into the dump file
155
+ * @param textureDefinitions - textures definitions array
156
+ */
157
+ addTexturesDefinitions(textureDefinitions) {
158
+ this.textureSetDefinitions = textureDefinitions;
159
+ }
160
+ /**
161
+ * Update done status object for the writing resources
162
+ * @param fileName - key - source filename
163
+ * @param nodeId - nodeId for the source filename
164
+ * @param resourceType - resource type to update status
165
+ * @param value - value
166
+ */
167
+ updateDoneStatus(filename, nodeId, resourceType, value) {
168
+ const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
169
+ if (nodeDump) {
170
+ if (!nodeDump.progress) {
171
+ nodeDump.progress = {};
172
+ }
173
+ nodeDump.progress[resourceType] = value;
174
+ if (!value) {
175
+ nodeDump.done = false;
176
+ }
177
+ }
178
+ }
179
+ /**
180
+ * Update dump file according to writing results
181
+ * @param changedRecords - array of parameters ids for the written resources
182
+ * @param writeResults - array of writing resource files results
183
+ */
184
+ async updateConvertedTilesDump(changedRecords, writeResults) {
185
+ for (let i = 0; i < changedRecords.length; i++) {
186
+ if (changedRecords[i] && 'value' in writeResults[i]) {
187
+ const { sourceId, resourceType, outputId } = changedRecords[i];
188
+ this.updateNodes(sourceId, outputId, resourceType);
189
+ }
190
+ }
191
+ await this.updateDumpFile();
192
+ }
193
+ /**
194
+ * Update done status for a node
195
+ * @param sourceId - source resource Id
196
+ * @param outputId - output node/tile Id
197
+ * @param resourceType - type of resource
198
+ * @returns void
199
+ */
200
+ updateNodes(sourceId, outputId, resourceType) {
201
+ if (!sourceId || !resourceType || !outputId) {
202
+ return;
70
203
  }
71
- } catch (error) {
72
- console.log("Can't open dump file", error);
73
- }
74
- }
75
- await this.deleteDumpFile();
76
- }
77
- reset() {
78
- this.restored = false;
79
- this.tilesConverted = {};
80
- if (this.textureSetDefinitions) {
81
- delete this.textureSetDefinitions;
82
- }
83
- if (this.attributeMetadataInfo) {
84
- delete this.attributeMetadataInfo;
85
- }
86
- if (this.materialDefinitions) {
87
- delete this.materialDefinitions;
88
- }
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
- }
106
- }
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}`));
112
- }
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
- });
135
- }
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
- }
157
- }
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
204
  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;
205
+ if (node.nodeId === outputId && node.progress) {
206
+ node.progress[resourceType] = true;
207
+ let done = false;
208
+ for (const key in node.progress) {
209
+ done = node.progress[key];
210
+ if (!done)
211
+ break;
212
+ }
213
+ node.done = done;
214
+ if (node.done) {
215
+ delete node.progress;
216
+ }
217
+ break;
175
218
  }
176
- node.done = done;
177
- if (node.done) {
178
- delete node.progress;
219
+ }
220
+ }
221
+ /**
222
+ * Update 3d-tiles-converter dump file
223
+ * @param filename - source filename
224
+ * @param nodeId - nodeId
225
+ * @param done - conversion status
226
+ */
227
+ async updateConvertedNodesDumpFile(filename, nodeId, done) {
228
+ const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
229
+ if (nodeDump) {
230
+ nodeDump.done = done;
231
+ await this.updateDumpFile();
232
+ }
233
+ }
234
+ /**
235
+ * Check is source file conversion complete
236
+ * @param filename - source filename
237
+ * @returns true if source file conversion complete
238
+ */
239
+ isFileConversionComplete(filename) {
240
+ let result = true;
241
+ for (const node of this.tilesConverted[filename]?.nodes || []) {
242
+ if (!node.done) {
243
+ result = false;
244
+ break;
179
245
  }
180
- break;
181
- }
182
246
  }
183
- }
184
- }
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();
193
- }
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
- }
204
- }
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
- }
247
+ return result && this.tilesConverted[filename]?.nodes?.length > 0;
248
+ }
249
+ /**
250
+ * Set materialDefinitions into a dump
251
+ * @param materialDefinitions - Array materialDefinitions
252
+ */
253
+ setMaterialsDefinitions(materialDefinitions) {
254
+ this.materialDefinitions = materialDefinitions;
255
+ }
210
256
  }
211
- //# sourceMappingURL=conversion-dump.js.map
@@ -36,7 +36,7 @@ export declare function isFileExists(fileName: string): Promise<boolean>;
36
36
  *
37
37
  * @param path
38
38
  */
39
- export declare function removeDir(path: string): Promise<void>;
39
+ export declare function removeDir(path: string): any;
40
40
  /**
41
41
  * Remove file with path
42
42
  *