@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.
Files changed (166) hide show
  1. package/dist/converter.min.cjs +89 -98
  2. package/dist/i3s-server/bin/i3s-server.min.cjs +78 -78
  3. package/package.json +17 -17
  4. package/src/3d-tiles-converter/3d-tiles-converter.ts +11 -7
  5. package/src/3d-tiles-converter/helpers/load-i3s.ts +5 -5
  6. package/src/converter-cli.ts +2 -2
  7. package/src/i3s-converter/helpers/geometry-converter.ts +17 -1
  8. package/src/i3s-converter/helpers/load-3d-tiles.ts +24 -9
  9. package/src/i3s-converter/i3s-converter.ts +25 -9
  10. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  11. package/src/lib/utils/compress-util.ts +1 -0
  12. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +0 -115
  13. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +0 -1
  14. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -388
  15. package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts +0 -88
  16. package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.d.ts.map +0 -1
  17. package/dist/3d-tiles-converter/helpers/3d-tiles-content-converter.js +0 -380
  18. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -13
  19. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +0 -1
  20. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -19
  21. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +0 -37
  22. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +0 -1
  23. package/dist/3d-tiles-converter/helpers/load-i3s.js +0 -98
  24. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +0 -10
  25. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +0 -1
  26. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -50
  27. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +0 -15
  28. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +0 -1
  29. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -39
  30. package/dist/constants.d.ts +0 -3
  31. package/dist/constants.d.ts.map +0 -1
  32. package/dist/constants.js +0 -2
  33. package/dist/converter-cli.d.ts +0 -2
  34. package/dist/converter-cli.d.ts.map +0 -1
  35. package/dist/converter-cli.js +0 -290
  36. package/dist/deps-installer/deps-installer.d.ts +0 -19
  37. package/dist/deps-installer/deps-installer.d.ts.map +0 -1
  38. package/dist/deps-installer/deps-installer.js +0 -95
  39. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +0 -84
  40. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +0 -1
  41. package/dist/i3s-converter/helpers/attribute-metadata-info.js +0 -219
  42. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +0 -26
  43. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +0 -1
  44. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -165
  45. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +0 -39
  46. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +0 -1
  47. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -118
  48. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +0 -9
  49. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +0 -1
  50. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -21
  51. package/dist/i3s-converter/helpers/feature-attributes.d.ts +0 -54
  52. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +0 -1
  53. package/dist/i3s-converter/helpers/feature-attributes.js +0 -193
  54. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +0 -8
  55. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +0 -1
  56. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -226
  57. package/dist/i3s-converter/helpers/geometry-converter.d.ts +0 -60
  58. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +0 -1
  59. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1309
  60. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +0 -28
  61. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +0 -1
  62. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -122
  63. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +0 -33
  64. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +0 -1
  65. package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -121
  66. package/dist/i3s-converter/helpers/node-debug.d.ts +0 -8
  67. package/dist/i3s-converter/helpers/node-debug.d.ts.map +0 -1
  68. package/dist/i3s-converter/helpers/node-debug.js +0 -116
  69. package/dist/i3s-converter/helpers/node-index-document.d.ts +0 -111
  70. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +0 -1
  71. package/dist/i3s-converter/helpers/node-index-document.js +0 -269
  72. package/dist/i3s-converter/helpers/node-pages.d.ts +0 -156
  73. package/dist/i3s-converter/helpers/node-pages.d.ts.map +0 -1
  74. package/dist/i3s-converter/helpers/node-pages.js +0 -285
  75. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +0 -22
  76. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +0 -1
  77. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -104
  78. package/dist/i3s-converter/helpers/progress.d.ts +0 -90
  79. package/dist/i3s-converter/helpers/progress.d.ts.map +0 -1
  80. package/dist/i3s-converter/helpers/progress.js +0 -148
  81. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +0 -32
  82. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +0 -1
  83. package/dist/i3s-converter/helpers/tileset-traversal.js +0 -34
  84. package/dist/i3s-converter/i3s-converter.d.ts +0 -312
  85. package/dist/i3s-converter/i3s-converter.d.ts.map +0 -1
  86. package/dist/i3s-converter/i3s-converter.js +0 -1191
  87. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +0 -7
  88. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +0 -1
  89. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -80
  90. package/dist/i3s-converter/json-templates/layers.d.ts +0 -70
  91. package/dist/i3s-converter/json-templates/layers.d.ts.map +0 -1
  92. package/dist/i3s-converter/json-templates/layers.js +0 -132
  93. package/dist/i3s-converter/json-templates/metadata.d.ts +0 -22
  94. package/dist/i3s-converter/json-templates/metadata.d.ts.map +0 -1
  95. package/dist/i3s-converter/json-templates/metadata.js +0 -21
  96. package/dist/i3s-converter/json-templates/node.d.ts +0 -61
  97. package/dist/i3s-converter/json-templates/node.d.ts.map +0 -1
  98. package/dist/i3s-converter/json-templates/node.js +0 -82
  99. package/dist/i3s-converter/json-templates/scene-server.d.ts +0 -28
  100. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +0 -1
  101. package/dist/i3s-converter/json-templates/scene-server.js +0 -27
  102. package/dist/i3s-converter/json-templates/shared-resources.d.ts +0 -14
  103. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +0 -1
  104. package/dist/i3s-converter/json-templates/shared-resources.js +0 -122
  105. package/dist/i3s-converter/json-templates/store.d.ts +0 -95
  106. package/dist/i3s-converter/json-templates/store.d.ts.map +0 -1
  107. package/dist/i3s-converter/json-templates/store.js +0 -100
  108. package/dist/i3s-converter/types.d.ts +0 -226
  109. package/dist/i3s-converter/types.d.ts.map +0 -1
  110. package/dist/i3s-converter/types.js +0 -37
  111. package/dist/i3s-server/app.d.ts +0 -3
  112. package/dist/i3s-server/app.d.ts.map +0 -1
  113. package/dist/i3s-server/app.js +0 -31
  114. package/dist/i3s-server/bin/www.d.ts +0 -3
  115. package/dist/i3s-server/bin/www.d.ts.map +0 -1
  116. package/dist/i3s-server/bin/www.js +0 -46
  117. package/dist/i3s-server/controllers/slpk-controller.d.ts +0 -13
  118. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +0 -1
  119. package/dist/i3s-server/controllers/slpk-controller.js +0 -32
  120. package/dist/i3s-server/routes/slpk-router.d.ts +0 -3
  121. package/dist/i3s-server/routes/slpk-router.d.ts.map +0 -1
  122. package/dist/i3s-server/routes/slpk-router.js +0 -40
  123. package/dist/i3s-server/utils/create-scene-server.d.ts +0 -17
  124. package/dist/i3s-server/utils/create-scene-server.d.ts.map +0 -1
  125. package/dist/i3s-server/utils/create-scene-server.js +0 -18
  126. package/dist/i3s-server/utils/server-utils.d.ts +0 -21
  127. package/dist/i3s-server/utils/server-utils.d.ts.map +0 -1
  128. package/dist/i3s-server/utils/server-utils.js +0 -60
  129. package/dist/index.cjs +0 -6228
  130. package/dist/index.cjs.map +0 -7
  131. package/dist/index.d.ts +0 -3
  132. package/dist/index.d.ts.map +0 -1
  133. package/dist/index.js +0 -2
  134. package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts +0 -463
  135. package/dist/lib/json-schemas/conversion-dump-json-schema.d.ts.map +0 -1
  136. package/dist/lib/json-schemas/conversion-dump-json-schema.js +0 -285
  137. package/dist/lib/utils/cli-utils.d.ts +0 -34
  138. package/dist/lib/utils/cli-utils.d.ts.map +0 -1
  139. package/dist/lib/utils/cli-utils.js +0 -76
  140. package/dist/lib/utils/compress-util.d.ts +0 -8
  141. package/dist/lib/utils/compress-util.d.ts.map +0 -1
  142. package/dist/lib/utils/compress-util.js +0 -25
  143. package/dist/lib/utils/conversion-dump.d.ts +0 -147
  144. package/dist/lib/utils/conversion-dump.d.ts.map +0 -1
  145. package/dist/lib/utils/conversion-dump.js +0 -257
  146. package/dist/lib/utils/file-utils.d.ts +0 -57
  147. package/dist/lib/utils/file-utils.d.ts.map +0 -1
  148. package/dist/lib/utils/file-utils.js +0 -140
  149. package/dist/lib/utils/geometry-utils.d.ts +0 -9
  150. package/dist/lib/utils/geometry-utils.d.ts.map +0 -1
  151. package/dist/lib/utils/geometry-utils.js +0 -14
  152. package/dist/lib/utils/lod-conversion-utils.d.ts +0 -42
  153. package/dist/lib/utils/lod-conversion-utils.d.ts.map +0 -1
  154. package/dist/lib/utils/lod-conversion-utils.js +0 -71
  155. package/dist/lib/utils/queue.d.ts +0 -7
  156. package/dist/lib/utils/queue.d.ts.map +0 -1
  157. package/dist/lib/utils/queue.js +0 -14
  158. package/dist/lib/utils/statistic-utils.d.ts +0 -20
  159. package/dist/lib/utils/statistic-utils.d.ts.map +0 -1
  160. package/dist/lib/utils/statistic-utils.js +0 -88
  161. package/dist/lib/utils/write-queue.d.ts +0 -44
  162. package/dist/lib/utils/write-queue.d.ts.map +0 -1
  163. package/dist/lib/utils/write-queue.js +0 -82
  164. package/dist/pgm-loader.d.ts +0 -28
  165. package/dist/pgm-loader.d.ts.map +0 -1
  166. package/dist/pgm-loader.js +0 -24
