@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":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,EAC/B,QAAQ,GAAE,OAAc,EACxB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAC,CAoB5F;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,iBAGrC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAEtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAEnD;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAA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oader } from '@loaders.gl/loader-utils';
3
3
  import { promises as fs } from 'fs';
4
4
  import { isAbsolute, join } from 'path';
5
5
  import { compressFileWithGzip } from "./compress-util.js";
6
- export async function writeFile(path, data) {
7
- let fileName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.json';
8
- let toWriteData;
9
- if (data instanceof Promise) {
10
- toWriteData = new Uint8Array(await data);
11
- } else if (data instanceof ArrayBuffer) {
12
- toWriteData = new Uint8Array(data);
13
- } else {
14
- toWriteData = data;
15
- }
16
- await fs.mkdir(path, {
17
- recursive: true
18
- });
19
- const pathFile = join(path, fileName);
20
- try {
21
- await fs.writeFile(pathFile, toWriteData);
22
- } catch (err) {
23
- throw err;
24
- }
25
- console.log(`${pathFile} saved.`);
26
- return pathFile;
6
+ /**
7
+ * Write a file with data and name fileName to path
8
+ *
9
+ * @param path - output path
10
+ * @param data - file content
11
+ * @param fileName - name of output file (default: index.json)
12
+ */
13
+ export async function writeFile(path, data, fileName = 'index.json') {
14
+ let toWriteData;
15
+ if (data instanceof Promise) {
16
+ toWriteData = new Uint8Array(await data);
17
+ }
18
+ else if (data instanceof ArrayBuffer) {
19
+ toWriteData = new Uint8Array(data);
20
+ }
21
+ else {
22
+ toWriteData = data;
23
+ }
24
+ await fs.mkdir(path, { recursive: true });
25
+ const pathFile = join(path, fileName);
26
+ try {
27
+ await fs.writeFile(pathFile, toWriteData);
28
+ }
29
+ catch (err) {
30
+ throw err;
31
+ }
32
+ console.log(`${pathFile} saved.`); // eslint-disable-line no-console
33
+ return pathFile;
27
34
  }
28
- export async function writeFileForSlpk(path, data) {
29
- let fileName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.json';
30
- let compress = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
31
- let compressList = arguments.length > 4 ? arguments[4] : undefined;
32
- const pathFile = await writeFile(path, data, fileName);
33
- if (compress) {
34
- if (compressList) {
35
- if (!compressList.includes(pathFile)) {
36
- compressList.push(pathFile);
37
- return `${pathFile}.gz`;
38
- } else {
39
- return null;
40
- }
41
- } else {
42
- const pathGzFile = await compressFileWithGzip(pathFile);
43
- await removeFile(pathFile);
44
- return pathGzFile;
35
+ /**
36
+ * Write a file with data and name fileName to path - specific one for further packaging into slpk
37
+ *
38
+ * @param path - output path
39
+ * @param data - file content
40
+ * @param fileName - name of output file (default: index.json)
41
+ * @param compress - if need to compress file with gzip (default: true)
42
+ * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
43
+ */
44
+ export async function writeFileForSlpk(path, data, fileName = 'index.json', compress = true, compressList) {
45
+ const pathFile = await writeFile(path, data, fileName);
46
+ if (compress) {
47
+ if (compressList) {
48
+ if (!compressList.includes(pathFile)) {
49
+ compressList.push(pathFile);
50
+ return `${pathFile}.gz`;
51
+ }
52
+ return null;
53
+ }
54
+ const pathGzFile = await compressFileWithGzip(pathFile);
55
+ // After compression, we don't need an uncompressed file
56
+ await removeFile(pathFile);
57
+ return pathGzFile;
45
58
  }
46
- }
47
- return pathFile;
59
+ return pathFile;
48
60
  }
61
+ /**
62
+ * Open json file
63
+ * @param path - path to the file
64
+ * @param fileName - file name
65
+ * @returns object
66
+ */
49
67
  export async function openJson(path, fileName) {
50
- return new Promise((resolve, reject) => {
51
- let count = 0;
52
- console.log(`load ${path}/${fileName}.`);
53
- const intervalId = setInterval(() => {
54
- const pathFile = join(path, fileName);
55
- load(pathFile, JSONLoader).then(result => {
56
- clearInterval(intervalId);
57
- resolve(result);
58
- }).catch(() => {
59
- count++;
60
- if (count > 100) {
61
- clearInterval(intervalId);
62
- reject(new Error(`Cannon load ${path}/${fileName}.`));
63
- }
64
- });
65
- }, 200);
66
- });
68
+ return new Promise((resolve, reject) => {
69
+ let count = 0;
70
+ console.log(`load ${path}/${fileName}.`); // eslint-disable-line no-console
71
+ const intervalId = setInterval(() => {
72
+ const pathFile = join(path, fileName);
73
+ load(pathFile, JSONLoader)
74
+ .then((result) => {
75
+ clearInterval(intervalId);
76
+ resolve(result);
77
+ })
78
+ .catch(() => {
79
+ count++;
80
+ if (count > 100) {
81
+ clearInterval(intervalId);
82
+ reject(new Error(`Cannon load ${path}/${fileName}.`));
83
+ }
84
+ });
85
+ }, 200);
86
+ });
67
87
  }
88
+ /**
89
+ * Check if the file exists
90
+ * @param fileName - full name of file
91
+ * @returns true if file exists, otherwise - false
92
+ */
68
93
  export async function isFileExists(fileName) {
69
- try {
70
- await fs.stat(fileName);
71
- return true;
72
- } catch {
73
- return false;
74
- }
94
+ try {
95
+ await fs.stat(fileName);
96
+ return true;
97
+ }
98
+ catch {
99
+ return false;
100
+ }
75
101
  }
102
+ /**
103
+ * Remove dir with path
104
+ *
105
+ * @param path
106
+ */
76
107
  export function removeDir(path) {
77
- return fs.rm(path, {
78
- recursive: true
79
- });
108
+ // (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
109
+ // @ts-ignore
110
+ return fs.rm(path, { recursive: true });
80
111
  }
112
+ /**
113
+ * Remove file with path
114
+ *
115
+ * @param path
116
+ */
81
117
  export function removeFile(path) {
82
- return fs.unlink(path);
118
+ return fs.unlink(path);
83
119
  }
120
+ /**
121
+ * Generates absolute file path
122
+ * @param filePath
123
+ */
84
124
  export function getAbsoluteFilePath(filePath) {
85
- return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
125
+ return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
86
126
  }
127
+ /**
128
+ * Rename file with old path by new path
129
+ * @param oldPath
130
+ * @param newPath
131
+ */
87
132
  export async function renameFile(oldPath, newPath) {
88
- try {
89
- await fs.rename(oldPath, newPath);
90
- } catch (err) {
91
- console.log("Can't rename file", err);
92
- }
133
+ try {
134
+ await fs.rename(oldPath, newPath);
135
+ }
136
+ catch (err) {
137
+ // prettier-ignore
138
+ console.log('Can\'t rename file', err); // eslint-disable-line no-console
139
+ }
93
140
  }
94
- //# sourceMappingURL=file-utils.js.map
@@ -1,8 +1,14 @@
1
- export const generateSyntheticIndices = vertexCount => {
2
- const result = new Uint32Array(vertexCount);
3
- for (let index = 0; index < vertexCount; index++) {
4
- result[index] = index;
5
- }
6
- return result;
1
+ /**
2
+ * luma.gl can not work without indices now:
3
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
4
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
5
+ * @param {number} vertexCount - vertex count in the geometry
6
+ * @returns {Uint32Array} indices array.
7
+ */
8
+ export const generateSyntheticIndices = (vertexCount) => {
9
+ const result = new Uint32Array(vertexCount);
10
+ for (let index = 0; index < vertexCount; index++) {
11
+ result[index] = index;
12
+ }
13
+ return result;
7
14
  };
8
- //# sourceMappingURL=geometry-utils.js.map
@@ -1,39 +1,71 @@
1
+ // https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html
1
2
  const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
3
+ /**
4
+ * Do conversion from geometric error to screen threshold
5
+ *
6
+ * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.
7
+ * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.
8
+ * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles
9
+ * 3DTiles spec:
10
+ * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error
11
+ * I3S spec:
12
+ * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md
13
+ * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us
14
+ * to make child maxError bigger than his parent maxError.
15
+ *
16
+ * @param tile - 3d-tiles tile JSON
17
+ * @param coordinates - node converted coordinates
18
+ * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection
19
+ * @example
20
+ * [
21
+ {
22
+ "metricType": "maxScreenThresholdSQ",
23
+ "maxError": 870638.071285568
24
+ },
25
+ {
26
+ "metricType": "maxScreenThreshold",
27
+ "maxError": 1052.8679031638949
28
+ }
29
+ ]
30
+ */
2
31
  export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
3
- const lodSelection = [];
4
- const boundingVolume = tile.boundingVolume;
5
- const lodMetricValue = tile.lodMetricValue || 0.1;
6
- const maxScreenThreshold = {
7
- metricType: 'maxScreenThreshold',
8
- maxError: coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / lodMetricValue
9
- };
10
- const maxScreenThresholdSQ = {
11
- metricType: 'maxScreenThresholdSQ',
12
- maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError
13
- };
14
- if (boundingVolume.constructor.name === 'OrientedBoundingBox') {
15
- lodSelection.push(maxScreenThresholdSQ);
16
- lodSelection.push(maxScreenThreshold);
17
- } else {
18
- lodSelection.push(maxScreenThreshold);
19
- lodSelection.push(maxScreenThresholdSQ);
20
- }
21
- return lodSelection;
32
+ const lodSelection = [];
33
+ const boundingVolume = tile.boundingVolume;
34
+ const lodMetricValue = tile.lodMetricValue || 0.1;
35
+ const maxScreenThreshold = {
36
+ metricType: 'maxScreenThreshold',
37
+ maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue
38
+ };
39
+ const maxScreenThresholdSQ = {
40
+ metricType: 'maxScreenThresholdSQ',
41
+ maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError
42
+ };
43
+ if (boundingVolume.constructor.name === 'OrientedBoundingBox') {
44
+ lodSelection.push(maxScreenThresholdSQ);
45
+ lodSelection.push(maxScreenThreshold);
46
+ }
47
+ else {
48
+ lodSelection.push(maxScreenThreshold);
49
+ lodSelection.push(maxScreenThresholdSQ);
50
+ }
51
+ return lodSelection;
22
52
  }
53
+ /**
54
+ * Convert LOD metric from "Screen Threshold" to "Screen Space Error"
55
+ * @param node - i3s node data
56
+ * @returns lod metric in 3d-tiles format
57
+ */
23
58
  export function convertScreenThresholdToGeometricError(node) {
24
- var _node$lodSelection;
25
- const metricData = (_node$lodSelection = node.lodSelection) === null || _node$lodSelection === void 0 ? void 0 : _node$lodSelection.find(metric => metric.metricType === 'maxScreenThreshold');
26
- let maxError = metricData === null || metricData === void 0 ? void 0 : metricData.maxError;
27
- if (!maxError) {
28
- var _node$lodSelection2;
29
- const sqMetricData = (_node$lodSelection2 = node.lodSelection) === null || _node$lodSelection2 === void 0 ? void 0 : _node$lodSelection2.find(metric => metric.metricType === 'maxScreenThresholdSQ');
30
- if (sqMetricData) {
31
- maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
59
+ const metricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThreshold');
60
+ let maxError = metricData?.maxError;
61
+ if (!maxError) {
62
+ const sqMetricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThresholdSQ');
63
+ if (sqMetricData) {
64
+ maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
65
+ }
66
+ }
67
+ if (!maxError) {
68
+ maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
32
69
  }
33
- }
34
- if (!maxError) {
35
- maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
36
- }
37
- return node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / maxError;
70
+ return (node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;
38
71
  }
39
- //# sourceMappingURL=lod-conversion-utils.js.map
@@ -1,15 +1,14 @@
1
1
  export class Queue extends Array {
2
- enqueue(val) {
3
- this.push(val);
4
- }
5
- dequeue() {
6
- return this.shift();
7
- }
8
- peek() {
9
- return this[0];
10
- }
11
- isEmpty() {
12
- return this.length === 0;
13
- }
2
+ enqueue(val) {
3
+ this.push(val);
4
+ }
5
+ dequeue() {
6
+ return this.shift();
7
+ }
8
+ peek() {
9
+ return this[0];
10
+ }
11
+ isEmpty() {
12
+ return this.length === 0;
13
+ }
14
14
  }
15
- //# sourceMappingURL=queue.js.map
@@ -1,25 +1,8 @@
1
1
  /**
2
- * Do milliseconds time conversion to readable time string.
3
- * @param tile - 3d-tiles tile Object
4
- * @param coordinates - node converted coordinates
5
- * @returns String which characterizes conversion time period
2
+ * Converts time value to string.
3
+ * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
4
+ * @returns string representation of the time
6
5
  */
7
- export function timeConverter(time: [number, number]): String;
8
-
9
- /**
10
- * Calculate files sizes after conversion.
11
- * @param params - Object with params of conversion.
12
- * @returns Promise with generated files size in bytes.
13
- */
14
- export function calculateFilesSize(params: {
15
- slpk: boolean;
16
- outputPath: string;
17
- tilesetName: string;
18
- }): Number;
19
-
20
- /**
21
- * Reqursivelly calculate files sizes in directory.
22
- * @param dirPath - Directory path.
23
- * @returns Promise with files size in directory.
24
- */
25
- export function getTotalFilesSize(dirPath: string): Number;
6
+ export declare function timeConverter(time: number | [number, number]): string;
7
+ export declare function calculateFilesSize(params: any): Promise<number | null>;
8
+ //# sourceMappingURL=statistic-utills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAcrE;AA6BD,wBAAsB,kBAAkB,CAAC,MAAM,KAAA,0BAkB9C"}
1
+ {"version":3,"file":"statistic-utills.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utills.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAarE;AA6BD,wBAAsB,kBAAkB,CAAC,MAAM,KAAA,0BAkB9C"}
@@ -1,72 +1,75 @@
1
1
  import { join } from 'path';
2
2
  import { promises as fs } from 'fs';
3
3
  import { getAbsoluteFilePath } from "./file-utils.js";
4
+ /**
5
+ * Converts time value to string.
6
+ * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
7
+ * @returns string representation of the time
8
+ */
4
9
  export function timeConverter(time) {
5
- if (typeof time === 'number') {
6
- const milliSecondsInSecond = 1e3;
7
- const timeInSeconds = Math.floor(time / milliSecondsInSecond);
8
- const milliseconds = time - timeInSeconds * milliSecondsInSecond;
9
- return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
10
- } else {
10
+ if (typeof time === 'number') {
11
+ // time - real time in milli-seconds
12
+ const milliSecondsInSecond = 1e3;
13
+ const timeInSeconds = Math.floor(time / milliSecondsInSecond);
14
+ const milliseconds = time - timeInSeconds * milliSecondsInSecond;
15
+ return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
16
+ }
17
+ // time - high-resolution real time in a [seconds, nanoseconds] tuple Array
11
18
  const nanoSecondsInMillisecond = 1e6;
12
19
  const timeInSeconds = time[0];
13
20
  const milliseconds = time[1] / nanoSecondsInMillisecond;
14
21
  return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
15
- }
16
22
  }
17
23
  function timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds) {
18
- const hours = Math.floor(timeInSeconds / 3600);
19
- timeInSeconds = timeInSeconds - hours * 3600;
20
- const minutes = Math.floor(timeInSeconds / 60);
21
- timeInSeconds = timeInSeconds - minutes * 60;
22
- const seconds = Math.floor(timeInSeconds);
23
- let result = '';
24
- if (hours) {
25
- result += `${hours}h `;
26
- }
27
- if (minutes) {
28
- result += `${minutes}m `;
29
- }
30
- if (seconds) {
31
- result += `${seconds}s`;
32
- }
33
- if (!result) {
34
- result += `${Math.floor(milliseconds)}ms`;
35
- }
36
- return result;
24
+ const hours = Math.floor(timeInSeconds / 3600);
25
+ timeInSeconds = timeInSeconds - hours * 3600;
26
+ const minutes = Math.floor(timeInSeconds / 60);
27
+ timeInSeconds = timeInSeconds - minutes * 60;
28
+ const seconds = Math.floor(timeInSeconds);
29
+ let result = '';
30
+ if (hours) {
31
+ result += `${hours}h `;
32
+ }
33
+ if (minutes) {
34
+ result += `${minutes}m `;
35
+ }
36
+ if (seconds) {
37
+ result += `${seconds}s`;
38
+ }
39
+ if (!result) {
40
+ result += `${Math.floor(milliseconds)}ms`;
41
+ }
42
+ return result;
37
43
  }
38
44
  export async function calculateFilesSize(params) {
39
- const {
40
- slpk,
41
- outputPath,
42
- tilesetName
43
- } = params;
44
- const fullOutputPath = getAbsoluteFilePath(outputPath);
45
- try {
46
- if (slpk) {
47
- const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
48
- const stat = await fs.stat(slpkPath);
49
- return stat.size;
45
+ const { slpk, outputPath, tilesetName } = params;
46
+ const fullOutputPath = getAbsoluteFilePath(outputPath);
47
+ try {
48
+ if (slpk) {
49
+ const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
50
+ const stat = await fs.stat(slpkPath);
51
+ return stat.size;
52
+ }
53
+ const directoryPath = join(fullOutputPath, tilesetName);
54
+ const totalSize = await getTotalFilesSize(directoryPath);
55
+ return totalSize;
56
+ }
57
+ catch (error) {
58
+ console.log('Calculate file sizes error: ', error); // eslint-disable-line
59
+ return null;
50
60
  }
51
- const directoryPath = join(fullOutputPath, tilesetName);
52
- const totalSize = await getTotalFilesSize(directoryPath);
53
- return totalSize;
54
- } catch (error) {
55
- console.log('Calculate file sizes error: ', error);
56
- return null;
57
- }
58
61
  }
59
62
  async function getTotalFilesSize(dirPath) {
60
- let totalFileSize = 0;
61
- const files = await fs.readdir(dirPath);
62
- for (const file of files) {
63
- const fileStat = await fs.stat(join(dirPath, file));
64
- if (fileStat.isDirectory()) {
65
- totalFileSize += await getTotalFilesSize(join(dirPath, file));
66
- } else {
67
- totalFileSize += fileStat.size;
63
+ let totalFileSize = 0;
64
+ const files = await fs.readdir(dirPath);
65
+ for (const file of files) {
66
+ const fileStat = await fs.stat(join(dirPath, file));
67
+ if (fileStat.isDirectory()) {
68
+ totalFileSize += await getTotalFilesSize(join(dirPath, file));
69
+ }
70
+ else {
71
+ totalFileSize += fileStat.size;
72
+ }
68
73
  }
69
- }
70
- return totalFileSize;
74
+ return totalFileSize;
71
75
  }
72
- //# sourceMappingURL=statistic-utills.js.map
@@ -1,5 +1,5 @@
1
- import { Queue } from './queue';
2
- import { ConversionDump } from './conversion-dump';
1
+ import { Queue } from "./queue.js";
2
+ import { ConversionDump } from "./conversion-dump.js";
3
3
  export type WriteQueueItem = {
4
4
  archiveKey?: string;
5
5
  sourceId?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAKjD,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,cAAc,CAAiB;IAChC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAC1C,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IACtC,iB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