@loaders.gl/tile-converter 4.4.0-alpha.1 → 4.4.0-alpha.9
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/converter.min.cjs +89 -98
- package/dist/i3s-server/bin/i3s-server.min.cjs +78 -78
- package/package.json +17 -17
- package/src/3d-tiles-converter/3d-tiles-converter.ts +11 -7
- package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -5
- package/src/converter-cli.ts +2 -2
- package/src/i3s-converter/helpers/geometry-converter.ts +17 -1
- package/src/i3s-converter/helpers/load-3d-tiles.ts +24 -9
- package/src/i3s-converter/i3s-converter.ts +25 -9
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/lib/utils/compress-util.ts +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -115
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -388
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts +0 -88
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js +0 -380
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -13
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -19
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +0 -37
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -98
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +0 -10
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +0 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -50
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +0 -15
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +0 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -39
- package/dist/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -2
- package/dist/converter-cli.d.ts +0 -2
- package/dist/converter-cli.d.ts.map +0 -1
- package/dist/converter-cli.js +0 -290
- package/dist/deps-installer/deps-installer.d.ts +0 -19
- package/dist/deps-installer/deps-installer.d.ts.map +0 -1
- package/dist/deps-installer/deps-installer.js +0 -95
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +0 -84
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +0 -219
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +0 -26
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -165
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +0 -39
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -118
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +0 -9
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -21
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +0 -54
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -193
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +0 -8
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -226
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +0 -60
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1309
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +0 -28
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -122
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +0 -33
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -121
- package/dist/i3s-converter/helpers/node-debug.d.ts +0 -8
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-debug.js +0 -116
- package/dist/i3s-converter/helpers/node-index-document.d.ts +0 -111
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-index-document.js +0 -269
- package/dist/i3s-converter/helpers/node-pages.d.ts +0 -156
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/node-pages.js +0 -285
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +0 -22
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -104
- package/dist/i3s-converter/helpers/progress.d.ts +0 -90
- package/dist/i3s-converter/helpers/progress.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/progress.js +0 -148
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +0 -32
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +0 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +0 -34
- package/dist/i3s-converter/i3s-converter.d.ts +0 -312
- package/dist/i3s-converter/i3s-converter.d.ts.map +0 -1
- package/dist/i3s-converter/i3s-converter.js +0 -1191
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +0 -7
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -80
- package/dist/i3s-converter/json-templates/layers.d.ts +0 -70
- package/dist/i3s-converter/json-templates/layers.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/layers.js +0 -132
- package/dist/i3s-converter/json-templates/metadata.d.ts +0 -22
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/metadata.js +0 -21
- package/dist/i3s-converter/json-templates/node.d.ts +0 -61
- package/dist/i3s-converter/json-templates/node.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/node.js +0 -82
- package/dist/i3s-converter/json-templates/scene-server.d.ts +0 -28
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/scene-server.js +0 -27
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +0 -14
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -122
- package/dist/i3s-converter/json-templates/store.d.ts +0 -95
- package/dist/i3s-converter/json-templates/store.d.ts.map +0 -1
- package/dist/i3s-converter/json-templates/store.js +0 -100
- package/dist/i3s-converter/types.d.ts +0 -226
- package/dist/i3s-converter/types.d.ts.map +0 -1
- package/dist/i3s-converter/types.js +0 -37
- package/dist/i3s-server/app.d.ts +0 -3
- package/dist/i3s-server/app.d.ts.map +0 -1
- package/dist/i3s-server/app.js +0 -31
- package/dist/i3s-server/bin/www.d.ts +0 -3
- package/dist/i3s-server/bin/www.d.ts.map +0 -1
- package/dist/i3s-server/bin/www.js +0 -46
- package/dist/i3s-server/controllers/slpk-controller.d.ts +0 -13
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +0 -1
- package/dist/i3s-server/controllers/slpk-controller.js +0 -32
- package/dist/i3s-server/routes/slpk-router.d.ts +0 -3
- package/dist/i3s-server/routes/slpk-router.d.ts.map +0 -1
- package/dist/i3s-server/routes/slpk-router.js +0 -40
- package/dist/i3s-server/utils/create-scene-server.d.ts +0 -17
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +0 -1
- package/dist/i3s-server/utils/create-scene-server.js +0 -18
- package/dist/i3s-server/utils/server-utils.d.ts +0 -21
- package/dist/i3s-server/utils/server-utils.d.ts.map +0 -1
- package/dist/i3s-server/utils/server-utils.js +0 -60
- package/dist/index.cjs +0 -6228
- package/dist/index.cjs.map +0 -7
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +0 -463
- package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +0 -1
- package/dist/lib/json-schemas/conversion-dump-json-schema.js +0 -285
- package/dist/lib/utils/cli-utils.d.ts +0 -34
- package/dist/lib/utils/cli-utils.d.ts.map +0 -1
- package/dist/lib/utils/cli-utils.js +0 -76
- package/dist/lib/utils/compress-util.d.ts +0 -8
- package/dist/lib/utils/compress-util.d.ts.map +0 -1
- package/dist/lib/utils/compress-util.js +0 -25
- package/dist/lib/utils/conversion-dump.d.ts +0 -147
- package/dist/lib/utils/conversion-dump.d.ts.map +0 -1
- package/dist/lib/utils/conversion-dump.js +0 -257
- package/dist/lib/utils/file-utils.d.ts +0 -57
- package/dist/lib/utils/file-utils.d.ts.map +0 -1
- package/dist/lib/utils/file-utils.js +0 -140
- package/dist/lib/utils/geometry-utils.d.ts +0 -9
- package/dist/lib/utils/geometry-utils.d.ts.map +0 -1
- package/dist/lib/utils/geometry-utils.js +0 -14
- package/dist/lib/utils/lod-conversion-utils.d.ts +0 -42
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +0 -1
- package/dist/lib/utils/lod-conversion-utils.js +0 -71
- package/dist/lib/utils/queue.d.ts +0 -7
- package/dist/lib/utils/queue.d.ts.map +0 -1
- package/dist/lib/utils/queue.js +0 -14
- package/dist/lib/utils/statistic-utils.d.ts +0 -20
- package/dist/lib/utils/statistic-utils.d.ts.map +0 -1
- package/dist/lib/utils/statistic-utils.js +0 -88
- package/dist/lib/utils/write-queue.d.ts +0 -44
- package/dist/lib/utils/write-queue.d.ts.map +0 -1
- package/dist/lib/utils/write-queue.js +0 -82
- package/dist/pgm-loader.d.ts +0 -28
- package/dist/pgm-loader.d.ts.map +0 -1
- package/dist/pgm-loader.js +0 -24
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import transform from 'json-map-transform';
|
|
3
|
-
import { METADATA as metadataTemplate } from "../json-templates/metadata.js";
|
|
4
|
-
import { isFileExists, openJson } from "../../lib/utils/file-utils.js";
|
|
5
|
-
/**
|
|
6
|
-
* class NodePages - wrapper of nodePages array
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import {writeFile} from './helpers/write-file';
|
|
10
|
-
*
|
|
11
|
-
* // create an instance of the class
|
|
12
|
-
* const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
13
|
-
* ...
|
|
14
|
-
* // push root node
|
|
15
|
-
* const parent = await nodePages.push({
|
|
16
|
-
lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
|
|
17
|
-
obb: coordinates.obb,
|
|
18
|
-
children: []
|
|
19
|
-
});
|
|
20
|
-
* ...
|
|
21
|
-
* // push node with parent relation
|
|
22
|
-
* const nodeInPage = {
|
|
23
|
-
lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
|
|
24
|
-
obb: coordinates.obb,
|
|
25
|
-
children: [],
|
|
26
|
-
mesh: {
|
|
27
|
-
geometry: {
|
|
28
|
-
definition: 0
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
* const node = await this.nodePages.push(nodeInPage, parent.index);
|
|
33
|
-
* ...
|
|
34
|
-
* // save all the nodePages in the end of pushing all the nodes
|
|
35
|
-
* await this.nodePages.save(layers0path);
|
|
36
|
-
*/
|
|
37
|
-
export default class NodePages {
|
|
38
|
-
nodesPerPage;
|
|
39
|
-
nodesCounter;
|
|
40
|
-
writeFile;
|
|
41
|
-
converter;
|
|
42
|
-
nodePages;
|
|
43
|
-
length = 0;
|
|
44
|
-
/**
|
|
45
|
-
* @constructs
|
|
46
|
-
* Create a nodePages instance.
|
|
47
|
-
* @param writeFileFunc - function to save one nodePage into a file
|
|
48
|
-
* @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
|
|
49
|
-
*/
|
|
50
|
-
constructor(writeFileFunc, nodesPerPage, converter) {
|
|
51
|
-
this.nodesPerPage = nodesPerPage;
|
|
52
|
-
this.nodesCounter = 0;
|
|
53
|
-
// @ts-expect-error
|
|
54
|
-
this.nodePages = [{}];
|
|
55
|
-
this.nodePages[0].nodes = [];
|
|
56
|
-
this.writeFile = writeFileFunc;
|
|
57
|
-
this.converter = converter;
|
|
58
|
-
this.length = 0;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Setup function to save node pages
|
|
62
|
-
* @param func - function which should be used to save node pages
|
|
63
|
-
*/
|
|
64
|
-
useWriteFunction(func) {
|
|
65
|
-
this.writeFile = func;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get file path and file name of the node page with the particular id
|
|
69
|
-
* @param nodePageId - node page id
|
|
70
|
-
* @returns file path and file name
|
|
71
|
-
*/
|
|
72
|
-
getNodePageFileName(nodePageId) {
|
|
73
|
-
const filePath = join(this.converter.layers0Path, 'nodepages');
|
|
74
|
-
const fileName = `${nodePageId.toString()}.json`;
|
|
75
|
-
return { filePath, fileName };
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Load node page from a file on the disk
|
|
79
|
-
* @param nodePageId - node page id
|
|
80
|
-
* @returns - node page data
|
|
81
|
-
*/
|
|
82
|
-
async loadNodePage(nodePageId) {
|
|
83
|
-
const { filePath, fileName } = this.getNodePageFileName(nodePageId);
|
|
84
|
-
const fullName = join(filePath, fileName);
|
|
85
|
-
if (await isFileExists(fullName)) {
|
|
86
|
-
console.log(`load ${fullName}.`); // eslint-disable-line
|
|
87
|
-
return (await openJson(filePath, fileName));
|
|
88
|
-
}
|
|
89
|
-
return { nodes: [] };
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Get nodepage id by node id
|
|
93
|
-
* @param id node id
|
|
94
|
-
* @returns node page id
|
|
95
|
-
*/
|
|
96
|
-
getPageIndexByNodeId(id) {
|
|
97
|
-
return Math.floor(id / this.nodesPerPage);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get node page data by node id
|
|
101
|
-
* @param id node id
|
|
102
|
-
* @returns node page data
|
|
103
|
-
*/
|
|
104
|
-
async getPageByNodeId(id) {
|
|
105
|
-
const pageIndex = this.getPageIndexByNodeId(id);
|
|
106
|
-
if (this.converter.options.instantNodeWriting) {
|
|
107
|
-
return await this.loadNodePage(pageIndex);
|
|
108
|
-
}
|
|
109
|
-
return this.nodePages[pageIndex];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get the node by its end-to-end index
|
|
113
|
-
* @param id - end-to-end index of the node
|
|
114
|
-
* @return the node object
|
|
115
|
-
*/
|
|
116
|
-
async getNodeById(id, nodePage) {
|
|
117
|
-
const nodeIndex = id % this.nodesPerPage;
|
|
118
|
-
nodePage = nodePage || (await this.getPageByNodeId(id));
|
|
119
|
-
return nodePage.nodes[nodeIndex];
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Add a child id into the parent node.children array
|
|
123
|
-
* @param parentId - end-to-end parent node index
|
|
124
|
-
* @param childId - end-to-end child node index
|
|
125
|
-
*/
|
|
126
|
-
async addChildRelation(parentId, childId) {
|
|
127
|
-
if (parentId === null || parentId === undefined) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const parentNode = await this.getNodeById(parentId);
|
|
131
|
-
parentNode.children?.push(childId);
|
|
132
|
-
await this.saveNode(parentNode);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Put new node in nodePages array
|
|
136
|
-
* @param node - node object
|
|
137
|
-
* @param parentId - index of parent node
|
|
138
|
-
* @return
|
|
139
|
-
*/
|
|
140
|
-
async push(node, parentId) {
|
|
141
|
-
node.index = this.nodesCounter++;
|
|
142
|
-
if (!this.converter.options.instantNodeWriting) {
|
|
143
|
-
let currentNodePage = this.nodePages[this.nodePages.length - 1];
|
|
144
|
-
if (currentNodePage.nodes.length === this.nodesPerPage) {
|
|
145
|
-
currentNodePage = { nodes: [] };
|
|
146
|
-
this.nodePages.push(currentNodePage);
|
|
147
|
-
}
|
|
148
|
-
currentNodePage.nodes.push(node);
|
|
149
|
-
}
|
|
150
|
-
await this.addChildRelation(parentId, node.index);
|
|
151
|
-
NodePages.updateResourceInMesh(node);
|
|
152
|
-
await this.saveNode(node);
|
|
153
|
-
return node;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Save node to the file on the disk
|
|
157
|
-
* @param node - node data
|
|
158
|
-
*/
|
|
159
|
-
async saveNode(node) {
|
|
160
|
-
if (!this.converter.options.instantNodeWriting) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const nodePageIndex = this.getPageIndexByNodeId(node.index);
|
|
164
|
-
const nodePage = await this.getPageByNodeId(node.index);
|
|
165
|
-
const { filePath, fileName } = this.getNodePageFileName(nodePageIndex);
|
|
166
|
-
const nodeToUpdate = await this.getNodeById(node.index, nodePage);
|
|
167
|
-
if (nodeToUpdate) {
|
|
168
|
-
NodePages.updateAll(nodeToUpdate, node);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
nodePage.nodes.push(node);
|
|
172
|
-
}
|
|
173
|
-
const nodePageStr = JSON.stringify(nodePage);
|
|
174
|
-
await this.converter.writeQueue.enqueue({
|
|
175
|
-
archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
|
|
176
|
-
writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
|
|
177
|
-
}, true);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Save metadata file (for slpk only)
|
|
181
|
-
*/
|
|
182
|
-
async saveMetadata() {
|
|
183
|
-
const metadata = transform({ nodeCount: this.nodesCounter }, metadataTemplate());
|
|
184
|
-
const compress = false;
|
|
185
|
-
await this.converter.writeQueue.enqueue({
|
|
186
|
-
archiveKey: 'metadata.json',
|
|
187
|
-
writePromise: () => this.writeFile(this.converter.layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Save all the node pages
|
|
192
|
-
* Run this method when all nodes is pushed in nodePages
|
|
193
|
-
*/
|
|
194
|
-
async save() {
|
|
195
|
-
if (this.converter.options.instantNodeWriting) {
|
|
196
|
-
await this.saveMetadata();
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
for (const [index, nodePage] of this.nodePages.entries()) {
|
|
200
|
-
const nodePageStr = JSON.stringify(nodePage);
|
|
201
|
-
const slpkPath = join(this.converter.layers0Path, 'nodepages');
|
|
202
|
-
await this.converter.writeQueue.enqueue({
|
|
203
|
-
archiveKey: `nodePages/${index.toString()}.json.gz`,
|
|
204
|
-
writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
await this.saveMetadata();
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Update resource index in node.mesh object
|
|
211
|
-
* @param node - node object
|
|
212
|
-
*/
|
|
213
|
-
static updateResourceInMesh(node) {
|
|
214
|
-
if (node.mesh && isFinite(node.index)) {
|
|
215
|
-
node.mesh.geometry.resource = node.index;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Update all fields in the node excluding id
|
|
220
|
-
* @param node - node object
|
|
221
|
-
* @param data - NodeInPage data to replace original data
|
|
222
|
-
*/
|
|
223
|
-
static updateAll(node, data) {
|
|
224
|
-
Object.assign(node, data, { index: node.index });
|
|
225
|
-
NodePages.updateResourceInMesh(node);
|
|
226
|
-
return node;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Update material in node.mesh object by node id
|
|
230
|
-
* @param id - end-to-end index of the node
|
|
231
|
-
* @param materialId - id from scene layer materialDefinitions
|
|
232
|
-
*/
|
|
233
|
-
static updateMaterialByNodeId(node, materialId) {
|
|
234
|
-
if (!node.mesh) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
node.mesh.material = {
|
|
238
|
-
definition: materialId,
|
|
239
|
-
resource: node.index
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Update vertexCount in node.mesh.geometry object by node id
|
|
244
|
-
* @param id - end-to-end index of the node
|
|
245
|
-
* @param vertexCount - vertex count for particular node
|
|
246
|
-
*/
|
|
247
|
-
static updateVertexCountByNodeId(node, vertexCount) {
|
|
248
|
-
if (!node.mesh) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
node.mesh.geometry.vertexCount = vertexCount;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Update resource in node.mesh.attribute object by node id
|
|
255
|
-
* @param node - node object
|
|
256
|
-
*/
|
|
257
|
-
static updateNodeAttributeByNodeId(node) {
|
|
258
|
-
if (!node.mesh || !node.index) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
node.mesh.attribute.resource = node.index;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Update featureCount in node.mesh.geometry object by node id
|
|
265
|
-
* @param node - node object
|
|
266
|
-
* @param featureCount - features count of the node
|
|
267
|
-
*/
|
|
268
|
-
static updateFeatureCountByNodeId(node, featureCount) {
|
|
269
|
-
if (!node.mesh) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
node.mesh.geometry.featureCount = featureCount;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Update texelCountHint in node.mesh.material object by node id
|
|
276
|
-
* @param node - node object
|
|
277
|
-
* @param texelCountHint - texelCountHint of particular node
|
|
278
|
-
*/
|
|
279
|
-
static updateTexelCountHintByNodeId(node, texelCountHint) {
|
|
280
|
-
if (!node.mesh || !node.mesh.material) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
node.mesh.material.texelCountHint = texelCountHint;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
|
|
2
|
-
import { GLTFPrimitiveModeString, PreprocessData } from "../types.js";
|
|
3
|
-
/**
|
|
4
|
-
* glTF primitive modes
|
|
5
|
-
* @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
|
|
6
|
-
*/
|
|
7
|
-
export declare const GLTF_PRIMITIVE_MODES: GLTFPrimitiveModeString[];
|
|
8
|
-
/**
|
|
9
|
-
* Analyze tile content. This function is used during preprocess stage of
|
|
10
|
-
* conversion
|
|
11
|
-
* @param tileContent - 3DTiles tile content ArrayBuffer
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare const analyzeTileContent: (tileContent: Tiles3DTileContent | null) => Promise<PreprocessData>;
|
|
15
|
-
/**
|
|
16
|
-
* Merge object2 into object1
|
|
17
|
-
* @param object1
|
|
18
|
-
* @param object2
|
|
19
|
-
* @returns nothing
|
|
20
|
-
*/
|
|
21
|
-
export declare const mergePreprocessData: (object1: PreprocessData, object2: PreprocessData) => void;
|
|
22
|
-
//# sourceMappingURL=preprocess-3d-tiles.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,oBAAiB;AAWjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BAQhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAChB,kBAAkB,GAAG,IAAI,KACrC,OAAO,CAAC,cAAc,CAuBxB,CAAC;AAwDF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,cAAc,WAAW,cAAc,KAAG,IAUtF,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { GLTFPrimitiveModeString } from "../types.js";
|
|
2
|
-
import { EXT_STRUCTURAL_METADATA, GLTFLoader, EXT_FEATURE_METADATA } from '@loaders.gl/gltf';
|
|
3
|
-
import { parse } from '@loaders.gl/core';
|
|
4
|
-
/**
|
|
5
|
-
* glTF primitive modes
|
|
6
|
-
* @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
|
|
7
|
-
*/
|
|
8
|
-
export const GLTF_PRIMITIVE_MODES = [
|
|
9
|
-
GLTFPrimitiveModeString.POINTS, // 0
|
|
10
|
-
GLTFPrimitiveModeString.LINES, // 1
|
|
11
|
-
GLTFPrimitiveModeString.LINE_LOOP, // 2
|
|
12
|
-
GLTFPrimitiveModeString.LINE_STRIP, // 3
|
|
13
|
-
GLTFPrimitiveModeString.TRIANGLES, // 4
|
|
14
|
-
GLTFPrimitiveModeString.TRIANGLE_STRIP, // 5
|
|
15
|
-
GLTFPrimitiveModeString.TRIANGLE_FAN // 6
|
|
16
|
-
];
|
|
17
|
-
/**
|
|
18
|
-
* Analyze tile content. This function is used during preprocess stage of
|
|
19
|
-
* conversion
|
|
20
|
-
* @param tileContent - 3DTiles tile content ArrayBuffer
|
|
21
|
-
* @returns
|
|
22
|
-
*/
|
|
23
|
-
export const analyzeTileContent = async (tileContent) => {
|
|
24
|
-
const defaultResult = {
|
|
25
|
-
meshTopologyTypes: new Set(),
|
|
26
|
-
metadataClasses: new Set()
|
|
27
|
-
};
|
|
28
|
-
if (!tileContent?.gltfArrayBuffer) {
|
|
29
|
-
return defaultResult;
|
|
30
|
-
}
|
|
31
|
-
const gltfData = await parse(tileContent.gltfArrayBuffer, GLTFLoader, {
|
|
32
|
-
gltf: { normalize: false, loadBuffers: false, loadImages: false, decompressMeshes: false }
|
|
33
|
-
});
|
|
34
|
-
const gltf = gltfData.json;
|
|
35
|
-
if (!gltf) {
|
|
36
|
-
return defaultResult;
|
|
37
|
-
}
|
|
38
|
-
const meshTopologyTypes = getMeshTypesFromGLTF(gltf);
|
|
39
|
-
const metadataClasses = getMetadataClassesFromGLTF(gltf);
|
|
40
|
-
return {
|
|
41
|
-
meshTopologyTypes,
|
|
42
|
-
metadataClasses
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Get mesh topology types that the glb content has
|
|
47
|
-
* @param gltfJson - JSON part of GLB content
|
|
48
|
-
* @returns array of mesh types found
|
|
49
|
-
*/
|
|
50
|
-
const getMeshTypesFromGLTF = (gltfJson) => {
|
|
51
|
-
const result = new Set();
|
|
52
|
-
for (const mesh of gltfJson.meshes || []) {
|
|
53
|
-
for (const primitive of mesh.primitives) {
|
|
54
|
-
let { mode } = primitive;
|
|
55
|
-
if (typeof mode !== 'number') {
|
|
56
|
-
mode = 4; // Default is 4 - TRIANGLES
|
|
57
|
-
}
|
|
58
|
-
result.add(GLTF_PRIMITIVE_MODES[mode]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Get feature metadata classes from glTF
|
|
65
|
-
* The tileset might contain multiple metadata classes provided by EXT_feature_metadata and EXT_structural_metadata extensions.
|
|
66
|
-
* Every class is a set of properties. But I3S can consume only one set of properties.
|
|
67
|
-
* On the pre-process we collect all classes from the tileset in order to show the prompt to select one class for conversion to I3S.
|
|
68
|
-
* @param gltfJson - JSON part of GLB content
|
|
69
|
-
* @returns array of classes
|
|
70
|
-
*/
|
|
71
|
-
const getMetadataClassesFromGLTF = (gltfJson) => {
|
|
72
|
-
const result = new Set();
|
|
73
|
-
// Try to parse from EXT_feature_metadata
|
|
74
|
-
const extFeatureMetadataClasses = gltfJson.extensions?.[EXT_FEATURE_METADATA]?.schema?.classes;
|
|
75
|
-
if (extFeatureMetadataClasses) {
|
|
76
|
-
for (const classKey of Object.keys(extFeatureMetadataClasses)) {
|
|
77
|
-
result.add(classKey);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Try to parse from EXT_structural_metadata
|
|
81
|
-
const extStructuralMetadataClasses = gltfJson.extensions?.[EXT_STRUCTURAL_METADATA]?.schema?.classes;
|
|
82
|
-
if (extStructuralMetadataClasses) {
|
|
83
|
-
for (const classKey of Object.keys(extStructuralMetadataClasses)) {
|
|
84
|
-
result.add(classKey);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return result;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Merge object2 into object1
|
|
91
|
-
* @param object1
|
|
92
|
-
* @param object2
|
|
93
|
-
* @returns nothing
|
|
94
|
-
*/
|
|
95
|
-
export const mergePreprocessData = (object1, object2) => {
|
|
96
|
-
// Merge topology mesh types info
|
|
97
|
-
for (const type of object2.meshTopologyTypes) {
|
|
98
|
-
object1.meshTopologyTypes.add(type);
|
|
99
|
-
}
|
|
100
|
-
// Merge feature metadata classes
|
|
101
|
-
for (const metadataClass of object2.metadataClasses) {
|
|
102
|
-
object1.metadataClasses.add(metadataClass);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements methods to keep track on the progress of a long process.
|
|
3
|
-
*/
|
|
4
|
-
export declare class Progress {
|
|
5
|
-
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
6
|
-
private _stepsTotal;
|
|
7
|
-
/** Amount of work already done */
|
|
8
|
-
private _stepsDone;
|
|
9
|
-
/** Time in milli-seconds when the process started */
|
|
10
|
-
private startTime;
|
|
11
|
-
/** Time in milli-seconds when the process stopped */
|
|
12
|
-
private stopTime;
|
|
13
|
-
/** Time in milli-seconds when stepsDone was updated */
|
|
14
|
-
private timeOfUpdatingStepsDone;
|
|
15
|
-
/** Time in milli-seconds spent for performing one step*/
|
|
16
|
-
private milliSecForOneStep;
|
|
17
|
-
private trust;
|
|
18
|
-
/**
|
|
19
|
-
* The number of digits to appear after decimal point in the string representation of the count of steps already done.
|
|
20
|
-
* It's calculated based on the total count of steps.
|
|
21
|
-
*/
|
|
22
|
-
private numberOfDigitsInPercentage;
|
|
23
|
-
/** Defines a threshold that is used to check if the process velocity can be consifered trust. */
|
|
24
|
-
private threshold;
|
|
25
|
-
/** Function that is used to get the time stamp */
|
|
26
|
-
private getTime;
|
|
27
|
-
constructor(options?: {
|
|
28
|
-
threshold?: number;
|
|
29
|
-
getTime?: () => bigint;
|
|
30
|
-
});
|
|
31
|
-
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
32
|
-
get stepsTotal(): number;
|
|
33
|
-
set stepsTotal(stepsTotal: number);
|
|
34
|
-
/** Amount of work already done */
|
|
35
|
-
get stepsDone(): number;
|
|
36
|
-
set stepsDone(stepsDone: number);
|
|
37
|
-
/**
|
|
38
|
-
* Saves the current time as we start monitoring the process.
|
|
39
|
-
*/
|
|
40
|
-
startMonitoring(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Saves the current time as we stop monitoring the process.
|
|
43
|
-
*/
|
|
44
|
-
stopMonitoring(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Gets percentage of the work already done.
|
|
47
|
-
* @returns percentage of the work already done.
|
|
48
|
-
*/
|
|
49
|
-
getPercent(): number | null;
|
|
50
|
-
/**
|
|
51
|
-
* Gets string representation of percentage of the work already done.
|
|
52
|
-
* @returns string representation of percentage or an empty string if the percetage value cannot be calculated.
|
|
53
|
-
*/
|
|
54
|
-
getPercentString(): string;
|
|
55
|
-
/**
|
|
56
|
-
* Gets the time elapsed since the monitoring started
|
|
57
|
-
* @returns Number of milliseconds elapsed
|
|
58
|
-
*/
|
|
59
|
-
getTimeCurrentlyElapsed(): number;
|
|
60
|
-
/**
|
|
61
|
-
* Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
62
|
-
* @returns Number of milliseconds remaining
|
|
63
|
-
*/
|
|
64
|
-
getTimeRemaining(): {
|
|
65
|
-
timeRemaining: number;
|
|
66
|
-
trust: boolean;
|
|
67
|
-
} | null;
|
|
68
|
-
/**
|
|
69
|
-
* Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
70
|
-
* @returns string representation of the time remaining.
|
|
71
|
-
* It's an empty string if the time cannot be pedicted or it's still being calculated.
|
|
72
|
-
*/
|
|
73
|
-
getTimeRemainingString(): string;
|
|
74
|
-
/**
|
|
75
|
-
* Check if the computed velociy of the process can be considered trust.
|
|
76
|
-
* At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,
|
|
77
|
-
* which results in huge deviation of the cumputed velocity of the process.
|
|
78
|
-
* It makes sense to perform the check before reporting the time remainig so the end user is not confused.
|
|
79
|
-
* @param current - current value
|
|
80
|
-
* @param previous - previous value
|
|
81
|
-
* @returns true if the computed velociy can be considered trust, or false otherwise
|
|
82
|
-
*/
|
|
83
|
-
private isVelocityTrust;
|
|
84
|
-
/**
|
|
85
|
-
* Gets current time in milliseconds.
|
|
86
|
-
* @returns current time in milliseconds.
|
|
87
|
-
*/
|
|
88
|
-
private getCurrentTimeInMilliSeconds;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/progress.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,QAAQ;IACnB,oFAAoF;IACpF,OAAO,CAAC,WAAW,CAAa;IAChC,kCAAkC;IAClC,OAAO,CAAC,UAAU,CAAa;IAC/B,qDAAqD;IACrD,OAAO,CAAC,SAAS,CAAa;IAC9B,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAAa;IAC7B,uDAAuD;IACvD,OAAO,CAAC,uBAAuB,CAAa;IAC5C,yDAAyD;IACzD,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,KAAK,CAAkB;IAC/B;;;OAGG;IACH,OAAO,CAAC,0BAA0B,CAAa;IAC/C,iGAAiG;IACjG,OAAO,CAAC,SAAS,CAAS;IAC1B,kDAAkD;IAClD,OAAO,CAAC,OAAO,CAAe;gBAElB,OAAO,GAAE;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,MAAM,CAAA;KAAM;IAMtE,oFAAoF;IACpF,IAAI,UAAU,WAEb;IAED,IAAI,UAAU,CAAC,UAAU,QAAA,EAIxB;IAED,kCAAkC;IAClC,IAAI,SAAS,WAEZ;IAED,IAAI,SAAS,CAAC,SAAS,QAAA,EAUtB;IAED;;OAEG;IACH,eAAe;IASf;;OAEG;IACH,cAAc;IAId;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,IAAI;IAQ3B;;;OAGG;IACH,gBAAgB;IAKhB;;;OAGG;IACH,uBAAuB,IAAI,MAAM;IAMjC;;;OAGG;IACH,gBAAgB,IAAI;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAC,GAAG,IAAI;IAUlE;;;;OAIG;IACH,sBAAsB,IAAI,MAAM;IAKhC;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAQvB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;CAIrC"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import process from 'process';
|
|
2
|
-
import { timeConverter } from "../../lib/utils/statistic-utils.js";
|
|
3
|
-
/** Defines a threshold that is used to check if the process velocity can be consifered trust. */
|
|
4
|
-
const THRESHOLD_DEFAULT = 0.2;
|
|
5
|
-
/**
|
|
6
|
-
* Implements methods to keep track on the progress of a long process.
|
|
7
|
-
*/
|
|
8
|
-
export class Progress {
|
|
9
|
-
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
10
|
-
_stepsTotal = 0;
|
|
11
|
-
/** Amount of work already done */
|
|
12
|
-
_stepsDone = 0;
|
|
13
|
-
/** Time in milli-seconds when the process started */
|
|
14
|
-
startTime = 0;
|
|
15
|
-
/** Time in milli-seconds when the process stopped */
|
|
16
|
-
stopTime = 0;
|
|
17
|
-
/** Time in milli-seconds when stepsDone was updated */
|
|
18
|
-
timeOfUpdatingStepsDone = 0;
|
|
19
|
-
/** Time in milli-seconds spent for performing one step*/
|
|
20
|
-
milliSecForOneStep = 0;
|
|
21
|
-
trust = false;
|
|
22
|
-
/**
|
|
23
|
-
* The number of digits to appear after decimal point in the string representation of the count of steps already done.
|
|
24
|
-
* It's calculated based on the total count of steps.
|
|
25
|
-
*/
|
|
26
|
-
numberOfDigitsInPercentage = 0;
|
|
27
|
-
/** Defines a threshold that is used to check if the process velocity can be consifered trust. */
|
|
28
|
-
threshold;
|
|
29
|
-
/** Function that is used to get the time stamp */
|
|
30
|
-
getTime;
|
|
31
|
-
constructor(options = {}) {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
33
|
-
this.getTime = options.getTime || process.hrtime.bigint;
|
|
34
|
-
this.threshold = options.threshold || THRESHOLD_DEFAULT;
|
|
35
|
-
}
|
|
36
|
-
/** Total amount of work, e.g. number of files to save or number of bytes to send */
|
|
37
|
-
get stepsTotal() {
|
|
38
|
-
return this._stepsTotal;
|
|
39
|
-
}
|
|
40
|
-
set stepsTotal(stepsTotal) {
|
|
41
|
-
this._stepsTotal = stepsTotal;
|
|
42
|
-
this.numberOfDigitsInPercentage =
|
|
43
|
-
this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;
|
|
44
|
-
}
|
|
45
|
-
/** Amount of work already done */
|
|
46
|
-
get stepsDone() {
|
|
47
|
-
return this._stepsDone;
|
|
48
|
-
}
|
|
49
|
-
set stepsDone(stepsDone) {
|
|
50
|
-
this._stepsDone = stepsDone;
|
|
51
|
-
this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();
|
|
52
|
-
if (this._stepsDone) {
|
|
53
|
-
const diff = this.timeOfUpdatingStepsDone - this.startTime;
|
|
54
|
-
const milliSecForOneStep = diff / this._stepsDone;
|
|
55
|
-
this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);
|
|
56
|
-
this.milliSecForOneStep = milliSecForOneStep;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Saves the current time as we start monitoring the process.
|
|
61
|
-
*/
|
|
62
|
-
startMonitoring() {
|
|
63
|
-
this.startTime = this.getCurrentTimeInMilliSeconds();
|
|
64
|
-
this.milliSecForOneStep = 0;
|
|
65
|
-
this.trust = false;
|
|
66
|
-
this.timeOfUpdatingStepsDone = 0;
|
|
67
|
-
this.stopTime = 0;
|
|
68
|
-
this.stepsDone = 0;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Saves the current time as we stop monitoring the process.
|
|
72
|
-
*/
|
|
73
|
-
stopMonitoring() {
|
|
74
|
-
this.stopTime = this.getCurrentTimeInMilliSeconds();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Gets percentage of the work already done.
|
|
78
|
-
* @returns percentage of the work already done.
|
|
79
|
-
*/
|
|
80
|
-
getPercent() {
|
|
81
|
-
if (!this._stepsTotal) {
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
const percent = (this._stepsDone / this._stepsTotal) * 100.0;
|
|
85
|
-
return percent;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Gets string representation of percentage of the work already done.
|
|
89
|
-
* @returns string representation of percentage or an empty string if the percetage value cannot be calculated.
|
|
90
|
-
*/
|
|
91
|
-
getPercentString() {
|
|
92
|
-
const percent = this.getPercent();
|
|
93
|
-
return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : '';
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Gets the time elapsed since the monitoring started
|
|
97
|
-
* @returns Number of milliseconds elapsed
|
|
98
|
-
*/
|
|
99
|
-
getTimeCurrentlyElapsed() {
|
|
100
|
-
const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();
|
|
101
|
-
const diff = currentTime - this.startTime;
|
|
102
|
-
return diff;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
106
|
-
* @returns Number of milliseconds remaining
|
|
107
|
-
*/
|
|
108
|
-
getTimeRemaining() {
|
|
109
|
-
if (!this._stepsTotal || !this._stepsDone || !this.startTime) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
|
|
113
|
-
return { timeRemaining: timeRemainingInMilliSeconds, trust: this.trust };
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.
|
|
117
|
-
* @returns string representation of the time remaining.
|
|
118
|
-
* It's an empty string if the time cannot be pedicted or it's still being calculated.
|
|
119
|
-
*/
|
|
120
|
-
getTimeRemainingString() {
|
|
121
|
-
const timeRemainingObject = this.getTimeRemaining();
|
|
122
|
-
return timeRemainingObject?.trust ? timeConverter(timeRemainingObject.timeRemaining) : '';
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Check if the computed velociy of the process can be considered trust.
|
|
126
|
-
* At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,
|
|
127
|
-
* which results in huge deviation of the cumputed velocity of the process.
|
|
128
|
-
* It makes sense to perform the check before reporting the time remainig so the end user is not confused.
|
|
129
|
-
* @param current - current value
|
|
130
|
-
* @param previous - previous value
|
|
131
|
-
* @returns true if the computed velociy can be considered trust, or false otherwise
|
|
132
|
-
*/
|
|
133
|
-
isVelocityTrust(current, previous) {
|
|
134
|
-
if (previous) {
|
|
135
|
-
const dev = Math.abs((current - previous) / previous);
|
|
136
|
-
return dev < this.threshold;
|
|
137
|
-
}
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Gets current time in milliseconds.
|
|
142
|
-
* @returns current time in milliseconds.
|
|
143
|
-
*/
|
|
144
|
-
getCurrentTimeInMilliSeconds() {
|
|
145
|
-
// process.hrtime.bigint() returns the time in nanoseconds. We need the time in milliseconds.
|
|
146
|
-
return Number(this.getTime() / BigInt(1e6));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Tiles3DTileJSONPostprocessed } from '@loaders.gl/3d-tiles';
|
|
2
|
-
import { NodeIndexDocument } from "./node-index-document.js";
|
|
3
|
-
import { Matrix4 } from '@math.gl/core';
|
|
4
|
-
/** Traversal props for the conversion stage */
|
|
5
|
-
export type TraversalConversionProps = {
|
|
6
|
-
/** Transformation matrix for the specific tile */
|
|
7
|
-
transform: Matrix4;
|
|
8
|
-
/** Parent nodes of the converted tile. Multiple nodes can be if one tile is converted to multiple nodes*/
|
|
9
|
-
parentNodes: NodeIndexDocument[];
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Travesal of 3DTile tiles tree with making specific actions with each tile
|
|
13
|
-
* @param tile - 3DTiles tile JSON metadata
|
|
14
|
-
* @param traversalProps - traversal props used to pass data through recursive calls
|
|
15
|
-
* @param processTile - callback to make some actions with the current tile
|
|
16
|
-
* @param postprocessTile - callback to make some action after processing of the current tile and all the subtree
|
|
17
|
-
* @param maxDepth - max recursive calls number the travesal function will do. If not set, the traversal function will
|
|
18
|
-
* go through all the tree.
|
|
19
|
-
* This value is used to limit the convertion with only partial number of levels of the tileset
|
|
20
|
-
* @param level - counter to keep recursive calls number of the tiles tree. This value used to be able to break
|
|
21
|
-
* traversal at the some level of the tree
|
|
22
|
-
* @returns void
|
|
23
|
-
*/
|
|
24
|
-
export declare const traverseDatasetWith: <TProps>({ tile, traversalProps, processTile, postprocessTile, maxDepth, level }: {
|
|
25
|
-
tile: Tiles3DTileJSONPostprocessed;
|
|
26
|
-
traversalProps: TProps;
|
|
27
|
-
processTile: (tile: Tiles3DTileJSONPostprocessed, traversalProps: TProps) => Promise<TProps>;
|
|
28
|
-
postprocessTile?: (processResults: TProps[], currentTraversalProps: TProps) => Promise<void>;
|
|
29
|
-
maxDepth?: number;
|
|
30
|
-
level?: number;
|
|
31
|
-
}) => Promise<void>;
|
|
32
|
-
//# sourceMappingURL=tileset-traversal.d.ts.map
|