@@ -1,257 +0,0 @@
1
- import { isDeepStrictEqual } from 'util';
2
- import { DUMP_FILE_SUFFIX } from "../../constants.js";
3
- import { isFileExists, openJson, removeFile, renameFile, writeFile } from "./file-utils.js";
4
- import { join } from 'path';
5
- import process from 'process';
6
- import Ajv from 'ajv';
7
- import { dumpJsonSchema } from "../json-schemas/conversion-dump-json-schema.js";
8
- export class ConversionDump {
9
- /** Restored/resumed dump indicator */
10
- restored = false;
11
- /** Conversion options */
12
- options;
13
- /** Tiles conversion progress status map */
14
- tilesConverted;
15
- /** Textures formats definitions */
16
- textureSetDefinitions;
17
- /** Attributes Metadata */
18
- attributeMetadataInfo;
19
- /** Array of materials definitions */
20
- materialDefinitions;
21
- constructor() {
22
- this.tilesConverted = {};
23
- }
24
- /**
25
- * Create a dump with convertion options
26
- * @param currentOptions - converter options
27
- */
28
- async createDump(currentOptions) {
29
- const { tilesetName, slpk, egmFilePath, inputUrl, outputPath, draco = true, maxDepth, token, generateTextures, generateBoundingVolumes, mergeMaterials = true, metadataClass, analyze = false, outputVersion = '1.1' } = currentOptions;
30
- this.options = {
31
- tilesetName,
32
- slpk,
33
- egmFilePath,
34
- inputUrl,
35
- outputPath,
36
- draco,
37
- maxDepth,
38
- token,
39
- generateTextures,
40
- generateBoundingVolumes,
41
- mergeMaterials,
42
- metadataClass,
43
- analyze,
44
- outputVersion
45
- };
46
- const dumpFilename = join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
47
- if (await isFileExists(dumpFilename)) {
48
- try {
49
- const dump = await openJson(join(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
50
- const { options, tilesConverted, textureSetDefinitions, attributeMetadataInfo, materialDefinitions } = dump;
51
- const ajv = new Ajv();
52
- const dumpJsonValidate = ajv.compile(dumpJsonSchema);
53
- const isDumpValid = dumpJsonValidate(dump);
54
- if (isDumpValid && isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {
55
- this.tilesConverted = tilesConverted;
56
- this.textureSetDefinitions = textureSetDefinitions;
57
- this.attributeMetadataInfo = attributeMetadataInfo;
58
- this.materialDefinitions = materialDefinitions;
59
- this.restored = true;
60
- return;
61
- }
62
- }
63
- catch (error) {
64
- // prettier-ignore
65
- console.log('Can\'t open dump file', error); // eslint-disable-line no-console
66
- }
67
- }
68
- await this.deleteDumpFile();
69
- }
70
- /**
71
- * Reset a dump
72
- */
73
- reset() {
74
- this.restored = false;
75
- this.tilesConverted = {};
76
- if (this.textureSetDefinitions) {
77
- delete this.textureSetDefinitions;
78
- }
79
- if (this.attributeMetadataInfo) {
80
- delete this.attributeMetadataInfo;
81
- }
82
- if (this.materialDefinitions) {
83
- delete this.materialDefinitions;
84
- }
85
- }
86
- /**
87
- * Update conversion status in the dump file
88
- */
89
- async updateDumpFile() {
90
- if (this.options?.outputPath && this.options.tilesetName) {
91
- try {
92
- const time = process.hrtime();
93
- await writeFile(join(this.options.outputPath, this.options.tilesetName), JSON.stringify({
94
- options: this.options,
95
- tilesConverted: this.tilesConverted,
96
- textureSetDefinitions: this.textureSetDefinitions,
97
- attributeMetadataInfo: this.attributeMetadataInfo,
98
- materialDefinitions: this.materialDefinitions
99
- }), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`);
100
- await renameFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}.${time[0]}.${time[1]}`), join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
101
- }
102
- catch (error) {
103
- // prettier-ignore
104
- console.log('Can\'t update dump file', error); // eslint-disable-line no-console
105
- }
106
- }
107
- }
108
- /**
109
- * Delete a dump file
110
- */
111
- async deleteDumpFile() {
112
- if (this.options?.outputPath &&
113
- this.options.tilesetName &&
114
- (await isFileExists(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)))) {
115
- await removeFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
116
- }
117
- }
118
- /**
119
- * Get record from the tilesConverted Map
120
- * @param fileName - source filename
121
- * @returns existing object from the tilesConverted Map
122
- */
123
- getRecord(fileName) {
124
- return this.tilesConverted[fileName];
125
- }
126
- /**
127
- * Set a record for the dump file
128
- * @param fileName - key - source filename
129
- * @param object - value
130
- */
131
- setRecord(fileName, object) {
132
- this.tilesConverted[fileName] = object;
133
- }
134
- /**
135
- * Add a node into the dump file for the source file record
136
- * @param fileName - source filename
137
- * @param nodeId - nodeId of the node
138
- */
139
- async addNode(filename, nodeId, dumpMetadata) {
140
- const { nodes } = this.getRecord(filename) || { nodes: [] };
141
- nodes.push({ nodeId, done: false, dumpMetadata });
142
- if (nodes.length === 1) {
143
- this.setRecord(filename, { nodes });
144
- }
145
- await this.updateDumpFile();
146
- }
147
- /**
148
- * Clear dump record got the source filename
149
- * @param fileName - source filename
150
- */
151
- clearDumpRecord(filename) {
152
- this.setRecord(filename, { nodes: [] });
153
- }
154
- /**
155
- * Add textures definitions into the dump file
156
- * @param textureDefinitions - textures definitions array
157
- */
158
- addTexturesDefinitions(textureDefinitions) {
159
- this.textureSetDefinitions = textureDefinitions;
160
- }
161
- /**
162
- * Update done status object for the writing resources
163
- * @param fileName - key - source filename
164
- * @param nodeId - nodeId for the source filename
165
- * @param resourceType - resource type to update status
166
- * @param value - value
167
- */
168
- updateDoneStatus(filename, nodeId, resourceType, value) {
169
- const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
170
- if (nodeDump) {
171
- if (!nodeDump.progress) {
172
- nodeDump.progress = {};
173
- }
174
- nodeDump.progress[resourceType] = value;
175
- if (!value) {
176
- nodeDump.done = false;
177
- }
178
- }
179
- }
180
- /**
181
- * Update dump file according to writing results
182
- * @param changedRecords - array of parameters ids for the written resources
183
- * @param writeResults - array of writing resource files results
184
- */
185
- async updateConvertedTilesDump(changedRecords, writeResults) {
186
- for (let i = 0; i < changedRecords.length; i++) {
187
- if (changedRecords[i] && 'value' in writeResults[i]) {
188
- const { sourceId, resourceType, outputId } = changedRecords[i];
189
- this.updateNodes(sourceId, outputId, resourceType);
190
- }
191
- }
192
- await this.updateDumpFile();
193
- }
194
- /**
195
- * Update done status for a node
196
- * @param sourceId - source resource Id
197
- * @param outputId - output node/tile Id
198
- * @param resourceType - type of resource
199
- * @returns void
200
- */
201
- updateNodes(sourceId, outputId, resourceType) {
202
- if (!sourceId || !resourceType || !outputId) {
203
- return;
204
- }
205
- for (const node of this.tilesConverted[sourceId].nodes) {
206
- if (node.nodeId === outputId && node.progress) {
207
- node.progress[resourceType] = true;
208
- let done = false;
209
- for (const key in node.progress) {
210
- done = node.progress[key];
211
- if (!done)
212
- break;
213
- }
214
- node.done = done;
215
- if (node.done) {
216
- delete node.progress;
217
- }
218
- break;
219
- }
220
- }
221
- }
222
- /**
223
- * Update 3d-tiles-converter dump file
224
- * @param filename - source filename
225
- * @param nodeId - nodeId
226
- * @param done - conversion status
227
- */
228
- async updateConvertedNodesDumpFile(filename, nodeId, done) {
229
- const nodeDump = this.tilesConverted[filename]?.nodes.find((element) => element.nodeId === nodeId);
230
- if (nodeDump) {
231
- nodeDump.done = done;
232
- await this.updateDumpFile();
233
- }
234
- }
235
- /**
236
- * Check is source file conversion complete
237
- * @param filename - source filename
238
- * @returns true if source file conversion complete
239
- */
240
- isFileConversionComplete(filename) {
241
- let result = true;
242
- for (const node of this.tilesConverted[filename]?.nodes || []) {
243
- if (!node.done) {
244
- result = false;
245
- break;
246
- }
247
- }
248
- return result && this.tilesConverted[filename]?.nodes?.length > 0;
249
- }
250
- /**
251
- * Set materialDefinitions into a dump
252
- * @param materialDefinitions - Array materialDefinitions
253
- */
254
- setMaterialsDefinitions(materialDefinitions) {
255
- this.materialDefinitions = materialDefinitions;
256
- }
257
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * Write a file with data and name fileName to path
3
- *
4
- * @param path - output path
5
- * @param data - file content
6
- * @param fileName - name of output file (default: index.json)
7
- */
8
- export declare function writeFile(path: string, data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>, fileName?: string): Promise<string>;
9
- /**
10
- * Write a file with data and name fileName to path - specific one for further packaging into slpk
11
- *
12
- * @param path - output path
13
- * @param data - file content
14
- * @param fileName - name of output file (default: index.json)
15
- * @param compress - if need to compress file with gzip (default: true)
16
- * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
17
- */
18
- export declare function writeFileForSlpk(path: string, data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>, fileName?: string, compress?: boolean, compressList?: string[] | null): Promise<string | null>;
19
- /**
20
- * Open json file
21
- * @param path - path to the file
22
- * @param fileName - file name
23
- * @returns object
24
- */
25
- export declare function openJson(path: string, fileName: string): Promise<{
26
- [key: string]: any;
27
- }>;
28
- /**
29
- * Check if the file exists
30
- * @param fileName - full name of file
31
- * @returns true if file exists, otherwise - false
32
- */
33
- export declare function isFileExists(fileName: string): Promise<boolean>;
34
- /**
35
- * Remove dir with path
36
- *
37
- * @param path
38
- */
39
- export declare function removeDir(path: string): any;
40
- /**
41
- * Remove file with path
42
- *
43
- * @param path
44
- */
45
- export declare function removeFile(path: string): Promise<void>;
46
- /**
47
- * Generates absolute file path
48
- * @param filePath
49
- */
50
- export declare function getAbsoluteFilePath(filePath: string): string;
51
- /**
52
- * Rename file with old path by new path
53
- * @param oldPath
54
- * @param newPath
55
- */
56
- export declare function renameFile(oldPath: string, newPath: string): Promise<void>;
57
- //# sourceMappingURL=file-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,EAC/B,QAAQ,GAAE,OAAc,EACxB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAC,CAoB5F;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,OAIrC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAEtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAEnD;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhF"}
@@ -1,140 +0,0 @@
1
- import { load } from '@loaders.gl/core';
2
- import { JSONLoader } from '@loaders.gl/loader-utils';
3
- import { promises as fs } from 'fs';
4
- import { isAbsolute, join } from 'path';
5
- import { compressFileWithGzip } from "./compress-util.js";
6
- /**
7
- * Write a file with data and name fileName to path
8
- *
9
- * @param path - output path
10
- * @param data - file content
11
- * @param fileName - name of output file (default: index.json)
12
- */
13
- export async function writeFile(path, data, fileName = 'index.json') {
14
- let toWriteData;
15
- if (data instanceof Promise) {
16
- toWriteData = new Uint8Array(await data);
17
- }
18
- else if (data instanceof ArrayBuffer) {
19
- toWriteData = new Uint8Array(data);
20
- }
21
- else {
22
- toWriteData = data;
23
- }
24
- await fs.mkdir(path, { recursive: true });
25
- const pathFile = join(path, fileName);
26
- try {
27
- await fs.writeFile(pathFile, toWriteData);
28
- }
29
- catch (err) {
30
- throw err;
31
- }
32
- console.log(`${pathFile} saved.`); // eslint-disable-line no-console
33
- return pathFile;
34
- }
35
- /**
36
- * Write a file with data and name fileName to path - specific one for further packaging into slpk
37
- *
38
- * @param path - output path
39
- * @param data - file content
40
- * @param fileName - name of output file (default: index.json)
41
- * @param compress - if need to compress file with gzip (default: true)
42
- * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
43
- */
44
- export async function writeFileForSlpk(path, data, fileName = 'index.json', compress = true, compressList) {
45
- const pathFile = await writeFile(path, data, fileName);
46
- if (compress) {
47
- if (compressList) {
48
- if (!compressList.includes(pathFile)) {
49
- compressList.push(pathFile);
50
- return `${pathFile}.gz`;
51
- }
52
- return null;
53
- }
54
- const pathGzFile = await compressFileWithGzip(pathFile);
55
- // After compression, we don't need an uncompressed file
56
- await removeFile(pathFile);
57
- return pathGzFile;
58
- }
59
- return pathFile;
60
- }
61
- /**
62
- * Open json file
63
- * @param path - path to the file
64
- * @param fileName - file name
65
- * @returns object
66
- */
67
- export async function openJson(path, fileName) {
68
- return new Promise((resolve, reject) => {
69
- let count = 0;
70
- console.log(`load ${path}/${fileName}.`); // eslint-disable-line no-console
71
- const intervalId = setInterval(() => {
72
- const pathFile = join(path, fileName);
73
- load(pathFile, JSONLoader)
74
- .then((result) => {
75
- clearInterval(intervalId);
76
- resolve(result);
77
- })
78
- .catch(() => {
79
- count++;
80
- if (count > 100) {
81
- clearInterval(intervalId);
82
- reject(new Error(`Cannon load ${path}/${fileName}.`));
83
- }
84
- });
85
- }, 200);
86
- });
87
- }
88
- /**
89
- * Check if the file exists
90
- * @param fileName - full name of file
91
- * @returns true if file exists, otherwise - false
92
- */
93
- export async function isFileExists(fileName) {
94
- try {
95
- await fs.stat(fileName);
96
- return true;
97
- }
98
- catch {
99
- return false;
100
- }
101
- }
102
- /**
103
- * Remove dir with path
104
- *
105
- * @param path
106
- */
107
- export function removeDir(path) {
108
- // (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
109
- // @ts-ignore
110
- return fs.rm(path, { recursive: true });
111
- }
112
- /**
113
- * Remove file with path
114
- *
115
- * @param path
116
- */
117
- export function removeFile(path) {
118
- return fs.unlink(path);
119
- }
120
- /**
121
- * Generates absolute file path
122
- * @param filePath
123
- */
124
- export function getAbsoluteFilePath(filePath) {
125
- return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
126
- }
127
- /**
128
- * Rename file with old path by new path
129
- * @param oldPath
130
- * @param newPath
131
- */
132
- export async function renameFile(oldPath, newPath) {
133
- try {
134
- await fs.rename(oldPath, newPath);
135
- }
136
- catch (err) {
137
- // prettier-ignore
138
- console.log('Can\'t rename file', err); // eslint-disable-line no-console
139
- }
140
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * luma.gl can not work without indices now:
3
- * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
4
- * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
5
- * @param {number} vertexCount - vertex count in the geometry
6
- * @returns {Uint32Array} indices array.
7
- */
8
- export declare const generateSyntheticIndices: (vertexCount: number) => Uint32Array;
9
- //# sourceMappingURL=geometry-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/geometry-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,gBAAiB,MAAM,KAAG,WAM9D,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * luma.gl can not work without indices now:
3
- * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
4
- * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
5
- * @param {number} vertexCount - vertex count in the geometry
6
- * @returns {Uint32Array} indices array.
7
- */
8
- export const generateSyntheticIndices = (vertexCount) => {
9
- const result = new Uint32Array(vertexCount);
10
- for (let index = 0; index < vertexCount; index++) {
11
- result[index] = index;
12
- }
13
- return result;
14
- };
@@ -1,42 +0,0 @@
1
- import { Tiles3DTileJSONPostprocessed } from '@loaders.gl/3d-tiles';
2
- import { BoundingVolumes } from '@loaders.gl/i3s';
3
- import { I3STileHeader } from '@loaders.gl/i3s/src/types';
4
- /**
5
- * Do conversion from geometric error to screen threshold
6
- *
7
- * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.
8
- * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.
9
- * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles
10
- * 3DTiles spec:
11
- * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error
12
- * I3S spec:
13
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md
14
- * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us
15
- * to make child maxError bigger than his parent maxError.
16
- *
17
- * @param tile - 3d-tiles tile JSON
18
- * @param coordinates - node converted coordinates
19
- * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection
20
- * @example
21
- * [
22
- {
23
- "metricType": "maxScreenThresholdSQ",
24
- "maxError": 870638.071285568
25
- },
26
- {
27
- "metricType": "maxScreenThreshold",
28
- "maxError": 1052.8679031638949
29
- }
30
- ]
31
- */
32
- export declare function convertGeometricErrorToScreenThreshold(tile: Tiles3DTileJSONPostprocessed, coordinates: BoundingVolumes): {
33
- metricType: string;
34
- maxError: number;
35
- }[];
36
- /**
37
- * Convert LOD metric from "Screen Threshold" to "Screen Space Error"
38
- * @param node - i3s node data
39
- * @returns lod metric in 3d-tiles format
40
- */
41
- export declare function convertScreenThresholdToGeometricError(node: I3STileHeader): number;
42
- //# sourceMappingURL=lod-conversion-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lod-conversion-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/lod-conversion-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,4BAA4B,EAClC,WAAW,EAAE,eAAe;gBAEK,MAAM;cAAY,MAAM;IAqB1D;AAED;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAmBlF"}
@@ -1,71 +0,0 @@
1
- // https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html
2
- const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
3
- /**
4
- * Do conversion from geometric error to screen threshold
5
- *
6
- * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.
7
- * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.
8
- * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles
9
- * 3DTiles spec:
10
- * https://github.com/CesiumGS/3d-tiles/tree/master/specification#geometric-error
11
- * I3S spec:
12
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md
13
- * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us
14
- * to make child maxError bigger than his parent maxError.
15
- *
16
- * @param tile - 3d-tiles tile JSON
17
- * @param coordinates - node converted coordinates
18
- * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection
19
- * @example
20
- * [
21
- {
22
- "metricType": "maxScreenThresholdSQ",
23
- "maxError": 870638.071285568
24
- },
25
- {
26
- "metricType": "maxScreenThreshold",
27
- "maxError": 1052.8679031638949
28
- }
29
- ]
30
- */
31
- export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
32
- const lodSelection = [];
33
- const boundingVolume = tile.boundingVolume;
34
- const lodMetricValue = tile.lodMetricValue || 0.1;
35
- const maxScreenThreshold = {
36
- metricType: 'maxScreenThreshold',
37
- maxError: (coordinates.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / lodMetricValue
38
- };
39
- const maxScreenThresholdSQ = {
40
- metricType: 'maxScreenThresholdSQ',
41
- maxError: Math.PI * 0.25 * maxScreenThreshold.maxError * maxScreenThreshold.maxError
42
- };
43
- if (boundingVolume.constructor.name === 'OrientedBoundingBox') {
44
- lodSelection.push(maxScreenThresholdSQ);
45
- lodSelection.push(maxScreenThreshold);
46
- }
47
- else {
48
- lodSelection.push(maxScreenThreshold);
49
- lodSelection.push(maxScreenThresholdSQ);
50
- }
51
- return lodSelection;
52
- }
53
- /**
54
- * Convert LOD metric from "Screen Threshold" to "Screen Space Error"
55
- * @param node - i3s node data
56
- * @returns lod metric in 3d-tiles format
57
- */
58
- export function convertScreenThresholdToGeometricError(node) {
59
- const metricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThreshold');
60
- let maxError = metricData?.maxError;
61
- if (!maxError) {
62
- const sqMetricData = node.lodSelection?.find((metric) => metric.metricType === 'maxScreenThresholdSQ');
63
- if (sqMetricData) {
64
- maxError = Math.sqrt(sqMetricData.maxError / (Math.PI * 0.25));
65
- }
66
- }
67
- if (!maxError) {
68
- maxError = DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR;
69
- }
70
- return (node.mbs[3] * 2 * DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR) / maxError;
71
- }
@@ -1,7 +0,0 @@
1
- export declare class Queue<T> extends Array<T> {
2
- enqueue(val: T): void;
3
- dequeue(): T | undefined;
4
- peek(): T;
5
- isEmpty(): boolean;
6
- }
7
- //# sourceMappingURL=queue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/queue.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,CAAC;IAId,OAAO,IAAI,CAAC,GAAG,SAAS;IAIxB,IAAI,IAAI,CAAC;IAIT,OAAO;CAGR"}
@@ -1,14 +0,0 @@
1
- export class Queue extends Array {
2
- enqueue(val) {
3
- this.push(val);
4
- }
5
- dequeue() {
6
- return this.shift();
7
- }
8
- peek() {
9
- return this[0];
10
- }
11
- isEmpty() {
12
- return this.length === 0;
13
- }
14
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Converts time value to string.
3
- * @param time - high-resolution real time in a [seconds, nanoseconds] tuple Array, or a value on milliseconds.
4
- * @returns string representation of the time
5
- */
6
- export declare function timeConverter(time: number | [number, number]): string;
7
- /**
8
- * Calculates overall datatset size
9
- * @param params - params object
10
- * @param params.slpk - if dataset is in slpk format
11
- * @param params.outputPath - path to the folder containing the dataset
12
- * @param params.tilesetName - tileset name
13
- * @returns dataset size in bytes
14
- */
15
- export declare function calculateDatasetSize(params: {
16
- slpk?: boolean;
17
- outputPath: string;
18
- tilesetName: string;
19
- }): Promise<number | null>;
20
- //# sourceMappingURL=statistic-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statistic-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/statistic-utils.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAarE;AA6BD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBzB"}