@loaders.gl/tile-converter 4.2.0-alpha.3 → 4.2.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +73 -59
  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 +17 -13
  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
@@ -3,92 +3,140 @@ import { JSONLoader } 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
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
+ else {
53
+ return null;
54
+ }
55
+ }
56
+ else {
57
+ const pathGzFile = await compressFileWithGzip(pathFile);
58
+ // After compression, we don't need an uncompressed file
59
+ await removeFile(pathFile);
60
+ return pathGzFile;
61
+ }
45
62
  }
46
- }
47
- return pathFile;
63
+ return pathFile;
48
64
  }
65
+ /**
66
+ * Open json file
67
+ * @param path - path to the file
68
+ * @param fileName - file name
69
+ * @returns object
70
+ */
49
71
  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
- });
72
+ return new Promise((resolve, reject) => {
73
+ let count = 0;
74
+ console.log(`load ${path}/${fileName}.`); // eslint-disable-line
75
+ const intervalId = setInterval(() => {
76
+ const pathFile = join(path, fileName);
77
+ load(pathFile, JSONLoader)
78
+ .then((result) => {
79
+ clearInterval(intervalId);
80
+ resolve(result);
81
+ })
82
+ .catch(() => {
83
+ count++;
84
+ if (count > 100) {
85
+ clearInterval(intervalId);
86
+ reject(new Error(`Cannon load ${path}/${fileName}.`));
87
+ }
88
+ });
89
+ }, 200);
90
+ });
67
91
  }
92
+ /**
93
+ * Check if the file exists
94
+ * @param fileName - full name of file
95
+ * @returns true if file exists, otherwise - false
96
+ */
68
97
  export async function isFileExists(fileName) {
69
- try {
70
- await fs.stat(fileName);
71
- return true;
72
- } catch {
73
- return false;
74
- }
98
+ try {
99
+ await fs.stat(fileName);
100
+ return true;
101
+ }
102
+ catch {
103
+ return false;
104
+ }
75
105
  }
106
+ /**
107
+ * Remove dir with path
108
+ *
109
+ * @param path
110
+ */
76
111
  export function removeDir(path) {
77
- return fs.rm(path, {
78
- recursive: true
79
- });
112
+ // (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
113
+ return fs.rm(path, { recursive: true });
80
114
  }
115
+ /**
116
+ * Remove file with path
117
+ *
118
+ * @param path
119
+ */
81
120
  export function removeFile(path) {
82
- return fs.unlink(path);
121
+ return fs.unlink(path);
83
122
  }
123
+ /**
124
+ * Generates absolute file path
125
+ * @param filePath
126
+ */
84
127
  export function getAbsoluteFilePath(filePath) {
85
- return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
128
+ return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
86
129
  }
130
+ /**
131
+ * Rename file with old path by new path
132
+ * @param oldPath
133
+ * @param newPath
134
+ */
87
135
  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
- }
136
+ try {
137
+ await fs.rename(oldPath, newPath);
138
+ }
139
+ catch (err) {
140
+ console.log("Can't rename file", err);
141
+ }
93
142
  }
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,72 +1,77 @@
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 {
11
- const nanoSecondsInMillisecond = 1e6;
12
- const timeInSeconds = time[0];
13
- const milliseconds = time[1] / nanoSecondsInMillisecond;
14
- return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
15
- }
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
+ else {
18
+ // time - high-resolution real time in a [seconds, nanoseconds] tuple Array
19
+ const nanoSecondsInMillisecond = 1e6;
20
+ const timeInSeconds = time[0];
21
+ const milliseconds = time[1] / nanoSecondsInMillisecond;
22
+ return timeConverterFromSecondsAndMilliseconds(timeInSeconds, milliseconds);
23
+ }
16
24
  }
17
25
  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;
26
+ const hours = Math.floor(timeInSeconds / 3600);
27
+ timeInSeconds = timeInSeconds - hours * 3600;
28
+ const minutes = Math.floor(timeInSeconds / 60);
29
+ timeInSeconds = timeInSeconds - minutes * 60;
30
+ const seconds = Math.floor(timeInSeconds);
31
+ let result = '';
32
+ if (hours) {
33
+ result += `${hours}h `;
34
+ }
35
+ if (minutes) {
36
+ result += `${minutes}m `;
37
+ }
38
+ if (seconds) {
39
+ result += `${seconds}s`;
40
+ }
41
+ if (!result) {
42
+ result += `${Math.floor(milliseconds)}ms`;
43
+ }
44
+ return result;
37
45
  }
38
46
  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;
47
+ const { slpk, outputPath, tilesetName } = params;
48
+ const fullOutputPath = getAbsoluteFilePath(outputPath);
49
+ try {
50
+ if (slpk) {
51
+ const slpkPath = join(fullOutputPath, `${tilesetName}.slpk`);
52
+ const stat = await fs.stat(slpkPath);
53
+ return stat.size;
54
+ }
55
+ const directoryPath = join(fullOutputPath, tilesetName);
56
+ const totalSize = await getTotalFilesSize(directoryPath);
57
+ return totalSize;
58
+ }
59
+ catch (error) {
60
+ console.log('Calculate file sizes error: ', error); // eslint-disable-line
61
+ return null;
50
62
  }
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
63
  }
59
64
  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;
65
+ let totalFileSize = 0;
66
+ const files = await fs.readdir(dirPath);
67
+ for (const file of files) {
68
+ const fileStat = await fs.stat(join(dirPath, file));
69
+ if (fileStat.isDirectory()) {
70
+ totalFileSize += await getTotalFilesSize(join(dirPath, file));
71
+ }
72
+ else {
73
+ totalFileSize += fileStat.size;
74
+ }
68
75
  }
69
- }
70
- return totalFileSize;
76
+ return totalFileSize;
71
77
  }
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,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;gBAG9B,cAAc,EAAE,cAAc,EAC9B,iBAAiB,GAAE,MAAa,EAChC,gBAAgB,GAAE,MAAY;IAQ1B,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,gBAAgB,GAAE,OAAe;IAgBvD,cAAc;IAId,aAAa;IAMP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAKjB,OAAO;IAsBrB,OAAO,CAAC,aAAa;CAWtB"}
1
+ {"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,mBAAgB;AAE9B,OAAO,EAAC,cAAc,EAAC,6BAA0B;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,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;gBAG9B,cAAc,EAAE,cAAc,EAC9B,iBAAiB,GAAE,MAAa,EAChC,gBAAgB,GAAE,MAAY;IAQ1B,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,gBAAgB,GAAE,OAAe;IAgBvD,cAAc;IAId,aAAa;IAMP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAKjB,OAAO;IAsBrB,OAAO,CAAC,aAAa;CAWtB"}