@loaders.gl/tile-converter 4.4.0-alpha.2 → 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 +16 -16
  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,388 +0,0 @@
1
- import { join } from 'path';
2
- import process from 'process';
3
- import transform from 'json-map-transform';
4
- import { load, isBrowser } from '@loaders.gl/core';
5
- import { I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM } from '@loaders.gl/i3s';
6
- import { PGMLoader } from "../pgm-loader.js";
7
- import { i3sObbTo3dTilesObb } from "./helpers/i3s-obb-to-3d-tiles-obb.js";
8
- import { convertScreenThresholdToGeometricError } from "../lib/utils/lod-conversion-utils.js";
9
- import { writeFile, removeDir } from "../lib/utils/file-utils.js";
10
- import { calculateDatasetSize, timeConverter } from "../lib/utils/statistic-utils.js";
11
- import { TILESET as tilesetTemplate } from "./json-templates/tileset.js";
12
- import { createObbFromMbs } from "../i3s-converter/helpers/coordinate-converter.js";
13
- import { WorkerFarm } from '@loaders.gl/worker-utils';
14
- import { BROWSER_ERROR_MESSAGE } from "../constants.js";
15
- import { Tiles3DContentConverter } from "./helpers/3d-tiles-content-converter.js";
16
- import { getNodeCount, loadFromArchive, loadI3SContent, openSLPK } from "./helpers/load-i3s.js";
17
- import { ConversionDump } from "../lib/utils/conversion-dump.js";
18
- import { Progress } from "../i3s-converter/helpers/progress.js";
19
- const I3S = 'I3S';
20
- /**
21
- * Converter from i3s to 3d-tiles
22
- */
23
- export default class Tiles3DConverter {
24
- options;
25
- tilesetPath;
26
- vertexCounter;
27
- conversionStartTime;
28
- geoidHeightModel;
29
- sourceTileset;
30
- attributeStorageInfo;
31
- workerSource = {};
32
- slpkFilesystem = null;
33
- loaderOptions = {
34
- _nodeWorkers: true,
35
- reuseWorkers: true,
36
- // TODO: converter freezes in the end because of i3s-content-worker
37
- worker: false,
38
- i3s: { coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false },
39
- // We need to load local fs workers because nodejs can't load workers from the Internet
40
- 'i3s-content': {
41
- workerUrl: './modules/i3s/dist/i3s-content-worker-node.js'
42
- }
43
- };
44
- conversionDump;
45
- progress;
46
- fileExt;
47
- constructor() {
48
- this.options = {};
49
- this.tilesetPath = '';
50
- this.vertexCounter = 0;
51
- this.conversionStartTime = [0, 0];
52
- this.geoidHeightModel = null;
53
- this.sourceTileset = null;
54
- this.attributeStorageInfo = null;
55
- this.workerSource = {};
56
- this.conversionDump = new ConversionDump();
57
- this.progress = new Progress();
58
- this.fileExt = '';
59
- }
60
- /**
61
- * Convert i3s format data to 3dTiles
62
- * @param options
63
- * @param options.inputUrl the url to read the tileset from
64
- * @param options.outputPath the output filename
65
- * @param options.outputVersion the version of 3DTiles
66
- * @param options.tilesetName the output name of the tileset
67
- * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
68
- * @param options.maxDepth The max tree depth of conversion
69
- */
70
- // eslint-disable-next-line complexity, max-statements
71
- async convert(options) {
72
- if (isBrowser) {
73
- console.log(BROWSER_ERROR_MESSAGE); // eslint-disable-line no-console
74
- return BROWSER_ERROR_MESSAGE;
75
- }
76
- const { inputUrl, outputPath, outputVersion, tilesetName, maxDepth, egmFilePath, inquirer, analyze } = options;
77
- this.conversionStartTime = process.hrtime();
78
- this.options = { maxDepth, inquirer, outputVersion };
79
- this.fileExt = this.options.outputVersion === '1.0' ? 'b3dm' : 'glb';
80
- console.log('Loading egm file...'); // eslint-disable-line
81
- this.geoidHeightModel = await load(egmFilePath, PGMLoader);
82
- console.log('Loading egm file completed!'); // eslint-disable-line
83
- this.slpkFilesystem = await openSLPK(inputUrl);
84
- let preprocessResult = true;
85
- if (analyze || this.slpkFilesystem) {
86
- preprocessResult = await this.preprocessConversion();
87
- if (!preprocessResult || analyze) {
88
- return undefined;
89
- }
90
- }
91
- this.progress.startMonitoring();
92
- this.sourceTileset = await loadFromArchive(inputUrl, I3SLoader, {
93
- ...this.loaderOptions,
94
- // @ts-expect-error `isTileset` can be boolean of 'auto' but TS expects a string
95
- i3s: { ...this.loaderOptions.i3s, isTileset: true }
96
- }, this.slpkFilesystem);
97
- if (!this.sourceTileset) {
98
- return undefined;
99
- }
100
- const rootNode = this.sourceTileset?.root;
101
- if (!rootNode.obb) {
102
- rootNode.obb = createObbFromMbs(rootNode.mbs);
103
- }
104
- this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);
105
- this.attributeStorageInfo = this.sourceTileset.attributeStorageInfo;
106
- await this.conversionDump.createDump(options);
107
- if (this.conversionDump.restored && this.options.inquirer) {
108
- const result = await this.options.inquirer.prompt([
109
- {
110
- name: 'resumeConversion',
111
- type: 'confirm',
112
- message: 'Dump file of the previous conversion exists, do you want to resume that conversion?'
113
- }
114
- ]);
115
- if (!result.resumeConversion) {
116
- this.conversionDump.reset();
117
- }
118
- }
119
- // Removing the tilesetPath needed to exclude erroneous files after conversion
120
- if (!this.conversionDump.restored) {
121
- try {
122
- await removeDir(this.tilesetPath);
123
- }
124
- catch (e) {
125
- // do nothing
126
- }
127
- }
128
- const rootTile = {
129
- boundingVolume: {
130
- box: i3sObbTo3dTilesObb(rootNode.obb, this.geoidHeightModel)
131
- },
132
- geometricError: convertScreenThresholdToGeometricError(rootNode),
133
- children: [],
134
- refine: 'REPLACE'
135
- };
136
- await this._addChildren(rootNode, rootTile, 1);
137
- const tileset = transform({ asset: { version: outputVersion }, root: rootTile }, tilesetTemplate());
138
- await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
139
- await this.conversionDump.deleteDumpFile();
140
- this.progress.stopMonitoring();
141
- await this._finishConversion({ slpk: false, outputPath, tilesetName });
142
- if (this.slpkFilesystem) {
143
- this.slpkFilesystem.destroy();
144
- }
145
- // Clean up worker pools
146
- const workerFarm = WorkerFarm.getWorkerFarm({});
147
- workerFarm.destroy();
148
- return undefined;
149
- }
150
- /**
151
- * Preprocess stage of the tile converter. Calculate number of nodes
152
- * @returns true - the conversion is possible, false - the tileset's content is not supported
153
- */
154
- async preprocessConversion() {
155
- // eslint-disable-next-line no-console
156
- console.log('Analyze source layer');
157
- const nodesCount = await getNodeCount(this.slpkFilesystem);
158
- this.progress.stepsTotal = nodesCount;
159
- // eslint-disable-next-line no-console
160
- console.log('------------------------------------------------');
161
- // eslint-disable-next-line no-console
162
- console.log('Preprocess results:');
163
- if (this.slpkFilesystem) {
164
- // eslint-disable-next-line no-console
165
- console.log(`Node count: ${nodesCount}`);
166
- if (nodesCount === 0) {
167
- // eslint-disable-next-line no-console
168
- console.log('Node count is 0. The conversion will be interrupted.');
169
- // eslint-disable-next-line no-console
170
- console.log('------------------------------------------------');
171
- return false;
172
- }
173
- }
174
- else {
175
- // eslint-disable-next-line no-console
176
- console.log('Node count cannot be calculated for the remote dataset');
177
- }
178
- // eslint-disable-next-line no-console
179
- console.log('------------------------------------------------');
180
- return true;
181
- }
182
- /**
183
- * Convert particular I3S Node
184
- * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
185
- * @param parentNode object in resulting tileset
186
- * @param level a current level of a tree depth
187
- * @param childNodeInfo child node to convert
188
- */
189
- // eslint-disable-next-line complexity, max-statements
190
- async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
191
- let nextParentNode = parentNode;
192
- const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
193
- if (sourceChild.contentUrl) {
194
- if (this.conversionDump.restored &&
195
- this.conversionDump.isFileConversionComplete(`${sourceChild.id}.${this.fileExt}`) &&
196
- (sourceChild.obb || sourceChild.mbs)) {
197
- const { child } = this._createChildAndBoundingVolume(sourceChild);
198
- parentNode.children.push(child);
199
- await this._addChildren(sourceChild, child, level + 1);
200
- return;
201
- }
202
- const content = await loadI3SContent(this.sourceTileset, sourceChild, this.loaderOptions, this.slpkFilesystem);
203
- if (!content) {
204
- await this._addChildren(sourceChild, parentNode, level + 1);
205
- return;
206
- }
207
- this.vertexCounter += content?.vertexCount || 0;
208
- let featureAttributes = null;
209
- if (this.attributeStorageInfo) {
210
- featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
211
- }
212
- const { child, boundingVolume } = this._createChildAndBoundingVolume(sourceChild);
213
- const i3sAttributesData = {
214
- tileContent: content,
215
- box: boundingVolume.box || [],
216
- textureFormat: sourceChild.textureFormat
217
- };
218
- const converter = new Tiles3DContentConverter({ outputVersion: this.options.outputVersion });
219
- const contentData = await converter.convert(i3sAttributesData, featureAttributes, this.attributeStorageInfo);
220
- await this.conversionDump.addNode(`${sourceChild.id}.${this.fileExt}`, sourceChild.id);
221
- await writeFile(this.tilesetPath, new Uint8Array(contentData), `${sourceChild.id}.${this.fileExt}`);
222
- await this.conversionDump.updateConvertedNodesDumpFile(`${sourceChild.id}.${this.fileExt}`, sourceChild.id, true);
223
- parentNode.children.push(child);
224
- nextParentNode = child;
225
- }
226
- this.progress.stepsDone += 1;
227
- let timeRemainingString = 'Calculating time left...';
228
- const timeRemaining = this.progress.getTimeRemainingString();
229
- if (timeRemaining) {
230
- timeRemainingString = `${timeRemaining} left`;
231
- }
232
- const percentString = this.progress.getPercentString();
233
- const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : '';
234
- console.log(`[converted${progressString}]: ${childNodeInfo.id}`); // eslint-disable-line
235
- await this._addChildren(sourceChild, nextParentNode, level + 1);
236
- }
237
- /**
238
- * The recursive function of traversal of a nodes tree
239
- * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
240
- * @param parentNode object in resulting tileset
241
- * @param level a current level of a tree depth
242
- */
243
- async _addChildren(parentSourceNode, parentNode, level) {
244
- if (this.options.maxDepth && level > this.options.maxDepth) {
245
- return;
246
- }
247
- for (const childNodeInfo of parentSourceNode.children || []) {
248
- await this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo);
249
- }
250
- }
251
- /**
252
- * Load a child node having information from the node header
253
- * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
254
- * @param childNodeInfo child information from 3DNodeIndexDocument
255
- * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
256
- */
257
- async _loadChildNode(parentNode, childNodeInfo) {
258
- let header;
259
- if (this.sourceTileset?.nodePagesTile) {
260
- console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
261
- header = await this.sourceTileset.nodePagesTile.formTileFromNodePages(parseInt(childNodeInfo.id));
262
- }
263
- else {
264
- const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
265
- // load metadata
266
- const options = {
267
- i3s: {
268
- ...this.loaderOptions,
269
- // @ts-expect-error
270
- isTileHeader: true,
271
- loadContent: false
272
- }
273
- };
274
- console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
275
- header = await loadFromArchive(nodeUrl, I3SLoader, options, this.slpkFilesystem);
276
- }
277
- return header;
278
- }
279
- /**
280
- * Create child and child's boundingVolume for the converted node
281
- * @param sourceChild
282
- * @returns child and child's boundingVolume
283
- */
284
- _createChildAndBoundingVolume(sourceChild) {
285
- if (!sourceChild.obb) {
286
- sourceChild.obb = createObbFromMbs(sourceChild.mbs);
287
- }
288
- const boundingVolume = {
289
- box: i3sObbTo3dTilesObb(sourceChild.obb, this.geoidHeightModel)
290
- };
291
- const child = {
292
- boundingVolume,
293
- geometricError: convertScreenThresholdToGeometricError(sourceChild),
294
- children: [],
295
- content: {
296
- uri: `${sourceChild.id}.${this.fileExt}`,
297
- boundingVolume
298
- }
299
- };
300
- return { boundingVolume, child };
301
- }
302
- /**
303
- * Make an url of a resource from its relative url having the base url
304
- * @param baseUrl the base url. A resulting url will be related from this url
305
- * @param relativeUrl a realtive url of a resource
306
- */
307
- _relativeUrlToFullUrl(baseUrl = '', relativeUrl) {
308
- let resultArray = baseUrl.split('/');
309
- const relativeUrlArray = relativeUrl.split('/');
310
- for (const folder of relativeUrlArray) {
311
- switch (folder) {
312
- case '.':
313
- continue; // eslint-disable-line no-continue
314
- case '..':
315
- resultArray = resultArray.slice(0, -1);
316
- break;
317
- default:
318
- resultArray.push(folder);
319
- }
320
- }
321
- return resultArray.join('/');
322
- }
323
- /**
324
- * Do loading all attributes related to particular node.
325
- * @param sourceChild
326
- * @param attributeStorageInfo
327
- * @returns Promise of attributes object.
328
- */
329
- async _loadChildAttributes(sourceChild, attributeStorageInfo) {
330
- const promises = [];
331
- const { attributeUrls = [] } = sourceChild;
332
- for (let index = 0; index < attributeUrls.length; index++) {
333
- const inputUrl = attributeUrls[index];
334
- const attribute = attributeStorageInfo[index];
335
- const options = {
336
- attributeName: attribute.name,
337
- attributeType: this._getAttributeType(attribute)
338
- };
339
- promises.push(loadFromArchive(inputUrl, I3SAttributeLoader, options, this.slpkFilesystem));
340
- }
341
- const attributesList = await Promise.all(promises);
342
- this._replaceNestedArrays(attributesList);
343
- return Object.assign({}, ...attributesList);
344
- }
345
- /**
346
- * Returns attribute type for loading attributes
347
- * @param attribute
348
- * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
349
- * There is an 'Oid32' type if attribute has objectIds property.
350
- * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
351
- */
352
- _getAttributeType(attribute) {
353
- if (attribute.attributeValues) {
354
- return attribute.attributeValues.valueType;
355
- }
356
- else if (attribute.objectIds) {
357
- return 'Oid32';
358
- }
359
- return '';
360
- }
361
- /**
362
- * Make simple arrays from attribute typed arrays.
363
- * @param attributesList
364
- */
365
- _replaceNestedArrays(attributesList) {
366
- for (let index = 0; index < attributesList.length; index++) {
367
- const attributeObject = attributesList[index];
368
- for (const key in attributeObject) {
369
- attributeObject[key] = Array.from(attributeObject[key]);
370
- }
371
- }
372
- }
373
- /**
374
- * Print statistics in the end of conversion
375
- * @param params - output files data
376
- */
377
- async _finishConversion(params) {
378
- const filesSize = await calculateDatasetSize(params);
379
- const diff = process.hrtime(this.conversionStartTime);
380
- const conversionTime = timeConverter(diff);
381
- console.log(`------------------------------------------------`); // eslint-disable-line
382
- console.log(`Finish conversion of ${I3S}`); // eslint-disable-line
383
- console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line
384
- console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line
385
- console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
386
- console.log(`------------------------------------------------`); // eslint-disable-line
387
- }
388
- }
@@ -1,88 +0,0 @@
1
- import type { I3STileContent, AttributeStorageInfo, I3STileAttributes } from '@loaders.gl/i3s';
2
- import { Matrix4 } from '@math.gl/core';
3
- export type I3SAttributesData = {
4
- tileContent: I3STileContent;
5
- box: number[];
6
- textureFormat: string;
7
- };
8
- /**
9
- * Converts content of an I3S node to 3D Tiles file content
10
- */
11
- export declare class Tiles3DContentConverter {
12
- rtcCenter: Float32Array;
13
- i3sTile: any;
14
- tileType: string;
15
- constructor(options?: {
16
- outputVersion: string;
17
- });
18
- /**
19
- * The starter of content conversion
20
- * @param i3sTile - Tile3D instance for I3S node
21
- * @returns - encoded content
22
- */
23
- convert(i3sAttributesData: I3SAttributesData, featureAttributes?: I3STileAttributes | null, attributeStorageInfo?: AttributeStorageInfo[] | null | undefined): Promise<ArrayBuffer>;
24
- /**
25
- * Build and encode gltf
26
- * @param i3sTile - Tile3D instance for I3S node
27
- * @returns - encoded glb content
28
- */
29
- buildGLTF(i3sAttributesData: I3SAttributesData, featureAttributes: I3STileAttributes | null, attributeStorageInfo?: AttributeStorageInfo[] | null | undefined): Promise<ArrayBuffer>;
30
- private _createMetadataExtensions;
31
- private _createPropertyAttibutes;
32
- private _convertAttributeStorageInfoToPropertyAttribute;
33
- /**
34
- * Update gltfBuilder with texture from I3S tile
35
- * @param {object} i3sTile - Tile3D object
36
- * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
37
- * @returns {Promise<number | null>} - GLTF texture index
38
- */
39
- _addI3sTextureToGLTF(tileContent: any, textureFormat: any, gltfBuilder: any): Promise<null>;
40
- /**
41
- * Generate a positions array which is correct for 3DTiles/GLTF format
42
- * @param {Float64Array} positionsValue - the input geometry positions array
43
- * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
44
- * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
45
- * @param {number[]} modelMatrix - the model matrix of geometry
46
- * @returns {Float32Array} - the output geometry positions array
47
- */
48
- _normalizePositions(positionsValue: any, cartesianOrigin: any, cartographicOrigin: any, modelMatrix: any): Float32Array;
49
- /**
50
- * Generate the transformation matrix for GLTF node:
51
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
52
- * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
53
- * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
54
- * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
55
- * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
56
- */
57
- _generateTransformMatrix(cartesianOrigin: any): Matrix4;
58
- /**
59
- * Create _BATCHID attribute
60
- * @param {Object} i3sContent - the source object
61
- * @returns {void}
62
- */
63
- _createBatchIds(i3sContent: any, featureAttributes: any): void;
64
- /**
65
- * Deduce mime type by format from `textureSetDefinition.formats[0].format`
66
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
67
- * @param {string} format - format name
68
- * @returns {string} mime type.
69
- */
70
- _deduceMimeTypeFromFormat(format: any): "image/jpeg" | "image/png" | "image/ktx2";
71
- /**
72
- * Convert i3s material to GLTF compatible material
73
- * @param {object} material - i3s material definition
74
- * @param {number | null} textureIndex - texture index in GLTF
75
- * @returns {object} GLTF material
76
- */
77
- _convertI3sMaterialToGLTFMaterial(material: any, textureIndex: any): any;
78
- /**
79
- * Set texture properties in material with GLTF textureIndex
80
- * @param {object} materialDefinition - i3s material definition
81
- * @param {number} textureIndex - texture index in GLTF
82
- * @returns {void}
83
- */
84
- _setGLTFTexture(materialDefinition: any, textureIndex: any): any;
85
- _getFeaturesLength(attributes: any): any;
86
- _checkNormals(normals: any): any;
87
- }
88
- //# sourceMappingURL=3d-tiles-content-converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"3d-tiles-content-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/3d-tiles-content-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAE,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAU7F,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAY/C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,cAAc,CAAC;IAC5B,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,qBAAa,uBAAuB;IAElC,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;gBAEL,OAAO,GAAE;QAAC,aAAa,EAAE,MAAM,CAAA;KAA0B;IAKrE;;;;OAIG;IACG,OAAO,CACX,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,GAAE,iBAAiB,GAAG,IAAW,EAClD,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/D,OAAO,CAAC,WAAW,CAAC;IAkBvB;;;;OAIG;IAEG,SAAS,CACb,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,EAC3C,oBAAoB,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,GAAG,SAAS,GAC/D,OAAO,CAAC,WAAW,CAAC;IA8EvB,OAAO,CAAC,yBAAyB;IA0BjC,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,+CAA+C;IA8DvD;;;;;OAKG;IACG,oBAAoB,CAAC,WAAW,KAAA,EAAE,aAAa,KAAA,EAAE,WAAW,KAAA;IAmBlE;;;;;;;OAOG;IACH,mBAAmB,CAAC,cAAc,KAAA,EAAE,eAAe,KAAA,EAAE,kBAAkB,KAAA,EAAE,WAAW,KAAA;IAepF;;;;;;;OAOG;IACH,wBAAwB,CAAC,eAAe,KAAA;IAMxC;;;;OAIG;IACH,eAAe,CAAC,UAAU,KAAA,EAAE,iBAAiB,KAAA;IAoB7C;;;;;OAKG;IACH,yBAAyB,CAAC,MAAM,KAAA;IAchC;;;;;OAKG;IACH,iCAAiC,CAAC,QAAQ,KAAA,EAAE,YAAY,KAAA;IAgCxD;;;;;OAKG;IACH,eAAe,CAAC,kBAAkB,KAAA,EAAE,YAAY,KAAA;IA+ChD,kBAAkB,CAAC,UAAU,KAAA;IAY7B,aAAa,CAAC,OAAO,KAAA;CAItB"}