@loaders.gl/tile-converter 3.4.14 → 3.4.15
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-attributes-worker.js +1 -1
- package/dist/converter.min.js +78 -77
- package/dist/dist.min.js +2081 -1557
- package/dist/es5/3d-tiles-attributes-worker.js +3 -3
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +203 -417
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +197 -266
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +4 -6
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +12 -12
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +35 -51
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js +1 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +78 -133
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +38 -110
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +3 -3
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +31 -36
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +23 -23
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +9 -27
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +27 -42
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +97 -114
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +523 -798
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +24 -25
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +27 -25
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +165 -461
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +169 -474
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +663 -1401
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +82 -92
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +130 -152
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +21 -23
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +78 -89
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +27 -31
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +110 -152
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js +2 -4
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-server/app.js +6 -6
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +20 -49
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +14 -33
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +2 -2
- package/dist/es5/lib/utils/compress-util.js +127 -295
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +65 -174
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +13 -38
- package/dist/es5/lib/utils/queue.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +39 -117
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +74 -195
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +3 -22
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +5 -22
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +4 -25
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/package.json +15 -15
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -11,188 +10,80 @@ exports.removeDir = removeDir;
|
|
|
11
10
|
exports.removeFile = removeFile;
|
|
12
11
|
exports.writeFile = writeFile;
|
|
13
12
|
exports.writeFileForSlpk = writeFileForSlpk;
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
13
|
var _core = require("@loaders.gl/core");
|
|
17
14
|
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
18
15
|
var _fs = require("fs");
|
|
19
16
|
var _path = require("path");
|
|
20
17
|
var _compressUtil = require("./compress-util");
|
|
21
|
-
function writeFile(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
_context.t1 = _context.sent;
|
|
43
|
-
toWriteData = new _context.t0(_context.t1);
|
|
44
|
-
_context.next = 10;
|
|
45
|
-
break;
|
|
46
|
-
case 9:
|
|
47
|
-
if (data instanceof ArrayBuffer) {
|
|
48
|
-
toWriteData = new Uint8Array(data);
|
|
49
|
-
} else {
|
|
50
|
-
toWriteData = data;
|
|
51
|
-
}
|
|
52
|
-
case 10:
|
|
53
|
-
_context.next = 12;
|
|
54
|
-
return _fs.promises.mkdir(path, {
|
|
55
|
-
recursive: true
|
|
56
|
-
});
|
|
57
|
-
case 12:
|
|
58
|
-
pathFile = (0, _path.join)(path, fileName);
|
|
59
|
-
_context.prev = 13;
|
|
60
|
-
_context.next = 16;
|
|
61
|
-
return _fs.promises.writeFile(pathFile, toWriteData);
|
|
62
|
-
case 16:
|
|
63
|
-
_context.next = 21;
|
|
64
|
-
break;
|
|
65
|
-
case 18:
|
|
66
|
-
_context.prev = 18;
|
|
67
|
-
_context.t2 = _context["catch"](13);
|
|
68
|
-
throw _context.t2;
|
|
69
|
-
case 21:
|
|
70
|
-
console.log("".concat(pathFile, " saved."));
|
|
71
|
-
return _context.abrupt("return", pathFile);
|
|
72
|
-
case 23:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee, null, [[13, 18]]);
|
|
77
|
-
}));
|
|
78
|
-
return _writeFile.apply(this, arguments);
|
|
79
|
-
}
|
|
80
|
-
function writeFileForSlpk(_x3, _x4) {
|
|
81
|
-
return _writeFileForSlpk.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
function _writeFileForSlpk() {
|
|
84
|
-
_writeFileForSlpk = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(path, data) {
|
|
85
|
-
var fileName,
|
|
86
|
-
compress,
|
|
87
|
-
compressList,
|
|
88
|
-
pathFile,
|
|
89
|
-
pathGzFile,
|
|
90
|
-
_args2 = arguments;
|
|
91
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
92
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
93
|
-
case 0:
|
|
94
|
-
fileName = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 'index.json';
|
|
95
|
-
compress = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : true;
|
|
96
|
-
compressList = _args2.length > 4 ? _args2[4] : undefined;
|
|
97
|
-
_context2.next = 5;
|
|
98
|
-
return writeFile(path, data, fileName);
|
|
99
|
-
case 5:
|
|
100
|
-
pathFile = _context2.sent;
|
|
101
|
-
if (!compress) {
|
|
102
|
-
_context2.next = 22;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
if (!compressList) {
|
|
106
|
-
_context2.next = 16;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
if (compressList.includes(pathFile)) {
|
|
110
|
-
_context2.next = 13;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
compressList.push(pathFile);
|
|
114
|
-
return _context2.abrupt("return", "".concat(pathFile, ".gz"));
|
|
115
|
-
case 13:
|
|
116
|
-
return _context2.abrupt("return", null);
|
|
117
|
-
case 14:
|
|
118
|
-
_context2.next = 22;
|
|
119
|
-
break;
|
|
120
|
-
case 16:
|
|
121
|
-
_context2.next = 18;
|
|
122
|
-
return (0, _compressUtil.compressFileWithGzip)(pathFile);
|
|
123
|
-
case 18:
|
|
124
|
-
pathGzFile = _context2.sent;
|
|
125
|
-
_context2.next = 21;
|
|
126
|
-
return removeFile(pathFile);
|
|
127
|
-
case 21:
|
|
128
|
-
return _context2.abrupt("return", pathGzFile);
|
|
129
|
-
case 22:
|
|
130
|
-
return _context2.abrupt("return", pathFile);
|
|
131
|
-
case 23:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context2.stop();
|
|
134
|
-
}
|
|
135
|
-
}, _callee2);
|
|
136
|
-
}));
|
|
137
|
-
return _writeFileForSlpk.apply(this, arguments);
|
|
138
|
-
}
|
|
139
|
-
function openJson(_x5, _x6) {
|
|
140
|
-
return _openJson.apply(this, arguments);
|
|
18
|
+
async function writeFile(path, data) {
|
|
19
|
+
let fileName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.json';
|
|
20
|
+
let toWriteData;
|
|
21
|
+
if (data instanceof Promise) {
|
|
22
|
+
toWriteData = new Uint8Array(await data);
|
|
23
|
+
} else if (data instanceof ArrayBuffer) {
|
|
24
|
+
toWriteData = new Uint8Array(data);
|
|
25
|
+
} else {
|
|
26
|
+
toWriteData = data;
|
|
27
|
+
}
|
|
28
|
+
await _fs.promises.mkdir(path, {
|
|
29
|
+
recursive: true
|
|
30
|
+
});
|
|
31
|
+
const pathFile = (0, _path.join)(path, fileName);
|
|
32
|
+
try {
|
|
33
|
+
await _fs.promises.writeFile(pathFile, toWriteData);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
console.log("".concat(pathFile, " saved."));
|
|
38
|
+
return pathFile;
|
|
141
39
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
resolve(result);
|
|
155
|
-
}).catch(function () {
|
|
156
|
-
count++;
|
|
157
|
-
if (count > 100) {
|
|
158
|
-
clearInterval(intervalId);
|
|
159
|
-
reject(new Error("Cannon load ".concat(path, "/").concat(fileName, ".")));
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}, 200);
|
|
163
|
-
}));
|
|
164
|
-
case 1:
|
|
165
|
-
case "end":
|
|
166
|
-
return _context3.stop();
|
|
40
|
+
async function writeFileForSlpk(path, data) {
|
|
41
|
+
let fileName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'index.json';
|
|
42
|
+
let compress = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
43
|
+
let compressList = arguments.length > 4 ? arguments[4] : undefined;
|
|
44
|
+
const pathFile = await writeFile(path, data, fileName);
|
|
45
|
+
if (compress) {
|
|
46
|
+
if (compressList) {
|
|
47
|
+
if (!compressList.includes(pathFile)) {
|
|
48
|
+
compressList.push(pathFile);
|
|
49
|
+
return "".concat(pathFile, ".gz");
|
|
50
|
+
} else {
|
|
51
|
+
return null;
|
|
167
52
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
53
|
+
} else {
|
|
54
|
+
const pathGzFile = await (0, _compressUtil.compressFileWithGzip)(pathFile);
|
|
55
|
+
await removeFile(pathFile);
|
|
56
|
+
return pathGzFile;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return pathFile;
|
|
171
60
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
61
|
+
async function openJson(path, fileName) {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
let count = 0;
|
|
64
|
+
console.log("load ".concat(path, "/").concat(fileName, "."));
|
|
65
|
+
const intervalId = setInterval(() => {
|
|
66
|
+
const pathFile = (0, _path.join)(path, fileName);
|
|
67
|
+
(0, _core.load)(pathFile, _loaderUtils.JSONLoader).then(result => {
|
|
68
|
+
clearInterval(intervalId);
|
|
69
|
+
resolve(result);
|
|
70
|
+
}).catch(() => {
|
|
71
|
+
count++;
|
|
72
|
+
if (count > 100) {
|
|
73
|
+
clearInterval(intervalId);
|
|
74
|
+
reject(new Error("Cannon load ".concat(path, "/").concat(fileName, ".")));
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, 200);
|
|
78
|
+
});
|
|
174
79
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return _fs.promises.stat(fileName);
|
|
183
|
-
case 3:
|
|
184
|
-
return _context4.abrupt("return", true);
|
|
185
|
-
case 6:
|
|
186
|
-
_context4.prev = 6;
|
|
187
|
-
_context4.t0 = _context4["catch"](0);
|
|
188
|
-
return _context4.abrupt("return", false);
|
|
189
|
-
case 9:
|
|
190
|
-
case "end":
|
|
191
|
-
return _context4.stop();
|
|
192
|
-
}
|
|
193
|
-
}, _callee4, null, [[0, 6]]);
|
|
194
|
-
}));
|
|
195
|
-
return _isFileExists.apply(this, arguments);
|
|
80
|
+
async function isFileExists(fileName) {
|
|
81
|
+
try {
|
|
82
|
+
await _fs.promises.stat(fileName);
|
|
83
|
+
return true;
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
196
87
|
}
|
|
197
88
|
function removeDir(path) {
|
|
198
89
|
return _fs.promises.rmdir(path, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","names":["_core","require","_loaderUtils","_fs","_path","_compressUtil","writeFile","_x","_x2","_writeFile","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","path","data","fileName","toWriteData","pathFile","_args","wrap","_callee$","_context","prev","next","length","undefined","Promise","t0","Uint8Array","t1","sent","ArrayBuffer","fs","mkdir","recursive","join","t2","console","log","concat","abrupt","stop","writeFileForSlpk","_x3","_x4","_writeFileForSlpk","_callee2","compress","compressList","pathGzFile","_args2","_callee2$","_context2","includes","push","compressFileWithGzip","removeFile","openJson","_x5","_x6","_openJson","_callee3","_callee3$","_context3","resolve","reject","count","intervalId","setInterval","load","JSONLoader","then","result","clearInterval","catch","Error","isFileExists","_x7","_isFileExists","_callee4","_callee4$","_context4","stat","removeDir","rmdir","unlink","getAbsoluteFilePath","filePath","isAbsolute","process","cwd"],"sources":["../../../../src/lib/utils/file-utils.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {JSONLoader} from '@loaders.gl/loader-utils';\nimport {promises as fs} from 'fs';\nimport {isAbsolute, join} from 'path';\nimport {compressFileWithGzip} from './compress-util';\n\n/**\n * Write a file with data and name fileName to path\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n */\nexport async function writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json'\n): Promise<string> {\n let toWriteData: string | Uint8Array;\n if (data instanceof Promise) {\n toWriteData = new Uint8Array(await data);\n } else if (data instanceof ArrayBuffer) {\n toWriteData = new Uint8Array(data as ArrayBuffer);\n } else {\n toWriteData = data;\n }\n await fs.mkdir(path, {recursive: true});\n const pathFile = join(path, fileName);\n try {\n await fs.writeFile(pathFile, toWriteData);\n } catch (err) {\n throw err;\n }\n console.log(`${pathFile} saved.`); // eslint-disable-line\n return pathFile;\n}\n\n/**\n * Write a file with data and name fileName to path - specific one for further packaging into slpk\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n * @param compress - if need to compress file with gzip (default: true)\n * @param compressList - if set - the file should be added to this list and compressed in the end of conversion\n */\nexport async function writeFileForSlpk(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json',\n compress: boolean = true,\n compressList?: string[] | null\n): Promise<string | null> {\n const pathFile = await writeFile(path, data, fileName);\n if (compress) {\n if (compressList) {\n if (!compressList.includes(pathFile)) {\n compressList.push(pathFile);\n return `${pathFile}.gz`;\n } else {\n return null;\n }\n } else {\n const pathGzFile = await compressFileWithGzip(pathFile);\n // After compression, we don't need an uncompressed file\n await removeFile(pathFile);\n return pathGzFile;\n }\n }\n return pathFile;\n}\n\n/**\n * Open json file\n * @param path - path to the file\n * @param fileName - file name\n * @returns object\n */\nexport async function openJson(path: string, fileName: string): Promise<{[key: string]: any}> {\n return new Promise((resolve, reject) => {\n let count = 0;\n console.log(`load ${path}/${fileName}.`); // eslint-disable-line\n const intervalId = setInterval(() => {\n const pathFile = join(path, fileName);\n load(pathFile, JSONLoader)\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch(() => {\n count++;\n if (count > 100) {\n clearInterval(intervalId);\n reject(new Error(`Cannon load ${path}/${fileName}.`));\n }\n });\n }, 200);\n });\n}\n\n/**\n * Check if the file exists\n * @param fileName - full name of file\n * @returns true if file exists, otherwise - false\n */\nexport async function isFileExists(fileName: string): Promise<boolean> {\n try {\n await fs.stat(fileName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove dir with path\n *\n * @param path\n */\nexport function removeDir(path: string) {\n return fs.rmdir(path, {recursive: true});\n}\n\n/**\n * Remove file with path\n *\n * @param path\n */\nexport function removeFile(path: string) {\n return fs.unlink(path);\n}\n\n/**\n * Generates absolute file path\n * @param filePath\n */\nexport function getAbsoluteFilePath(filePath: string) {\n return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AAC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compressUtil","writeFile","path","data","fileName","arguments","length","undefined","toWriteData","Promise","Uint8Array","ArrayBuffer","fs","mkdir","recursive","pathFile","join","err","console","log","concat","writeFileForSlpk","compress","compressList","includes","push","pathGzFile","compressFileWithGzip","removeFile","openJson","resolve","reject","count","intervalId","setInterval","load","JSONLoader","then","result","clearInterval","catch","Error","isFileExists","stat","removeDir","rmdir","unlink","getAbsoluteFilePath","filePath","isAbsolute","process","cwd"],"sources":["../../../../src/lib/utils/file-utils.ts"],"sourcesContent":["import {load} from '@loaders.gl/core';\nimport {JSONLoader} from '@loaders.gl/loader-utils';\nimport {promises as fs} from 'fs';\nimport {isAbsolute, join} from 'path';\nimport {compressFileWithGzip} from './compress-util';\n\n/**\n * Write a file with data and name fileName to path\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n */\nexport async function writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json'\n): Promise<string> {\n let toWriteData: string | Uint8Array;\n if (data instanceof Promise) {\n toWriteData = new Uint8Array(await data);\n } else if (data instanceof ArrayBuffer) {\n toWriteData = new Uint8Array(data as ArrayBuffer);\n } else {\n toWriteData = data;\n }\n await fs.mkdir(path, {recursive: true});\n const pathFile = join(path, fileName);\n try {\n await fs.writeFile(pathFile, toWriteData);\n } catch (err) {\n throw err;\n }\n console.log(`${pathFile} saved.`); // eslint-disable-line\n return pathFile;\n}\n\n/**\n * Write a file with data and name fileName to path - specific one for further packaging into slpk\n *\n * @param path - output path\n * @param data - file content\n * @param fileName - name of output file (default: index.json)\n * @param compress - if need to compress file with gzip (default: true)\n * @param compressList - if set - the file should be added to this list and compressed in the end of conversion\n */\nexport async function writeFileForSlpk(\n path: string,\n data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,\n fileName: string = 'index.json',\n compress: boolean = true,\n compressList?: string[] | null\n): Promise<string | null> {\n const pathFile = await writeFile(path, data, fileName);\n if (compress) {\n if (compressList) {\n if (!compressList.includes(pathFile)) {\n compressList.push(pathFile);\n return `${pathFile}.gz`;\n } else {\n return null;\n }\n } else {\n const pathGzFile = await compressFileWithGzip(pathFile);\n // After compression, we don't need an uncompressed file\n await removeFile(pathFile);\n return pathGzFile;\n }\n }\n return pathFile;\n}\n\n/**\n * Open json file\n * @param path - path to the file\n * @param fileName - file name\n * @returns object\n */\nexport async function openJson(path: string, fileName: string): Promise<{[key: string]: any}> {\n return new Promise((resolve, reject) => {\n let count = 0;\n console.log(`load ${path}/${fileName}.`); // eslint-disable-line\n const intervalId = setInterval(() => {\n const pathFile = join(path, fileName);\n load(pathFile, JSONLoader)\n .then((result) => {\n clearInterval(intervalId);\n resolve(result);\n })\n .catch(() => {\n count++;\n if (count > 100) {\n clearInterval(intervalId);\n reject(new Error(`Cannon load ${path}/${fileName}.`));\n }\n });\n }, 200);\n });\n}\n\n/**\n * Check if the file exists\n * @param fileName - full name of file\n * @returns true if file exists, otherwise - false\n */\nexport async function isFileExists(fileName: string): Promise<boolean> {\n try {\n await fs.stat(fileName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Remove dir with path\n *\n * @param path\n */\nexport function removeDir(path: string) {\n return fs.rmdir(path, {recursive: true});\n}\n\n/**\n * Remove file with path\n *\n * @param path\n */\nexport function removeFile(path: string) {\n return fs.unlink(path);\n}\n\n/**\n * Generates absolute file path\n * @param filePath\n */\nexport function getAbsoluteFilePath(filePath: string) {\n return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);\n}\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AASO,eAAeK,SAASA,CAC7BC,IAAY,EACZC,IAA8D,EAE7C;EAAA,IADjBC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAA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C;IACvB,OAAO,IAAI;EACb,CAAC,CAAC,MAAM;IACN,OAAO,KAAK;EACd;AACF;AAOO,SAASwC,SAASA,CAAC1C,IAAY,EAAE;EACtC,OAAOU,YAAE,CAACiC,KAAK,CAAC3C,IAAI,EAAE;IAACY,SAAS,EAAE;EAAI,CAAC,CAAC;AAC1C;AAOO,SAASc,UAAUA,CAAC1B,IAAY,EAAE;EACvC,OAAOU,YAAE,CAACkC,MAAM,CAAC5C,IAAI,CAAC;AACxB;AAMO,SAAS6C,mBAAmBA,CAACC,QAAgB,EAAE;EACpD,OAAO,IAAAC,gBAAU,EAACD,QAAQ,CAAC,GAAGA,QAAQ,GAAG,IAAAhC,UAAI,EAACkC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAEH,QAAQ,CAAC;AACxE"}
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.convertGeometricErrorToScreenThreshold = convertGeometricErrorToScreenThreshold;
|
|
7
7
|
exports.convertScreenThresholdToGeometricError = convertScreenThresholdToGeometricError;
|
|
8
|
-
|
|
8
|
+
const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
|
|
9
9
|
function convertGeometricErrorToScreenThreshold(tile, coordinates) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const lodSelection = [];
|
|
11
|
+
const boundingVolume = tile.boundingVolume;
|
|
12
|
+
const lodMetricValue = tile.lodMetricValue || 0.1;
|
|
13
|
+
const maxScreenThreshold = {
|
|
14
14
|
metricType: 'maxScreenThreshold',
|
|
15
15
|
maxError: coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR / lodMetricValue
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const maxScreenThresholdSQ = {
|
|
18
18
|
metricType: 'maxScreenThresholdSQ',
|
|
19
19
|
maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError
|
|
20
20
|
};
|
|
@@ -28,10 +28,10 @@ function convertGeometricErrorToScreenThreshold(tile, coordinates) {
|
|
|
28
28
|
return lodSelection;
|
|
29
29
|
}
|
|
30
30
|
function convertScreenThresholdToGeometricError(node) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const metricData = node.header.lodSelection.maxScreenThreshold || {};
|
|
32
|
+
let maxError = metricData.maxError;
|
|
33
33
|
if (!maxError) {
|
|
34
|
-
|
|
34
|
+
const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;
|
|
35
35
|
if (sqMetricData) {
|
|
36
36
|
maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","metricData","header","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {BoundingVolumes} from '@loaders.gl/i3s';\nimport {Tile3D} from '@loaders.gl/tiles';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile Object\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(tile: Tile3D, coordinates: BoundingVolumes) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: Tile3D): number {\n const metricData = node.header.lodSelection.maxScreenThreshold || {};\n let maxError = metricData.maxError;\n if (!maxError) {\n const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":";;;;;;;AAIA,
|
|
1
|
+
{"version":3,"file":"lod-conversion-utils.js","names":["DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR","convertGeometricErrorToScreenThreshold","tile","coordinates","lodSelection","boundingVolume","lodMetricValue","maxScreenThreshold","metricType","maxError","mbs","maxScreenThresholdSQ","Math","PI","constructor","name","push","convertScreenThresholdToGeometricError","node","metricData","header","sqMetricData","sqrt"],"sources":["../../../../src/lib/utils/lod-conversion-utils.ts"],"sourcesContent":["import {BoundingVolumes} from '@loaders.gl/i3s';\nimport {Tile3D} from '@loaders.gl/tiles';\n\n// https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html\nconst DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;\n/**\n * Do conversion from geometric error to screen threshold\n * \n * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.\n * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.\n * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles\n * 3DTiles spec:\n * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error\n * I3S spec:\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md\n * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us\n * to make child maxError bigger than his parent maxError.\n * \n * @param tile - 3d-tiles tile Object\n * @param coordinates - node converted coordinates\n * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection\n * @example \n * [\n {\n \"metricType\": \"maxScreenThresholdSQ\",\n \"maxError\": 870638.071285568\n },\n {\n \"metricType\": \"maxScreenThreshold\",\n \"maxError\": 1052.8679031638949\n }\n ]\n */\nexport function convertGeometricErrorToScreenThreshold(tile: Tile3D, coordinates: BoundingVolumes) {\n const lodSelection: {metricType: string; maxError: number}[] = [];\n const boundingVolume = tile.boundingVolume;\n const lodMetricValue = tile.lodMetricValue || 0.1;\n const maxScreenThreshold = {\n metricType: 'maxScreenThreshold',\n maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue\n };\n const maxScreenThresholdSQ = {\n metricType: 'maxScreenThresholdSQ',\n maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError\n };\n\n if (boundingVolume.constructor.name === 'OrientedBoundingBox') {\n lodSelection.push(maxScreenThresholdSQ);\n lodSelection.push(maxScreenThreshold);\n } else {\n lodSelection.push(maxScreenThreshold);\n lodSelection.push(maxScreenThresholdSQ);\n }\n\n return lodSelection;\n}\n\n/**\n * Convert LOD metric from \"Screen Threshold\" to \"Screen Space Error\"\n * @param node - i3s node data\n * @returns lod metric in 3d-tiles format\n */\nexport function convertScreenThresholdToGeometricError(node: Tile3D): number {\n const metricData = node.header.lodSelection.maxScreenThreshold || {};\n let maxError = metricData.maxError;\n if (!maxError) {\n const sqMetricData = node.header.lodSelection.maxScreenThresholdSQ;\n if (sqMetricData) {\n maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));\n }\n }\n\n if (!maxError) {\n maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;\n }\n\n return (node.header.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;\n}\n"],"mappings":";;;;;;;AAIA,MAAMA,kCAAkC,GAAG,EAAE;AA6BtC,SAASC,sCAAsCA,CAACC,IAAY,EAAEC,WAA4B,EAAE;EACjG,MAAMC,YAAsD,GAAG,EAAE;EACjE,MAAMC,cAAc,GAAGH,IAAI,CAACG,cAAc;EAC1C,MAAMC,cAAc,GAAGJ,IAAI,CAACI,cAAc,IAAI,GAAG;EACjD,MAAMC,kBAAkB,GAAG;IACzBC,UAAU,EAAE,oBAAoB;IAChCC,QAAQ,EAAGN,WAAW,CAACO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIM;EAC5E,CAAC;EACD,MAAMK,oBAAoB,GAAG;IAC3BH,UAAU,EAAE,sBAAsB;IAClCC,QAAQ,EAAEG,IAAI,CAACC,EAAE,GAAG,IAAI,GAAGN,kBAAkB,CAACE,QAAQ,GAAGF,kBAAkB,CAACE;EAC9E,CAAC;EAED,IAAIJ,cAAc,CAACS,WAAW,CAACC,IAAI,KAAK,qBAAqB,EAAE;IAC7DX,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;IACvCP,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;EACvC,CAAC,MAAM;IACLH,YAAY,CAACY,IAAI,CAACT,kBAAkB,CAAC;IACrCH,YAAY,CAACY,IAAI,CAACL,oBAAoB,CAAC;EACzC;EAEA,OAAOP,YAAY;AACrB;AAOO,SAASa,sCAAsCA,CAACC,IAAY,EAAU;EAC3E,MAAMC,UAAU,GAAGD,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACG,kBAAkB,IAAI,CAAC,CAAC;EACpE,IAAIE,QAAQ,GAAGU,UAAU,CAACV,QAAQ;EAClC,IAAI,CAACA,QAAQ,EAAE;IACb,MAAMY,YAAY,GAAGH,IAAI,CAACE,MAAM,CAAChB,YAAY,CAACO,oBAAoB;IAClE,IAAIU,YAAY,EAAE;MAChBZ,QAAQ,GAAGG,IAAI,CAACU,IAAI,CAACD,YAAY,CAACZ,QAAQ,IAAIG,IAAI,CAACC,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE;EACF;EAEA,IAAI,CAACJ,QAAQ,EAAE;IACbA,QAAQ,GAAGT,kCAAkC;EAC/C;EAEA,OAAQkB,IAAI,CAACE,MAAM,CAACV,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGV,kCAAkC,GAAIS,QAAQ;AACjF"}
|
|
@@ -1,47 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.Queue = void 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
14
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
15
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
var Queue = function (_Array) {
|
|
17
|
-
(0, _inherits2.default)(Queue, _Array);
|
|
18
|
-
var _super = _createSuper(Queue);
|
|
19
|
-
function Queue() {
|
|
20
|
-
(0, _classCallCheck2.default)(this, Queue);
|
|
21
|
-
return _super.apply(this, arguments);
|
|
7
|
+
class Queue extends Array {
|
|
8
|
+
enqueue(val) {
|
|
9
|
+
this.push(val);
|
|
22
10
|
}
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, {
|
|
34
|
-
key: "peek",
|
|
35
|
-
value: function peek() {
|
|
36
|
-
return this[0];
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
key: "isEmpty",
|
|
40
|
-
value: function isEmpty() {
|
|
41
|
-
return this.length === 0;
|
|
42
|
-
}
|
|
43
|
-
}]);
|
|
44
|
-
return Queue;
|
|
45
|
-
}((0, _wrapNativeSuper2.default)(Array));
|
|
11
|
+
dequeue() {
|
|
12
|
+
return this.shift();
|
|
13
|
+
}
|
|
14
|
+
peek() {
|
|
15
|
+
return this[0];
|
|
16
|
+
}
|
|
17
|
+
isEmpty() {
|
|
18
|
+
return this.length === 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
46
21
|
exports.Queue = Queue;
|
|
47
22
|
//# sourceMappingURL=queue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","names":["Queue","
|
|
1
|
+
{"version":3,"file":"queue.js","names":["Queue","Array","enqueue","val","push","dequeue","shift","peek","isEmpty","length","exports"],"sources":["../../../../src/lib/utils/queue.ts"],"sourcesContent":["export class Queue<T> extends Array<T> {\n enqueue(val: T) {\n this.push(val);\n }\n\n dequeue(): T | undefined {\n return this.shift();\n }\n\n peek(): T {\n return this[0];\n }\n\n isEmpty() {\n return this.length === 0;\n }\n}\n"],"mappings":";;;;;;AAAO,MAAMA,KAAK,SAAYC,KAAK,CAAI;EACrCC,OAAOA,CAACC,GAAM,EAAE;IACd,IAAI,CAACC,IAAI,CAACD,GAAG,CAAC;EAChB;EAEAE,OAAOA,CAAA,EAAkB;IACvB,OAAO,IAAI,CAACC,KAAK,CAAC,CAAC;EACrB;EAEAC,IAAIA,CAAA,EAAM;IACR,OAAO,IAAI,CAAC,CAAC,CAAC;EAChB;EAEAC,OAAOA,CAAA,EAAG;IACR,OAAO,IAAI,CAACC,MAAM,KAAK,CAAC;EAC1B;AACF;AAACC,OAAA,CAAAV,KAAA,GAAAA,KAAA"}
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.calculateFilesSize = calculateFilesSize;
|
|
8
7
|
exports.timeConverter = timeConverter;
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
8
|
var _path = require("path");
|
|
12
9
|
var _fs = require("fs");
|
|
13
10
|
var _fileUtils = require("./file-utils");
|
|
14
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
11
|
function timeConverter(time) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
const nanoSecondsInMillisecond = 1e6;
|
|
13
|
+
let timeInSeconds = time[0];
|
|
14
|
+
const hours = Math.floor(timeInSeconds / 3600);
|
|
21
15
|
timeInSeconds = timeInSeconds - hours * 3600;
|
|
22
|
-
|
|
16
|
+
const minutes = Math.floor(timeInSeconds / 60);
|
|
23
17
|
timeInSeconds = timeInSeconds - minutes * 60;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
const seconds = Math.floor(timeInSeconds);
|
|
19
|
+
const milliseconds = time[1] / nanoSecondsInMillisecond;
|
|
20
|
+
let result = '';
|
|
27
21
|
if (hours) {
|
|
28
22
|
result += "".concat(hours, "h ");
|
|
29
23
|
}
|
|
@@ -38,110 +32,38 @@ function timeConverter(time) {
|
|
|
38
32
|
}
|
|
39
33
|
return result;
|
|
40
34
|
}
|
|
41
|
-
function calculateFilesSize(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
stat = _context.sent;
|
|
62
|
-
return _context.abrupt("return", stat.size);
|
|
63
|
-
case 9:
|
|
64
|
-
directoryPath = (0, _path.join)(fullOutputPath, tilesetName);
|
|
65
|
-
_context.next = 12;
|
|
66
|
-
return getTotalFilesSize(directoryPath);
|
|
67
|
-
case 12:
|
|
68
|
-
totalSize = _context.sent;
|
|
69
|
-
return _context.abrupt("return", totalSize);
|
|
70
|
-
case 16:
|
|
71
|
-
_context.prev = 16;
|
|
72
|
-
_context.t0 = _context["catch"](2);
|
|
73
|
-
console.log('Calculate file sizes error: ', _context.t0);
|
|
74
|
-
return _context.abrupt("return", null);
|
|
75
|
-
case 20:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee, null, [[2, 16]]);
|
|
80
|
-
}));
|
|
81
|
-
return _calculateFilesSize.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
function getTotalFilesSize(_x2) {
|
|
84
|
-
return _getTotalFilesSize.apply(this, arguments);
|
|
35
|
+
async function calculateFilesSize(params) {
|
|
36
|
+
const {
|
|
37
|
+
slpk,
|
|
38
|
+
outputPath,
|
|
39
|
+
tilesetName
|
|
40
|
+
} = params;
|
|
41
|
+
const fullOutputPath = (0, _fileUtils.getAbsoluteFilePath)(outputPath);
|
|
42
|
+
try {
|
|
43
|
+
if (slpk) {
|
|
44
|
+
const slpkPath = (0, _path.join)(fullOutputPath, "".concat(tilesetName, ".slpk"));
|
|
45
|
+
const stat = await _fs.promises.stat(slpkPath);
|
|
46
|
+
return stat.size;
|
|
47
|
+
}
|
|
48
|
+
const directoryPath = (0, _path.join)(fullOutputPath, tilesetName);
|
|
49
|
+
const totalSize = await getTotalFilesSize(directoryPath);
|
|
50
|
+
return totalSize;
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.log('Calculate file sizes error: ', error);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
85
55
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_context2.prev = 5;
|
|
99
|
-
_iterator.s();
|
|
100
|
-
case 7:
|
|
101
|
-
if ((_step = _iterator.n()).done) {
|
|
102
|
-
_context2.next = 22;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
file = _step.value;
|
|
106
|
-
_context2.next = 11;
|
|
107
|
-
return _fs.promises.stat((0, _path.join)(dirPath, file));
|
|
108
|
-
case 11:
|
|
109
|
-
fileStat = _context2.sent;
|
|
110
|
-
if (!fileStat.isDirectory()) {
|
|
111
|
-
_context2.next = 19;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
_context2.t0 = totalFileSize;
|
|
115
|
-
_context2.next = 16;
|
|
116
|
-
return getTotalFilesSize((0, _path.join)(dirPath, file));
|
|
117
|
-
case 16:
|
|
118
|
-
totalFileSize = _context2.t0 += _context2.sent;
|
|
119
|
-
_context2.next = 20;
|
|
120
|
-
break;
|
|
121
|
-
case 19:
|
|
122
|
-
totalFileSize += fileStat.size;
|
|
123
|
-
case 20:
|
|
124
|
-
_context2.next = 7;
|
|
125
|
-
break;
|
|
126
|
-
case 22:
|
|
127
|
-
_context2.next = 27;
|
|
128
|
-
break;
|
|
129
|
-
case 24:
|
|
130
|
-
_context2.prev = 24;
|
|
131
|
-
_context2.t1 = _context2["catch"](5);
|
|
132
|
-
_iterator.e(_context2.t1);
|
|
133
|
-
case 27:
|
|
134
|
-
_context2.prev = 27;
|
|
135
|
-
_iterator.f();
|
|
136
|
-
return _context2.finish(27);
|
|
137
|
-
case 30:
|
|
138
|
-
return _context2.abrupt("return", totalFileSize);
|
|
139
|
-
case 31:
|
|
140
|
-
case "end":
|
|
141
|
-
return _context2.stop();
|
|
142
|
-
}
|
|
143
|
-
}, _callee2, null, [[5, 24, 27, 30]]);
|
|
144
|
-
}));
|
|
145
|
-
return _getTotalFilesSize.apply(this, arguments);
|
|
56
|
+
async function getTotalFilesSize(dirPath) {
|
|
57
|
+
let totalFileSize = 0;
|
|
58
|
+
const files = await _fs.promises.readdir(dirPath);
|
|
59
|
+
for (const file of files) {
|
|
60
|
+
const fileStat = await _fs.promises.stat((0, _path.join)(dirPath, file));
|
|
61
|
+
if (fileStat.isDirectory()) {
|
|
62
|
+
totalFileSize += await getTotalFilesSize((0, _path.join)(dirPath, file));
|
|
63
|
+
} else {
|
|
64
|
+
totalFileSize += fileStat.size;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return totalFileSize;
|
|
146
68
|
}
|
|
147
69
|
//# sourceMappingURL=statistic-utills.js.map
|