@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.0-alpha.2
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-attributes-worker.d.ts +28 -0
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/3d-tiles-attributes-worker.js +4 -0
- package/dist/3d-tiles-attributes-worker.js.map +7 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +29 -3
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -4
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +10 -10
- package/dist/converter.min.js +20 -20
- package/dist/dist.min.js +789 -645
- package/dist/es5/3d-tiles-attributes-worker.js +29 -0
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +102 -43
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +29 -0
- package/dist/es5/i3s-attributes-worker.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +267 -178
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +230 -195
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/index.js +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +14 -17
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +39 -14
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +61 -0
- package/dist/es5/lib/utils/queue.js.map +1 -0
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +225 -0
- package/dist/es5/lib/utils/write-queue.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/workers/i3s-attributes-worker.js +40 -0
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +16 -0
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +30 -4
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +16 -18
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +16 -0
- package/dist/esm/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +117 -58
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +105 -28
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +6 -8
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +11 -1
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +19 -0
- package/dist/esm/lib/utils/queue.js.map +1 -0
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +88 -0
- package/dist/esm/lib/utils/write-queue.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/workers/i3s-attributes-worker.js +4 -0
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/i3s-attributes-worker.d.ts +33 -0
- package/dist/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/i3s-attributes-worker.js +10 -0
- package/dist/i3s-attributes-worker.js.map +7 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +220 -110
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +13 -8
- package/dist/i3s-converter/i3s-converter.d.ts +7 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +88 -26
- package/dist/i3s-converter/types.d.ts +83 -8
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/utils/compress-util.d.ts +44 -5
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +73 -6
- package/dist/lib/utils/file-utils.d.ts +34 -5
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +40 -1
- package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/lib/utils/lod-conversion-utils.js +21 -2
- package/dist/lib/utils/queue.d.ts +7 -0
- package/dist/lib/utils/queue.d.ts.map +1 -0
- package/dist/lib/utils/queue.js +18 -0
- package/dist/lib/utils/statistic-utills.d.ts +2 -2
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.d.ts +22 -0
- package/dist/lib/utils/write-queue.d.ts.map +1 -0
- package/dist/lib/utils/write-queue.js +62 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/workers/3d-tiles-attributes-worker.js +9 -0
- package/dist/workers/i3s-attributes-worker.d.ts +2 -0
- package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/workers/i3s-attributes-worker.js +5 -0
- package/package.json +20 -17
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +44 -4
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
- package/src/i3s-attributes-worker.ts +46 -0
- package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
- package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
- package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +421 -175
- package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
- package/src/i3s-converter/helpers/node-pages.ts +25 -17
- package/src/i3s-converter/i3s-converter.ts +112 -69
- package/src/i3s-converter/types.ts +90 -8
- package/src/index.ts +1 -0
- package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
- package/src/lib/utils/file-utils.ts +84 -0
- package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
- package/src/lib/utils/queue.ts +17 -0
- package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
- package/src/lib/utils/write-queue.ts +75 -0
- package/src/workers/3d-tiles-attributes-worker.ts +6 -0
- package/src/workers/i3s-attributes-worker.ts +6 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/es5/lib/utils/compress-util.d.ts +0 -53
- package/dist/es5/lib/utils/file-utils.d.ts +0 -43
- package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/esm/lib/utils/compress-util.d.ts +0 -53
- package/dist/esm/lib/utils/file-utils.d.ts +0 -43
- package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/src/lib/utils/compress-util.d.ts +0 -53
- package/src/lib/utils/file-utils.d.ts +0 -43
- package/src/lib/utils/file-utils.js +0 -38
- package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {WorkerObject} from '@loaders.gl/worker-utils';
|
|
2
|
+
import type {FeatureAttribute} from '@loaders.gl/i3s';
|
|
3
|
+
|
|
4
|
+
import {processOnWorker} from '@loaders.gl/worker-utils';
|
|
5
|
+
|
|
6
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
9
|
+
|
|
10
|
+
export type Tile3DAttributesWorkerOptions = {
|
|
11
|
+
featureAttributes: FeatureAttribute | null;
|
|
12
|
+
source: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type I3SAttributesData = {
|
|
16
|
+
tileContent: any;
|
|
17
|
+
textureFormat: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* I3S Attributes Worker to handle B3DM object
|
|
22
|
+
*/
|
|
23
|
+
export const Tile3dAttributesWorker = {
|
|
24
|
+
id: '3d-tiles-attributes',
|
|
25
|
+
name: '3DTiles Attributes Worker',
|
|
26
|
+
module: 'tile-converter',
|
|
27
|
+
version: VERSION,
|
|
28
|
+
options: {
|
|
29
|
+
attributes: null
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Performs I3S attributes transformation
|
|
35
|
+
*/
|
|
36
|
+
export function transform3DTilesAttributesOnWorker(
|
|
37
|
+
i3sAttributesData: I3SAttributesData,
|
|
38
|
+
options: Tile3DAttributesWorkerOptions
|
|
39
|
+
): Promise<ArrayBuffer> {
|
|
40
|
+
return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;
|
|
@@ -4,7 +4,7 @@ import type {Node3D} from '@loaders.gl/3d-tiles';
|
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
import process from 'process';
|
|
6
6
|
import transform from 'json-map-transform';
|
|
7
|
-
import {load} from '@loaders.gl/core';
|
|
7
|
+
import {fetchFile, getLoaderOptions, load} from '@loaders.gl/core';
|
|
8
8
|
import {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';
|
|
9
9
|
import {Tileset3D, Tile3D} from '@loaders.gl/tiles';
|
|
10
10
|
import {Geoid} from '@math.gl/geoid';
|
|
@@ -17,6 +17,12 @@ import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
|
|
|
17
17
|
import {TILESET as tilesetTemplate} from './json-templates/tileset';
|
|
18
18
|
import B3dmConverter from './helpers/b3dm-converter';
|
|
19
19
|
import {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';
|
|
20
|
+
import {
|
|
21
|
+
I3SAttributesData,
|
|
22
|
+
Tile3dAttributesWorker
|
|
23
|
+
/*transform3DTilesAttributesOnWorker*/
|
|
24
|
+
} from '../3d-tiles-attributes-worker';
|
|
25
|
+
import {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';
|
|
20
26
|
|
|
21
27
|
const I3S = 'I3S';
|
|
22
28
|
|
|
@@ -31,6 +37,7 @@ export default class Tiles3DConverter {
|
|
|
31
37
|
geoidHeightModel: Geoid | null;
|
|
32
38
|
sourceTileset: Tileset3D | null;
|
|
33
39
|
attributeStorageInfo: AttributeStorageInfo | null;
|
|
40
|
+
workerSource: {[key: string]: string} = {};
|
|
34
41
|
|
|
35
42
|
constructor() {
|
|
36
43
|
this.options = {};
|
|
@@ -40,6 +47,7 @@ export default class Tiles3DConverter {
|
|
|
40
47
|
this.geoidHeightModel = null;
|
|
41
48
|
this.sourceTileset = null;
|
|
42
49
|
this.attributeStorageInfo = null;
|
|
50
|
+
this.workerSource = {};
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
/**
|
|
@@ -66,6 +74,8 @@ export default class Tiles3DConverter {
|
|
|
66
74
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
67
75
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
68
76
|
|
|
77
|
+
await this.loadWorkers();
|
|
78
|
+
|
|
69
79
|
const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
|
|
70
80
|
|
|
71
81
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, {
|
|
@@ -74,6 +84,7 @@ export default class Tiles3DConverter {
|
|
|
74
84
|
}
|
|
75
85
|
});
|
|
76
86
|
|
|
87
|
+
await this.sourceTileset.tilesetInitializationPromise;
|
|
77
88
|
const rootNode = this.sourceTileset.root!;
|
|
78
89
|
if (!rootNode.header.obb) {
|
|
79
90
|
rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);
|
|
@@ -102,6 +113,10 @@ export default class Tiles3DConverter {
|
|
|
102
113
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
103
114
|
|
|
104
115
|
this._finishConversion({slpk: false, outputPath, tilesetName});
|
|
116
|
+
|
|
117
|
+
// Clean up worker pools
|
|
118
|
+
const workerFarm = WorkerFarm.getWorkerFarm({});
|
|
119
|
+
workerFarm.destroy();
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
/**
|
|
@@ -125,9 +140,12 @@ export default class Tiles3DConverter {
|
|
|
125
140
|
await this.sourceTileset!._loadTile(sourceChild);
|
|
126
141
|
this.vertexCounter += sourceChild.content.vertexCount;
|
|
127
142
|
|
|
128
|
-
let
|
|
143
|
+
let featureAttributes: FeatureAttribute | null = null;
|
|
129
144
|
if (this.attributeStorageInfo) {
|
|
130
|
-
|
|
145
|
+
featureAttributes = await this._loadChildAttributes(
|
|
146
|
+
sourceChild,
|
|
147
|
+
this.attributeStorageInfo
|
|
148
|
+
);
|
|
131
149
|
}
|
|
132
150
|
|
|
133
151
|
if (!sourceChild.header.obb) {
|
|
@@ -143,7 +161,19 @@ export default class Tiles3DConverter {
|
|
|
143
161
|
children: []
|
|
144
162
|
};
|
|
145
163
|
|
|
146
|
-
const
|
|
164
|
+
const i3sAttributesData: I3SAttributesData = {
|
|
165
|
+
tileContent: sourceChild.content,
|
|
166
|
+
textureFormat: sourceChild?.header?.textureFormat
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
|
|
170
|
+
// const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
|
|
171
|
+
// source: this.workerSource.tile3dWorkerSource,
|
|
172
|
+
// featureAttributes
|
|
173
|
+
// });
|
|
174
|
+
|
|
175
|
+
const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);
|
|
176
|
+
|
|
147
177
|
child.content = {
|
|
148
178
|
uri: `${sourceChild.id}.b3dm`,
|
|
149
179
|
boundingVolume
|
|
@@ -290,4 +320,14 @@ export default class Tiles3DConverter {
|
|
|
290
320
|
console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
|
|
291
321
|
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
292
322
|
}
|
|
323
|
+
|
|
324
|
+
private async loadWorkers(): Promise<void> {
|
|
325
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
326
|
+
const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});
|
|
327
|
+
const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);
|
|
328
|
+
const source = await sourceResponse.text();
|
|
329
|
+
|
|
330
|
+
this.workerSource.tile3dWorkerSource = source;
|
|
331
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
332
|
+
}
|
|
293
333
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {I3SAttributesData} from '../../3d-tiles-attributes-worker';
|
|
2
|
+
|
|
1
3
|
import {encodeSync} from '@loaders.gl/core';
|
|
2
4
|
import {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';
|
|
3
5
|
import {Tile3DWriter} from '@loaders.gl/3d-tiles';
|
|
@@ -21,15 +23,17 @@ export default class B3dmConverter {
|
|
|
21
23
|
* @param i3sTile - Tile3D instance for I3S node
|
|
22
24
|
* @returns - encoded content
|
|
23
25
|
*/
|
|
24
|
-
async convert(
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
async convert(
|
|
27
|
+
i3sAttributesData: I3SAttributesData,
|
|
28
|
+
featureAttributes: any = null
|
|
29
|
+
): Promise<ArrayBuffer> {
|
|
30
|
+
const gltf = await this.buildGltf(i3sAttributesData);
|
|
27
31
|
const b3dm = encodeSync(
|
|
28
32
|
{
|
|
29
33
|
gltfEncoded: new Uint8Array(gltf),
|
|
30
34
|
type: 'b3dm',
|
|
31
|
-
featuresLength: this._getFeaturesLength(
|
|
32
|
-
batchTable:
|
|
35
|
+
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
36
|
+
batchTable: featureAttributes
|
|
33
37
|
},
|
|
34
38
|
Tile3DWriter
|
|
35
39
|
);
|
|
@@ -41,7 +45,8 @@ export default class B3dmConverter {
|
|
|
41
45
|
* @param i3sTile - Tile3D instance for I3S node
|
|
42
46
|
* @returns - encoded glb content
|
|
43
47
|
*/
|
|
44
|
-
async buildGltf(
|
|
48
|
+
async buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer> {
|
|
49
|
+
const {tileContent, textureFormat} = i3sAttributesData;
|
|
45
50
|
const {
|
|
46
51
|
material,
|
|
47
52
|
attributes,
|
|
@@ -49,10 +54,10 @@ export default class B3dmConverter {
|
|
|
49
54
|
cartesianOrigin,
|
|
50
55
|
cartographicOrigin,
|
|
51
56
|
modelMatrix
|
|
52
|
-
} =
|
|
57
|
+
} = tileContent;
|
|
53
58
|
const gltfBuilder = new GLTFScenegraph();
|
|
54
59
|
|
|
55
|
-
const textureIndex = await this._addI3sTextureToGltf(
|
|
60
|
+
const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
|
|
56
61
|
const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
|
|
57
62
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
58
63
|
|
|
@@ -101,11 +106,8 @@ export default class B3dmConverter {
|
|
|
101
106
|
* @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
|
|
102
107
|
* @returns {Promise<number | null>} - GLTF texture index
|
|
103
108
|
*/
|
|
104
|
-
async _addI3sTextureToGltf(
|
|
105
|
-
const {
|
|
106
|
-
content: {texture, material, attributes},
|
|
107
|
-
header: {textureFormat}
|
|
108
|
-
} = i3sTile;
|
|
109
|
+
async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
|
|
110
|
+
const {texture, material, attributes} = tileContent;
|
|
109
111
|
let textureIndex = null;
|
|
110
112
|
let selectedTexture = texture;
|
|
111
113
|
if (!texture && material) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {WorkerObject} from '@loaders.gl/worker-utils';
|
|
2
|
+
import type {ConvertedAttributes} from './i3s-converter/types';
|
|
3
|
+
import type {Matrix4, Vector3} from '@math.gl/core';
|
|
4
|
+
|
|
5
|
+
import {processOnWorker} from '@loaders.gl/worker-utils';
|
|
6
|
+
|
|
7
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
8
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
9
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
10
|
+
|
|
11
|
+
export type I3SAttributesWorkerOptions = {
|
|
12
|
+
useCartesianPositions: boolean;
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type B3DMAttributesData = {
|
|
17
|
+
gltfMaterials?: {id: string}[];
|
|
18
|
+
nodes: any;
|
|
19
|
+
cartographicOrigin: Vector3;
|
|
20
|
+
cartesianModelMatrix: Matrix4;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* I3S Attributes Worker to handle B3DM object
|
|
25
|
+
*/
|
|
26
|
+
export const I3SAttributesWorker = {
|
|
27
|
+
id: 'i3s-attributes',
|
|
28
|
+
name: 'I3S Attributes Worker',
|
|
29
|
+
module: 'tile-converter',
|
|
30
|
+
version: VERSION,
|
|
31
|
+
options: {
|
|
32
|
+
useCartesianPositions: false
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Performs I3S attributes transformation
|
|
38
|
+
*/
|
|
39
|
+
export function transformI3SAttributesOnWorker(
|
|
40
|
+
attributesData: B3DMAttributesData,
|
|
41
|
+
options: I3SAttributesWorkerOptions
|
|
42
|
+
): Promise<Map<string, ConvertedAttributes>> {
|
|
43
|
+
return processOnWorker(I3SAttributesWorker, attributesData, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const _typecheckI3SAttributesWorker: WorkerObject = I3SAttributesWorker;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {BoundingVolumes,
|
|
1
|
+
import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';
|
|
2
2
|
|
|
3
3
|
import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
|
|
4
4
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
5
5
|
import {
|
|
6
6
|
OrientedBoundingBox,
|
|
7
7
|
makeOrientedBoundingBoxFromPoints,
|
|
8
|
-
makeBoundingSphereFromPoints
|
|
8
|
+
makeBoundingSphereFromPoints,
|
|
9
|
+
BoundingSphere
|
|
9
10
|
} from '@math.gl/culling';
|
|
10
11
|
import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
|
|
11
12
|
import {Geoid} from '@math.gl/geoid';
|
|
12
|
-
import {Tileset3D} from '@loaders.gl/tiles';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Create bounding volumes object from tile and geoid height model.
|
|
@@ -101,34 +101,39 @@ export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
* Convert common coordinate to
|
|
105
|
-
* @param
|
|
106
|
-
* @
|
|
107
|
-
* @
|
|
104
|
+
* Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
|
|
105
|
+
* @param
|
|
106
|
+
* @param boundingVolume
|
|
107
|
+
* @returns - fullExtent object
|
|
108
108
|
*/
|
|
109
|
-
export function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
export function convertBoundingVolumeToI3SFullExtent(
|
|
110
|
+
boundingVolume: OrientedBoundingBox | BoundingSphere
|
|
111
|
+
): FullExtent {
|
|
112
|
+
let sphere: BoundingSphere;
|
|
113
|
+
if (boundingVolume instanceof BoundingSphere) {
|
|
114
|
+
sphere = boundingVolume;
|
|
115
|
+
} else {
|
|
116
|
+
sphere = boundingVolume.getBoundingSphere();
|
|
113
117
|
}
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
118
|
+
const center: Vector3 = sphere.center;
|
|
119
|
+
const radius: number = sphere.radius;
|
|
120
|
+
const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(
|
|
121
|
+
new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),
|
|
117
122
|
new Vector3()
|
|
118
123
|
);
|
|
119
|
-
const
|
|
120
|
-
new Vector3(
|
|
124
|
+
const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(
|
|
125
|
+
new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),
|
|
121
126
|
new Vector3()
|
|
122
127
|
);
|
|
123
|
-
const isFirstRight = rightTop[0] < leftBottom[0];
|
|
124
|
-
const isFirstTop = rightTop[1] < leftBottom[1];
|
|
125
128
|
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
return {
|
|
130
|
+
xmin: vertexMin[0],
|
|
131
|
+
xmax: vertexMax[0],
|
|
132
|
+
ymin: vertexMin[1],
|
|
133
|
+
ymax: vertexMax[1],
|
|
134
|
+
zmin: vertexMin[2],
|
|
135
|
+
zmax: vertexMax[2]
|
|
136
|
+
};
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {GeometryAttributes,
|
|
1
|
+
import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';
|
|
2
2
|
import {concatenateTypedArrays} from '@loaders.gl/loader-utils';
|
|
3
3
|
|
|
4
4
|
const VALUES_PER_VERTEX = 3;
|
|
@@ -9,8 +9,9 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|
|
|
9
9
|
* @param attributes
|
|
10
10
|
* @returns attirbutes with featureCount, featureIds and changed faceRange.
|
|
11
11
|
*/
|
|
12
|
-
export function generateAttributes(attributes:
|
|
13
|
-
const {positions, normals, texCoords, colors, featureIndices
|
|
12
|
+
export function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {
|
|
13
|
+
const {positions, normals, texCoords, colors, featureIndices} = attributes;
|
|
14
|
+
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
14
15
|
|
|
15
16
|
if (!featureIndices.length) {
|
|
16
17
|
return {
|