@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +3 -3
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +329 -293
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +257 -200
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
- package/dist/3d-tiles-converter/helpers/load-i3s.js +106 -75
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
- package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
- package/dist/constants.js +0 -1
- package/dist/converter-cli.js +255 -234
- package/dist/converter.min.cjs +80 -90
- package/dist/deps-installer/deps-installer.js +72 -58
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +207 -153
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +145 -103
- package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
- package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
- package/dist/i3s-converter/helpers/feature-attributes.js +168 -105
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +204 -212
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +1148 -829
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +111 -97
- package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
- package/dist/i3s-converter/helpers/node-debug.js +98 -54
- package/dist/i3s-converter/helpers/node-index-document.d.ts +3 -3
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +248 -177
- package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +299 -194
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
- package/dist/i3s-converter/helpers/progress.js +134 -83
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +24 -13
- package/dist/i3s-converter/i3s-converter.d.ts +7 -7
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +1044 -898
- package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
- package/dist/i3s-converter/json-templates/layers.js +120 -121
- package/dist/i3s-converter/json-templates/metadata.js +19 -20
- package/dist/i3s-converter/json-templates/node.js +73 -71
- package/dist/i3s-converter/json-templates/scene-server.js +25 -26
- package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
- package/dist/i3s-converter/json-templates/store.js +96 -94
- package/dist/i3s-converter/types.js +35 -23
- package/dist/i3s-server/app.js +15 -12
- package/dist/i3s-server/bin/www.js +14 -7
- package/dist/i3s-server/controllers/index-controller.js +18 -15
- package/dist/i3s-server/controllers/slpk-controller.js +22 -11
- package/dist/i3s-server/routes/index.js +9 -8
- package/dist/i3s-server/routes/slpk-router.js +18 -17
- package/dist/i3s-server/utils/create-scene-server.js +15 -10
- package/dist/i3s-server/utils/server-utils.js +49 -32
- package/dist/index.cjs +292 -851
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
- package/dist/lib/utils/cli-utils.js +63 -36
- package/dist/lib/utils/compress-util.js +20 -15
- package/dist/lib/utils/conversion-dump.d.ts +1 -1
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +209 -187
- package/dist/lib/utils/file-utils.js +122 -74
- package/dist/lib/utils/geometry-utils.js +13 -7
- package/dist/lib/utils/lod-conversion-utils.js +65 -33
- package/dist/lib/utils/queue.js +12 -13
- package/dist/lib/utils/statistic-utills.d.ts +6 -23
- package/dist/lib/utils/statistic-utills.js +64 -59
- package/dist/lib/utils/write-queue.d.ts +2 -2
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +68 -86
- package/dist/pgm-loader.js +16 -12
- package/dist/slpk-extractor/slpk-extractor.js +59 -50
- package/dist/slpk-extractor-cli.js +82 -59
- package/package.json +18 -18
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/converter-cli.js.map +0 -1
- package/dist/deps-installer/deps-installer.js.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
- package/dist/i3s-converter/helpers/progress.js.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
- package/dist/i3s-converter/i3s-converter.js.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
- package/dist/i3s-converter/json-templates/node.js.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
- package/dist/i3s-converter/json-templates/store.js.map +0 -1
- package/dist/i3s-converter/types.js.map +0 -1
- package/dist/i3s-server/README.md +0 -63
- package/dist/i3s-server/app.js.map +0 -1
- package/dist/i3s-server/bin/www.js.map +0 -1
- package/dist/i3s-server/certs/cert.pem +0 -19
- package/dist/i3s-server/certs/key.pem +0 -27
- package/dist/i3s-server/controllers/index-controller.js.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
- package/dist/i3s-server/routes/index.js.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
- package/dist/i3s-server/utils/server-utils.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
- package/dist/lib/utils/cli-utils.js.map +0 -1
- package/dist/lib/utils/compress-util.js.map +0 -1
- package/dist/lib/utils/conversion-dump.js.map +0 -1
- package/dist/lib/utils/file-utils.js.map +0 -1
- package/dist/lib/utils/geometry-utils.js.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
- package/dist/lib/utils/queue.js.map +0 -1
- package/dist/lib/utils/statistic-utills.js.map +0 -1
- package/dist/lib/utils/write-queue.js.map +0 -1
- package/dist/pgm-loader.js.map +0 -1
- package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
- package/dist/slpk-extractor-cli.js.map +0 -1
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
toWriteData
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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
|
-
|
|
121
|
+
return fs.unlink(path);
|
|
83
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Generates absolute file path
|
|
125
|
+
* @param filePath
|
|
126
|
+
*/
|
|
84
127
|
export function getAbsoluteFilePath(filePath) {
|
|
85
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
package/dist/lib/utils/queue.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
export class Queue extends Array {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
*
|
|
3
|
-
* @param
|
|
4
|
-
* @
|
|
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]):
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,
|
|
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"}
|