@loaders.gl/tile-converter 3.4.11 → 3.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/converter.min.js +58 -58
  3. package/dist/dist.min.js +11 -26
  4. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  5. package/dist/es5/deps-installer/deps-installer.js +1 -1
  6. package/dist/es5/i3s-attributes-worker.js +1 -1
  7. package/dist/es5/pgm-loader.js +1 -1
  8. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  9. package/dist/esm/deps-installer/deps-installer.js +1 -1
  10. package/dist/esm/i3s-attributes-worker.js +1 -1
  11. package/dist/esm/pgm-loader.js +1 -1
  12. package/package.json +15 -15
  13. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -287
  14. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -282
  15. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
  17. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
  18. package/dist/bundle.js +0 -5
  19. package/dist/constants.js +0 -4
  20. package/dist/converter-cli.js +0 -280
  21. package/dist/deps-installer/deps-installer.js +0 -63
  22. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -141
  23. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -124
  24. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
  25. package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
  26. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
  27. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1195
  28. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -88
  29. package/dist/i3s-converter/helpers/node-debug.js +0 -120
  30. package/dist/i3s-converter/helpers/node-index-document.js +0 -250
  31. package/dist/i3s-converter/helpers/node-pages.js +0 -316
  32. package/dist/i3s-converter/i3s-converter.js +0 -890
  33. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
  34. package/dist/i3s-converter/json-templates/layers.js +0 -139
  35. package/dist/i3s-converter/json-templates/metadata.js +0 -25
  36. package/dist/i3s-converter/json-templates/node.js +0 -89
  37. package/dist/i3s-converter/json-templates/scene-server.js +0 -31
  38. package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
  39. package/dist/i3s-converter/json-templates/store.js +0 -103
  40. package/dist/i3s-converter/types.js +0 -2
  41. package/dist/i3s-server/app.js +0 -14
  42. package/dist/i3s-server/controllers/index-controller.js +0 -23
  43. package/dist/i3s-server/routes/index.js +0 -16
  44. package/dist/index.js +0 -10
  45. package/dist/lib/utils/compress-util.js +0 -257
  46. package/dist/lib/utils/file-utils.js +0 -138
  47. package/dist/lib/utils/lod-conversion-utils.js +0 -76
  48. package/dist/lib/utils/queue.js +0 -18
  49. package/dist/lib/utils/statistic-utills.js +0 -64
  50. package/dist/lib/utils/write-queue.js +0 -80
  51. package/dist/pgm-loader.js +0 -24
  52. package/dist/workers/3d-tiles-attributes-worker.js +0 -9
  53. package/dist/workers/i3s-attributes-worker.js +0 -5
