@loaders.gl/tile-converter 4.0.0-alpha.4 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +9 -7
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +78 -18
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +19 -9
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +12 -9
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/converter.min.js +22 -22
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +2 -6
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/dist.min.js +86527 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +35 -3
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +2 -2
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +23 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +88 -42
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/node-debug.d.ts +2 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +2 -4
- package/dist/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.d.ts +83 -111
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +15 -4
- package/dist/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +320 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +158 -65
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +37 -27
- package/dist/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +2 -2
- package/dist/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +16 -12
- package/dist/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +2 -2
- package/dist/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +19 -14
- package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +14 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-converter/types.js.map +1 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +3 -3
- package/dist/pgm-loader.js.map +1 -1
- package/package.json +21 -19
- package/src/3d-tiles-converter/3d-tiles-converter.ts +25 -21
- package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +35 -11
- package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
- package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
- package/src/deps-installer/deps-installer.js +2 -2
- package/src/i3s-converter/helpers/coordinate-converter.ts +62 -9
- package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts} +2 -2
- package/src/i3s-converter/helpers/{geometry-attributes.js → geometry-attributes.ts} +4 -4
- package/src/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/src/i3s-converter/helpers/geometry-converter.js +110 -33
- package/src/i3s-converter/helpers/{node-debug.js → node-debug.ts} +3 -2
- package/src/i3s-converter/helpers/{node-pages.js → node-pages.ts} +41 -26
- package/src/i3s-converter/i3s-converter.ts +214 -136
- package/src/i3s-converter/json-templates/{layers.js → layers.ts} +29 -27
- package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
- package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
- package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
- package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +14 -14
- package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
- package/src/i3s-converter/types.ts +14 -0
- package/src/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/src/pgm-loader.ts +2 -2
- package/dist/lib/geoid-height-model.d.ts +0 -41
- package/dist/lib/geoid-height-model.js +0 -140
- package/dist/lib/geoid-height-model.js.map +0 -1
- package/dist/lib/pgm-parser.d.ts +0 -14
- package/dist/lib/pgm-parser.js +0 -183
- package/dist/lib/pgm-parser.js.map +0 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/src/lib/geoid-height-model.d.ts +0 -41
- package/src/lib/geoid-height-model.js +0 -239
- package/src/lib/pgm-parser.d.ts +0 -14
- package/src/lib/pgm-parser.js +0 -179
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { load, encode } from '@loaders.gl/core';
|
|
3
3
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
4
|
-
import { CesiumIonLoader } from '@loaders.gl/3d-tiles';
|
|
4
|
+
import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
7
7
|
import process from 'process';
|
|
@@ -18,9 +18,10 @@ import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-convers
|
|
|
18
18
|
import { PGMLoader } from '../pgm-loader';
|
|
19
19
|
import { LAYERS as layersTemplate } from './json-templates/layers';
|
|
20
20
|
import { NODE as nodeTemplate } from './json-templates/node';
|
|
21
|
-
import {
|
|
21
|
+
import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
|
|
22
22
|
import { validateNodeBoundingVolumes } from './helpers/node-debug';
|
|
23
23
|
import { KTX2BasisUniversalTextureWriter } from '@loaders.gl/textures';
|
|
24
|
+
import { ImageWriter } from '@loaders.gl/images';
|
|
24
25
|
const ION_DEFAULT_TOKEN = process.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
25
26
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
26
27
|
const _3D_TILES = '3DTILES';
|
|
@@ -30,6 +31,7 @@ const SHORT_INT_TYPE = 'Int32';
|
|
|
30
31
|
const DOUBLE_TYPE = 'double';
|
|
31
32
|
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
32
33
|
const REFRESH_TOKEN_TIMEOUT = 1800;
|
|
34
|
+
const CESIUM_DATASET_PREFIX = 'https://';
|
|
33
35
|
export default class I3SConverter {
|
|
34
36
|
constructor() {
|
|
35
37
|
_defineProperty(this, "nodePages", void 0);
|
|
@@ -54,15 +56,21 @@ export default class I3SConverter {
|
|
|
54
56
|
|
|
55
57
|
_defineProperty(this, "validate", void 0);
|
|
56
58
|
|
|
57
|
-
_defineProperty(this, "boundingVolumeWarnings",
|
|
59
|
+
_defineProperty(this, "boundingVolumeWarnings", []);
|
|
58
60
|
|
|
59
|
-
_defineProperty(this, "conversionStartTime",
|
|
61
|
+
_defineProperty(this, "conversionStartTime", [0, 0]);
|
|
60
62
|
|
|
61
|
-
_defineProperty(this, "refreshTokenTime",
|
|
63
|
+
_defineProperty(this, "refreshTokenTime", [0, 0]);
|
|
62
64
|
|
|
63
|
-
_defineProperty(this, "sourceTileset",
|
|
65
|
+
_defineProperty(this, "sourceTileset", null);
|
|
64
66
|
|
|
65
|
-
_defineProperty(this, "geoidHeightModel",
|
|
67
|
+
_defineProperty(this, "geoidHeightModel", null);
|
|
68
|
+
|
|
69
|
+
_defineProperty(this, "Loader", Tiles3DLoader);
|
|
70
|
+
|
|
71
|
+
_defineProperty(this, "generateTextures", void 0);
|
|
72
|
+
|
|
73
|
+
_defineProperty(this, "generateBoundingVolumes", void 0);
|
|
66
74
|
|
|
67
75
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
68
76
|
this.fileMap = {};
|
|
@@ -78,7 +86,8 @@ export default class I3SConverter {
|
|
|
78
86
|
tilesWithAddRefineCount: 0
|
|
79
87
|
};
|
|
80
88
|
this.validate = false;
|
|
81
|
-
this.
|
|
89
|
+
this.generateTextures = false;
|
|
90
|
+
this.generateBoundingVolumes = false;
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
async convert(options) {
|
|
@@ -93,7 +102,9 @@ export default class I3SConverter {
|
|
|
93
102
|
draco,
|
|
94
103
|
sevenZipExe,
|
|
95
104
|
maxDepth,
|
|
96
|
-
token
|
|
105
|
+
token,
|
|
106
|
+
generateTextures,
|
|
107
|
+
generateBoundingVolumes
|
|
97
108
|
} = options;
|
|
98
109
|
this.options = {
|
|
99
110
|
maxDepth,
|
|
@@ -104,7 +115,10 @@ export default class I3SConverter {
|
|
|
104
115
|
token,
|
|
105
116
|
inputUrl
|
|
106
117
|
};
|
|
107
|
-
this.validate = validate;
|
|
118
|
+
this.validate = Boolean(validate);
|
|
119
|
+
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
120
|
+
this.generateTextures = Boolean(generateTextures);
|
|
121
|
+
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
108
122
|
console.log('Loading egm file...');
|
|
109
123
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
110
124
|
console.log('Loading egm file completed!');
|
|
@@ -115,7 +129,11 @@ export default class I3SConverter {
|
|
|
115
129
|
|
|
116
130
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
117
131
|
const tilesetOptions = {
|
|
118
|
-
loadOptions: {
|
|
132
|
+
loadOptions: {
|
|
133
|
+
basis: {
|
|
134
|
+
format: 'rgba32'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
119
137
|
};
|
|
120
138
|
|
|
121
139
|
if (preloadOptions.headers) {
|
|
@@ -125,11 +143,11 @@ export default class I3SConverter {
|
|
|
125
143
|
}
|
|
126
144
|
|
|
127
145
|
Object.assign(tilesetOptions, preloadOptions);
|
|
128
|
-
const sourceTilesetJson = await load(inputUrl,
|
|
146
|
+
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
129
147
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
130
148
|
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
131
149
|
await this._finishConversion({
|
|
132
|
-
slpk,
|
|
150
|
+
slpk: Boolean(slpk),
|
|
133
151
|
outputPath,
|
|
134
152
|
tilesetName
|
|
135
153
|
});
|
|
@@ -152,6 +170,7 @@ export default class I3SConverter {
|
|
|
152
170
|
const sourceRootTile = this.sourceTileset.root;
|
|
153
171
|
const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel);
|
|
154
172
|
const parentId = this.nodePages.push({
|
|
173
|
+
index: 0,
|
|
155
174
|
lodThreshold: 0,
|
|
156
175
|
obb: boundingVolumes.obb,
|
|
157
176
|
children: []
|
|
@@ -185,7 +204,7 @@ export default class I3SConverter {
|
|
|
185
204
|
},
|
|
186
205
|
compressGeometry: this.options.draco
|
|
187
206
|
};
|
|
188
|
-
this.layers0 = transform(layers0data, layersTemplate);
|
|
207
|
+
this.layers0 = transform(layers0data, layersTemplate());
|
|
189
208
|
}
|
|
190
209
|
|
|
191
210
|
_formRootNodeIndexDocument(boundingVolumes) {
|
|
@@ -203,13 +222,14 @@ export default class I3SConverter {
|
|
|
203
222
|
...boundingVolumes,
|
|
204
223
|
children: []
|
|
205
224
|
};
|
|
206
|
-
return transform(root0data, nodeTemplate);
|
|
225
|
+
return transform(root0data, nodeTemplate());
|
|
207
226
|
}
|
|
208
227
|
|
|
209
228
|
async _convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes) {
|
|
210
229
|
await this.sourceTileset._loadTile(sourceRootTile);
|
|
211
230
|
|
|
212
|
-
if (
|
|
231
|
+
if (this.isContentSupported(sourceRootTile)) {
|
|
232
|
+
root0.children = root0.children || [];
|
|
213
233
|
root0.children.push({
|
|
214
234
|
id: '1',
|
|
215
235
|
href: './1',
|
|
@@ -296,14 +316,15 @@ export default class I3SConverter {
|
|
|
296
316
|
});
|
|
297
317
|
await sourceTile.unloadContent();
|
|
298
318
|
} else {
|
|
299
|
-
const boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
300
319
|
const children = await this._createNode(parentNode, sourceTile, parentId, level);
|
|
320
|
+
parentNode.children = parentNode.children || [];
|
|
301
321
|
|
|
302
322
|
for (const child of children) {
|
|
303
323
|
parentNode.children.push({
|
|
304
324
|
id: child.id,
|
|
305
325
|
href: "../".concat(child.path),
|
|
306
|
-
|
|
326
|
+
obb: child.obb,
|
|
327
|
+
mbs: child.mbs
|
|
307
328
|
});
|
|
308
329
|
childNodes.push(child);
|
|
309
330
|
}
|
|
@@ -317,18 +338,22 @@ export default class I3SConverter {
|
|
|
317
338
|
|
|
318
339
|
async _addNeighborsAndWriteFile(parentNode, childNodes) {
|
|
319
340
|
for (const node of childNodes) {
|
|
341
|
+
var _parentNode$children;
|
|
342
|
+
|
|
320
343
|
const childPath = join(this.layers0Path, 'nodes', node.path);
|
|
321
344
|
const nodePath = node.path;
|
|
322
345
|
delete node.path;
|
|
323
346
|
|
|
324
|
-
if (parentNode.children.length < 1000) {
|
|
325
|
-
for (const neighbor of parentNode.children) {
|
|
347
|
+
if (Number(parentNode === null || parentNode === void 0 ? void 0 : (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.length) < 1000) {
|
|
348
|
+
for (const neighbor of parentNode.children || []) {
|
|
326
349
|
if (node.id === neighbor.id) {
|
|
327
350
|
continue;
|
|
328
351
|
}
|
|
329
352
|
|
|
330
|
-
node.neighbors
|
|
331
|
-
|
|
353
|
+
if (node.neighbors) {
|
|
354
|
+
node.neighbors.push({ ...neighbor
|
|
355
|
+
});
|
|
356
|
+
}
|
|
332
357
|
}
|
|
333
358
|
} else {
|
|
334
359
|
console.warn("Node ".concat(node.id, ": neighbors attribute is omited because of large number of neigbors"));
|
|
@@ -349,11 +374,7 @@ export default class I3SConverter {
|
|
|
349
374
|
|
|
350
375
|
await this._updateTilesetOptions();
|
|
351
376
|
await this.sourceTileset._loadTile(sourceTile);
|
|
352
|
-
|
|
353
|
-
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
354
|
-
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
355
|
-
maxError: 0
|
|
356
|
-
};
|
|
377
|
+
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
357
378
|
const batchTable = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content = sourceTile.content) === null || _sourceTile$content === void 0 ? void 0 : _sourceTile$content.batchTableJson;
|
|
358
379
|
|
|
359
380
|
if (batchTable) {
|
|
@@ -362,6 +383,7 @@ export default class I3SConverter {
|
|
|
362
383
|
|
|
363
384
|
const resourcesData = await this._convertResources(sourceTile);
|
|
364
385
|
const nodes = [];
|
|
386
|
+
const nodesInPage = [];
|
|
365
387
|
const emptyResources = {
|
|
366
388
|
geometry: null,
|
|
367
389
|
compressedGeometry: null,
|
|
@@ -370,10 +392,20 @@ export default class I3SConverter {
|
|
|
370
392
|
meshMaterial: null,
|
|
371
393
|
vertexCount: null,
|
|
372
394
|
attributes: null,
|
|
373
|
-
featureCount: null
|
|
395
|
+
featureCount: null,
|
|
396
|
+
boundingVolumes: null
|
|
374
397
|
};
|
|
375
398
|
|
|
376
399
|
for (const resources of resourcesData || [emptyResources]) {
|
|
400
|
+
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
401
|
+
boundingVolumes = resources.boundingVolumes;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
405
|
+
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
406
|
+
maxError: 0
|
|
407
|
+
};
|
|
408
|
+
|
|
377
409
|
const nodeInPage = this._createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
|
|
378
410
|
|
|
379
411
|
const node = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
@@ -391,33 +423,37 @@ export default class I3SConverter {
|
|
|
391
423
|
}
|
|
392
424
|
|
|
393
425
|
nodes.push(node);
|
|
426
|
+
nodesInPage.push(nodeInPage);
|
|
394
427
|
}
|
|
395
428
|
|
|
396
429
|
sourceTile.unloadContent();
|
|
397
|
-
const firstNode = nodes[0];
|
|
398
430
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
399
|
-
parentNode:
|
|
431
|
+
parentNode: nodes[0],
|
|
400
432
|
sourceTiles: sourceTile.children,
|
|
401
|
-
parentId:
|
|
433
|
+
parentId: nodesInPage[0].index,
|
|
402
434
|
level: level + 1
|
|
403
435
|
});
|
|
404
436
|
return nodes;
|
|
405
437
|
}
|
|
406
438
|
|
|
407
439
|
_convertAttributeStorageInfo(sourceTileContent) {
|
|
440
|
+
var _this$layers, _this$layers$attribut;
|
|
441
|
+
|
|
408
442
|
const batchTable = sourceTileContent && sourceTileContent.batchTableJson;
|
|
409
443
|
|
|
410
|
-
if (batchTable && !this.layers0.attributeStorageInfo.length) {
|
|
444
|
+
if (batchTable && !((_this$layers = this.layers0) !== null && _this$layers !== void 0 && (_this$layers$attribut = _this$layers.attributeStorageInfo) !== null && _this$layers$attribut !== void 0 && _this$layers$attribut.length)) {
|
|
411
445
|
this._convertBatchTableInfoToNodeAttributes(batchTable);
|
|
412
446
|
}
|
|
413
447
|
}
|
|
414
448
|
|
|
415
449
|
async _convertResources(sourceTile) {
|
|
416
|
-
|
|
450
|
+
var _this$layers2;
|
|
451
|
+
|
|
452
|
+
if (!this.isContentSupported(sourceTile)) {
|
|
417
453
|
return null;
|
|
418
454
|
}
|
|
419
455
|
|
|
420
|
-
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0.attributeStorageInfo, this.options.draco);
|
|
456
|
+
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel);
|
|
421
457
|
return resourcesData;
|
|
422
458
|
}
|
|
423
459
|
|
|
@@ -430,18 +466,24 @@ export default class I3SConverter {
|
|
|
430
466
|
geometry
|
|
431
467
|
} = resources;
|
|
432
468
|
const nodeInPage = {
|
|
469
|
+
index: 0,
|
|
433
470
|
lodThreshold: maxScreenThresholdSQ.maxError,
|
|
434
471
|
obb: boundingVolumes.obb,
|
|
435
|
-
children: []
|
|
436
|
-
mesh: null
|
|
472
|
+
children: []
|
|
437
473
|
};
|
|
438
474
|
|
|
439
|
-
if (geometry &&
|
|
475
|
+
if (geometry && this.isContentSupported(sourceTile)) {
|
|
440
476
|
nodeInPage.mesh = {
|
|
441
477
|
geometry: {
|
|
442
|
-
definition: texture ? 0 : 1
|
|
478
|
+
definition: texture ? 0 : 1,
|
|
479
|
+
resource: 0
|
|
443
480
|
},
|
|
444
|
-
attribute: {
|
|
481
|
+
attribute: {
|
|
482
|
+
resource: 0
|
|
483
|
+
},
|
|
484
|
+
material: {
|
|
485
|
+
definition: 0
|
|
486
|
+
}
|
|
445
487
|
};
|
|
446
488
|
}
|
|
447
489
|
|
|
@@ -492,9 +534,11 @@ export default class I3SConverter {
|
|
|
492
534
|
children: [],
|
|
493
535
|
neighbors: []
|
|
494
536
|
};
|
|
495
|
-
const node = transform(nodeData, nodeTemplate);
|
|
537
|
+
const node = transform(nodeData, nodeTemplate());
|
|
496
538
|
|
|
497
539
|
if (nodeInPage.mesh) {
|
|
540
|
+
var _this$layers3, _this$layers3$attribu;
|
|
541
|
+
|
|
498
542
|
node.geometryData = [{
|
|
499
543
|
href: './geometries/0'
|
|
500
544
|
}];
|
|
@@ -510,7 +554,7 @@ export default class I3SConverter {
|
|
|
510
554
|
}];
|
|
511
555
|
}
|
|
512
556
|
|
|
513
|
-
if (attributes && attributes.length && this.layers0.attributeStorageInfo &&
|
|
557
|
+
if (attributes && attributes.length && (_this$layers3 = this.layers0) !== null && _this$layers3 !== void 0 && (_this$layers3$attribu = _this$layers3.attributeStorageInfo) !== null && _this$layers3$attribu !== void 0 && _this$layers3$attribu.length) {
|
|
514
558
|
node.attributeData = [];
|
|
515
559
|
|
|
516
560
|
for (let index = 0; index < attributes.length; index++) {
|
|
@@ -563,7 +607,7 @@ export default class I3SConverter {
|
|
|
563
607
|
|
|
564
608
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
565
609
|
sharedResources.nodePath = nodePath;
|
|
566
|
-
const sharedData = transform(sharedResources,
|
|
610
|
+
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
567
611
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
568
612
|
|
|
569
613
|
if (this.options.slpk) {
|
|
@@ -577,39 +621,75 @@ export default class I3SConverter {
|
|
|
577
621
|
|
|
578
622
|
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
579
623
|
if (texture) {
|
|
580
|
-
const format = this._getFormatByMimeType(texture.mimeType);
|
|
624
|
+
const format = this._getFormatByMimeType(texture === null || texture === void 0 ? void 0 : texture.mimeType);
|
|
625
|
+
|
|
626
|
+
const formats = [];
|
|
627
|
+
const textureData = texture.bufferView.data;
|
|
628
|
+
|
|
629
|
+
switch (format) {
|
|
630
|
+
case 'jpg':
|
|
631
|
+
case 'png':
|
|
632
|
+
{
|
|
633
|
+
formats.push({
|
|
634
|
+
name: '0',
|
|
635
|
+
format
|
|
636
|
+
});
|
|
637
|
+
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
638
|
+
|
|
639
|
+
if (this.generateTextures) {
|
|
640
|
+
formats.push({
|
|
641
|
+
name: '1',
|
|
642
|
+
format: 'ktx2'
|
|
643
|
+
});
|
|
644
|
+
const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
|
|
645
|
+
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
case 'ktx2':
|
|
652
|
+
{
|
|
653
|
+
formats.push({
|
|
654
|
+
name: '1',
|
|
655
|
+
format
|
|
656
|
+
});
|
|
657
|
+
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
658
|
+
|
|
659
|
+
if (this.generateTextures) {
|
|
660
|
+
formats.push({
|
|
661
|
+
name: '0',
|
|
662
|
+
format: 'jpg'
|
|
663
|
+
});
|
|
664
|
+
const decodedFromKTX2TextureData = new Uint8Array(await encode(texture.image.data[0], ImageWriter));
|
|
665
|
+
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
581
669
|
|
|
582
670
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
583
671
|
this.layers0.textureSetDefinitions.push({
|
|
584
|
-
formats
|
|
585
|
-
name: '0',
|
|
586
|
-
format
|
|
587
|
-
}, {
|
|
588
|
-
name: '1',
|
|
589
|
-
format: 'ktx2'
|
|
590
|
-
}]
|
|
672
|
+
formats
|
|
591
673
|
});
|
|
592
674
|
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
593
677
|
|
|
594
|
-
|
|
595
|
-
|
|
678
|
+
async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
|
|
679
|
+
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
680
|
+
await writeFile(texturePath, textureData, "index.".concat(format));
|
|
596
681
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
this.fileMap["".concat(slpkChildPath, "/textures/1.ktx2")] = await writeFileForSlpk(slpkTexturePath, ktx2TextureData, "1.ktx2", compress);
|
|
602
|
-
} else {
|
|
603
|
-
const texturePath = join(childPath, 'textures/0/');
|
|
604
|
-
await writeFile(texturePath, textureData, "index.".concat(format));
|
|
605
|
-
const ktx2TexturePath = join(childPath, 'textures/1/');
|
|
606
|
-
await writeFile(ktx2TexturePath, ktx2TextureData, "index.ktx2");
|
|
607
|
-
}
|
|
682
|
+
if (this.options.slpk) {
|
|
683
|
+
const slpkTexturePath = join(childPath, 'textures');
|
|
684
|
+
const compress = false;
|
|
685
|
+
this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
|
|
608
686
|
}
|
|
609
687
|
}
|
|
610
688
|
|
|
611
689
|
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
612
|
-
|
|
690
|
+
var _this$layers4, _this$layers4$attribu;
|
|
691
|
+
|
|
692
|
+
if (attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
|
|
613
693
|
for (let index = 0; index < attributes.length; index++) {
|
|
614
694
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
615
695
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
@@ -633,6 +713,9 @@ export default class I3SConverter {
|
|
|
633
713
|
case 'image/png':
|
|
634
714
|
return 'png';
|
|
635
715
|
|
|
716
|
+
case 'image/ktx2':
|
|
717
|
+
return 'ktx2';
|
|
718
|
+
|
|
636
719
|
default:
|
|
637
720
|
return 'jpg';
|
|
638
721
|
}
|
|
@@ -839,12 +922,16 @@ export default class I3SConverter {
|
|
|
839
922
|
}
|
|
840
923
|
|
|
841
924
|
async _fetchPreloadOptions() {
|
|
925
|
+
if (!this.Loader.preload) {
|
|
926
|
+
return {};
|
|
927
|
+
}
|
|
928
|
+
|
|
842
929
|
const options = {
|
|
843
930
|
'cesium-ion': {
|
|
844
931
|
accessToken: this.options.token || ION_DEFAULT_TOKEN
|
|
845
932
|
}
|
|
846
933
|
};
|
|
847
|
-
const preloadOptions = await
|
|
934
|
+
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
848
935
|
this.refreshTokenTime = process.hrtime();
|
|
849
936
|
return { ...options,
|
|
850
937
|
...preloadOptions
|
|
@@ -883,5 +970,11 @@ export default class I3SConverter {
|
|
|
883
970
|
this.refinementCounter.tilesCount += 1;
|
|
884
971
|
}
|
|
885
972
|
|
|
973
|
+
isContentSupported(sourceRootTile) {
|
|
974
|
+
var _sourceRootTile$conte;
|
|
975
|
+
|
|
976
|
+
return ['b3dm', 'glTF'].includes(sourceRootTile === null || sourceRootTile === void 0 ? void 0 : (_sourceRootTile$conte = sourceRootTile.content) === null || _sourceRootTile$conte === void 0 ? void 0 : _sourceRootTile$conte.type);
|
|
977
|
+
}
|
|
978
|
+
|
|
886
979
|
}
|
|
887
980
|
//# sourceMappingURL=i3s-converter.js.map
|