@@ -1,316 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = require("path");
7
- const json_map_transform_1 = __importDefault(require("json-map-transform"));
8
- const metadata_1 = require("../json-templates/metadata");
9
- const file_utils_1 = require("../../lib/utils/file-utils");
10
- /**
11
- * class NodePages - wrapper of nodePages array
12
- *
13
- * @example
14
- * import {writeFile} from './helpers/write-file';
15
- *
16
- * // create an instance of the class
17
- * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
18
- * ...
19
- * // push root node
20
- * const parent = await nodePages.push({
21
- lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
22
- obb: coordinates.obb,
23
- children: []
24
- });
25
- * ...
26
- * // push node with parent relation
27
- * const nodeInPage = {
28
- lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,
29
- obb: coordinates.obb,
30
- children: [],
31
- mesh: {
32
- geometry: {
33
- definition: 0
34
- }
35
- }
36
- };
37
- * const node = await this.nodePages.push(nodeInPage, parent.index);
38
- * ...
39
- * // save all the nodePages in the end of pushing all the nodes
40
- * await this.nodePages.save(layers0path);
41
- */
42
- class NodePages {
43
- /**
44
- * @constructs
45
- * Create a nodePages instance.
46
- * @param writeFileFunc - function to save one nodePage into a file
47
- * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met
48
- */
49
- constructor(writeFileFunc, nodesPerPage, converter) {
50
- this.length = 0;
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
- let filePath;
74
- let fileName;
75
- if (this.converter.options.slpk) {
76
- filePath = (0, path_1.join)(this.converter.layers0Path, 'nodepages');
77
- fileName = `${nodePageId.toString()}.json`;
78
- }
79
- else {
80
- filePath = (0, path_1.join)(this.converter.layers0Path, 'nodepages', nodePageId.toString());
81
- fileName = 'index.json';
82
- }
83
- return { filePath, fileName };
84
- }
85
- /**
86
- * Load node page from a file on the disk
87
- * @param nodePageId - node page id
88
- * @returns - node page data
89
- */
90
- async loadNodePage(nodePageId) {
91
- const { filePath, fileName } = this.getNodePageFileName(nodePageId);
92
- const fullName = (0, path_1.join)(filePath, fileName);
93
- if (await (0, file_utils_1.isFileExists)(fullName)) {
94
- console.log(`load ${fullName}.`); // eslint-disable-line
95
- return (await (0, file_utils_1.openJson)(filePath, fileName));
96
- }
97
- else {
98
- return { nodes: [] };
99
- }
100
- }
101
- /**
102
- * Get nodepage id by node id
103
- * @param id node id
104
- * @returns node page id
105
- */
106
- getPageIndexByNodeId(id) {
107
- return Math.floor(id / this.nodesPerPage);
108
- }
109
- /**
110
- * Get node page data by node id
111
- * @param id node id
112
- * @returns node page data
113
- */
114
- async getPageByNodeId(id) {
115
- const pageIndex = this.getPageIndexByNodeId(id);
116
- if (this.converter.options.instantNodeWriting) {
117
- return await this.loadNodePage(pageIndex);
118
- }
119
- return this.nodePages[pageIndex];
120
- }
121
- /**
122
- * Get the node by its end-to-end index
123
- * @param id - end-to-end index of the node
124
- * @return the node object
125
- */
126
- async getNodeById(id, nodePage) {
127
- const nodeIndex = id % this.nodesPerPage;
128
- nodePage = nodePage || (await this.getPageByNodeId(id));
129
- return nodePage.nodes[nodeIndex];
130
- }
131
- /**
132
- * Add a child id into the parent node.children array
133
- * @param parentId - end-to-end parent node index
134
- * @param childId - end-to-end child node index
135
- */
136
- async addChildRelation(parentId, childId) {
137
- if (parentId === null || parentId === undefined) {
138
- return;
139
- }
140
- const parentNode = await this.getNodeById(parentId);
141
- parentNode.children?.push(childId);
142
- await this.saveNode(parentNode);
143
- }
144
- /**
145
- * Put new node in nodePages array
146
- * @param node - node object
147
- * @param parentId - index of parent node
148
- * @return
149
- */
150
- async push(node, parentId) {
151
- node.index = this.nodesCounter++;
152
- if (!this.converter.options.instantNodeWriting) {
153
- let currentNodePage = this.nodePages[this.nodePages.length - 1];
154
- if (currentNodePage.nodes.length === this.nodesPerPage) {
155
- currentNodePage = { nodes: [] };
156
- this.nodePages.push(currentNodePage);
157
- }
158
- currentNodePage.nodes.push(node);
159
- }
160
- await this.addChildRelation(parentId, node.index);
161
- NodePages.updateResourceInMesh(node);
162
- await this.saveNode(node);
163
- return node;
164
- }
165
- /**
166
- * Save node to the file on the disk
167
- * @param node - node data
168
- */
169
- async saveNode(node) {
170
- if (!this.converter.options.instantNodeWriting) {
171
- return;
172
- }
173
- else {
174
- const nodePageIndex = this.getPageIndexByNodeId(node.index);
175
- const nodePage = await this.getPageByNodeId(node.index);
176
- const { filePath, fileName } = this.getNodePageFileName(nodePageIndex);
177
- const nodeToUpdate = await this.getNodeById(node.index, nodePage);
178
- if (nodeToUpdate) {
179
- NodePages.updateAll(nodeToUpdate, node);
180
- }
181
- else {
182
- nodePage.nodes.push(node);
183
- }
184
- const nodePageStr = JSON.stringify(nodePage);
185
- if (this.converter.options.slpk) {
186
- await this.converter.writeQueue.enqueue({
187
- archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
188
- writePromise: () => this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
189
- }, true);
190
- }
191
- else {
192
- await this.converter.writeQueue.enqueue({
193
- writePromise: () => this.writeFile(filePath, nodePageStr)
194
- }, true);
195
- }
196
- }
197
- }
198
- /**
199
- * Save metadata file (for slpk only)
200
- */
201
- async saveMetadata() {
202
- const metadata = (0, json_map_transform_1.default)({ nodeCount: this.nodesCounter }, (0, metadata_1.METADATA)());
203
- const compress = false;
204
- await this.converter.writeQueue.enqueue({
205
- archiveKey: 'metadata.json',
206
- writePromise: () => this.writeFile(this.converter.layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
207
- });
208
- }
209
- /**
210
- * Save all the node pages
211
- * Run this method when all nodes is pushed in nodePages
212
- */
213
- async save() {
214
- if (this.converter.options.instantNodeWriting) {
215
- await this.saveMetadata();
216
- return;
217
- }
218
- if (this.converter.options.slpk) {
219
- for (const [index, nodePage] of this.nodePages.entries()) {
220
- const nodePageStr = JSON.stringify(nodePage);
221
- const slpkPath = (0, path_1.join)(this.converter.layers0Path, 'nodepages');
222
- await this.converter.writeQueue.enqueue({
223
- archiveKey: `nodePages/${index.toString()}.json.gz`,
224
- writePromise: () => this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
225
- });
226
- }
227
- await this.saveMetadata();
228
- }
229
- else {
230
- for (const [index, nodePage] of this.nodePages.entries()) {
231
- const nodePageStr = JSON.stringify(nodePage);
232
- const nodePagePath = (0, path_1.join)(this.converter.layers0Path, 'nodepages', index.toString());
233
- await this.converter.writeQueue.enqueue({
234
- writePromise: () => this.writeFile(nodePagePath, nodePageStr)
235
- });
236
- }
237
- }
238
- }
239
- /**
240
- * Update resource index in node.mesh object
241
- * @param node - node object
242
- */
243
- static updateResourceInMesh(node) {
244
- if (node.mesh && isFinite(node.index)) {
245
- node.mesh.geometry.resource = node.index;
246
- }
247
- }
248
- /**
249
- * Update all fields in the node excluding id
250
- * @param node - node object
251
- * @param data - NodeInPage data to replace original data
252
- */
253
- static updateAll(node, data) {
254
- Object.assign(node, data, { index: node.index });
255
- NodePages.updateResourceInMesh(node);
256
- return node;
257
- }
258
- /**
259
- * Update material in node.mesh object by node id
260
- * @param id - end-to-end index of the node
261
- * @param materialId - id from scene layer materialDefinitions
262
- */
263
- static updateMaterialByNodeId(node, materialId) {
264
- if (!node.mesh) {
265
- return;
266
- }
267
- node.mesh.material = {
268
- definition: materialId,
269
- resource: node.index
270
- };
271
- }
272
- /**
273
- * Update vertexCount in node.mesh.geometry object by node id
274
- * @param id - end-to-end index of the node
275
- * @param vertexCount - vertex count for particular node
276
- */
277
- static updateVertexCountByNodeId(node, vertexCount) {
278
- if (!node.mesh) {
279
- return;
280
- }
281
- node.mesh.geometry.vertexCount = vertexCount;
282
- }
283
- /**
284
- * Update resource in node.mesh.attribute object by node id
285
- * @param node - node object
286
- */
287
- static updateNodeAttributeByNodeId(node) {
288
- if (!node.mesh || !node.index) {
289
- return;
290
- }
291
- node.mesh.attribute.resource = node.index;
292
- }
293
- /**
294
- * Update featureCount in node.mesh.geometry object by node id
295
- * @param node - node object
296
- * @param featureCount - features count of the node
297
- */
298
- static updateFeatureCountByNodeId(node, featureCount) {
299
- if (!node.mesh) {
300
- return;
301
- }
302
- node.mesh.geometry.featureCount = featureCount;
303
- }
304
- /**
305
- * Update texelCountHint in node.mesh.material object by node id
306
- * @param node - node object
307
- * @param texelCountHint - texelCountHint of particular node
308
- */
309
- static updateTexelCountHintByNodeId(node, texelCountHint) {
310
- if (!node.mesh || !node.mesh.material) {
311
- return;
312
- }
313
- node.mesh.material.texelCountHint = texelCountHint;
314
- }
315
- }
316
- exports.default = NodePages;