@loaders.gl/tile-converter 3.3.0-alpha.2 → 3.3.0-alpha.4
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.js +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
- package/dist/converter.min.js +21 -21
- package/dist/deps-installer/deps-installer.d.ts +5 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +21 -1
- package/dist/dist.min.js +671 -1028
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +115 -101
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +70 -6
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +153 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +40 -44
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +10 -2
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +364 -435
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +59 -44
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +21 -2
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +138 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -21
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +93 -183
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.d.ts +5 -1
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +3 -3
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +2 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +32 -0
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +162 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +29 -27
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +50 -30
- package/dist/i3s-converter/helpers/node-pages.d.ts +4 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/i3s-converter/i3s-converter.d.ts +24 -48
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +88 -186
- package/dist/i3s-converter/types.d.ts +4 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
- package/src/deps-installer/deps-installer.ts +29 -2
- package/src/i3s-attributes-worker.ts +5 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -6
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +182 -0
- package/src/i3s-converter/helpers/geometry-converter.ts +45 -36
- package/src/i3s-converter/helpers/gltf-attributes.ts +54 -33
- package/src/i3s-converter/helpers/node-pages.ts +10 -2
- package/src/i3s-converter/i3s-converter.ts +125 -210
- package/src/i3s-converter/types.ts +4 -0
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import type {Image, MeshPrimitive} from 'modules/gltf/src/lib/types/gltf-postprocessed-schema';
|
|
2
1
|
import type {B3DMContent, FeatureTableJson} from '@loaders.gl/3d-tiles';
|
|
3
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
GLTF_EXT_feature_metadata,
|
|
4
|
+
GLTFAccessorPostprocessed,
|
|
5
|
+
GLTFMaterialPostprocessed,
|
|
6
|
+
GLTFNodePostprocessed,
|
|
7
|
+
GLTFImagePostprocessed,
|
|
8
|
+
GLTFMeshPrimitivePostprocessed,
|
|
9
|
+
GLTFMeshPostprocessed,
|
|
10
|
+
GLTFTexturePostprocessed
|
|
11
|
+
} from '@loaders.gl/gltf';
|
|
4
12
|
|
|
5
13
|
import {Vector3, Matrix4, Vector4} from '@math.gl/core';
|
|
6
14
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
7
15
|
|
|
8
16
|
import {DracoWriterWorker} from '@loaders.gl/draco';
|
|
9
17
|
import {assert, encode} from '@loaders.gl/core';
|
|
10
|
-
import {Tile3D} from '@loaders.gl/tiles';
|
|
11
18
|
import {concatenateArrayBuffers, concatenateTypedArrays} from '@loaders.gl/loader-utils';
|
|
12
19
|
import md5 from 'md5';
|
|
13
20
|
import {generateAttributes} from './geometry-attributes';
|
|
@@ -18,7 +25,6 @@ import {
|
|
|
18
25
|
I3SMaterialWithTexture,
|
|
19
26
|
SharedResourcesArrays
|
|
20
27
|
} from '../types';
|
|
21
|
-
import {GLTFMaterialPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';
|
|
22
28
|
import {
|
|
23
29
|
AttributeStorageInfo,
|
|
24
30
|
I3SMaterialDefinition,
|
|
@@ -27,12 +33,8 @@ import {
|
|
|
27
33
|
} from '@loaders.gl/i3s';
|
|
28
34
|
import {TypedArray} from '@loaders.gl/schema';
|
|
29
35
|
import {Geoid} from '@math.gl/geoid';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
GLTFMeshPostprocessed,
|
|
33
|
-
GLTFTexturePostprocessed
|
|
34
|
-
} from 'modules/gltf/src/lib/types/gltf-types';
|
|
35
|
-
import {B3DMAttributesData /*transformI3SAttributesOnWorker */} from '../../i3s-attributes-worker';
|
|
36
|
+
/** Usage of worker here brings more overhead than advantage */
|
|
37
|
+
import {B3DMAttributesData /*, transformI3SAttributesOnWorker*/} from '../../i3s-attributes-worker';
|
|
36
38
|
import {prepareDataForAttributesConversion} from './gltf-attributes';
|
|
37
39
|
import {handleBatchIdsExtensions} from './batch-ids-extensions';
|
|
38
40
|
import {checkPropertiesLength, flattenPropertyTableByFeatureIds} from './feature-attributes';
|
|
@@ -65,7 +67,7 @@ let scratchVector = new Vector3();
|
|
|
65
67
|
* Convert binary data from b3dm file to i3s resources
|
|
66
68
|
*
|
|
67
69
|
* @param tileContent - 3d tile content
|
|
68
|
-
* @param
|
|
70
|
+
* @param addNodeToNodePage - function to add new node to node pages
|
|
69
71
|
* @param featuresHashArray - hash array of features that is needed to not to mix up same features in parent and child nodes
|
|
70
72
|
* @param attributeStorageInfo - attributes metadata from 3DSceneLayer json
|
|
71
73
|
* @param draco - is converter should create draco compressed geometry
|
|
@@ -75,7 +77,7 @@ let scratchVector = new Vector3();
|
|
|
75
77
|
*/
|
|
76
78
|
export default async function convertB3dmToI3sGeometry(
|
|
77
79
|
tileContent: B3DMContent,
|
|
78
|
-
|
|
80
|
+
addNodeToNodePage: () => number,
|
|
79
81
|
propertyTable: FeatureTableJson | null,
|
|
80
82
|
featuresHashArray: string[],
|
|
81
83
|
attributeStorageInfo: AttributeStorageInfo[] | undefined,
|
|
@@ -83,7 +85,7 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
83
85
|
generateBoundingVolumes: boolean,
|
|
84
86
|
geoidHeightModel: Geoid,
|
|
85
87
|
workerSource: {[key: string]: string}
|
|
86
|
-
) {
|
|
88
|
+
): Promise<I3SConvertedResources[] | null> {
|
|
87
89
|
const useCartesianPositions = generateBoundingVolumes;
|
|
88
90
|
const materialAndTextureList: I3SMaterialWithTexture[] = convertMaterials(
|
|
89
91
|
tileContent.gltf?.materials
|
|
@@ -95,14 +97,14 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
95
97
|
dataForAttributesConversion,
|
|
96
98
|
useCartesianPositions
|
|
97
99
|
);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
/** Usage of worker here brings more overhead than advantage */
|
|
101
|
+
// const convertedAttributesMap: Map<string, ConvertedAttributes> =
|
|
102
|
+
// await transformI3SAttributesOnWorker(dataForAttributesConversion, {
|
|
103
|
+
// reuseWorkers: true,
|
|
104
|
+
// _nodeWorkers: true,
|
|
105
|
+
// useCartesianPositions,
|
|
106
|
+
// source: workerSource.I3SAttributes
|
|
107
|
+
// });
|
|
106
108
|
|
|
107
109
|
if (generateBoundingVolumes) {
|
|
108
110
|
_generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
|
|
@@ -115,7 +117,6 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
const result: I3SConvertedResources[] = [];
|
|
118
|
-
let nodesCounter = nodeId;
|
|
119
120
|
let {materials = []} = tileContent.gltf || {materials: []};
|
|
120
121
|
if (!materials?.length) {
|
|
121
122
|
materials.push({id: 'default'});
|
|
@@ -130,13 +131,14 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
130
131
|
continue;
|
|
131
132
|
}
|
|
132
133
|
const {material, texture} = materialAndTextureList[i];
|
|
134
|
+
const nodeId = addNodeToNodePage();
|
|
133
135
|
result.push(
|
|
134
136
|
await _makeNodeResources({
|
|
135
137
|
convertedAttributes,
|
|
136
138
|
material,
|
|
137
139
|
texture,
|
|
138
140
|
tileContent,
|
|
139
|
-
nodeId
|
|
141
|
+
nodeId,
|
|
140
142
|
featuresHashArray,
|
|
141
143
|
propertyTable,
|
|
142
144
|
attributeStorageInfo,
|
|
@@ -144,7 +146,6 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
144
146
|
workerSource
|
|
145
147
|
})
|
|
146
148
|
);
|
|
147
|
-
nodesCounter++;
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
if (!result.length) {
|
|
@@ -274,6 +275,7 @@ async function _makeNodeResources({
|
|
|
274
275
|
}
|
|
275
276
|
|
|
276
277
|
return {
|
|
278
|
+
nodeId,
|
|
277
279
|
geometry: fileBuffer,
|
|
278
280
|
compressedGeometry,
|
|
279
281
|
texture,
|
|
@@ -297,7 +299,7 @@ export async function convertAttributes(
|
|
|
297
299
|
attributesData: B3DMAttributesData,
|
|
298
300
|
useCartesianPositions: boolean
|
|
299
301
|
): Promise<Map<string, ConvertedAttributes>> {
|
|
300
|
-
const {gltfMaterials, nodes, cartographicOrigin, cartesianModelMatrix} = attributesData;
|
|
302
|
+
const {gltfMaterials, nodes, images, cartographicOrigin, cartesianModelMatrix} = attributesData;
|
|
301
303
|
const attributesMap = new Map<string, ConvertedAttributes>();
|
|
302
304
|
|
|
303
305
|
for (const material of gltfMaterials || [{id: 'default'}]) {
|
|
@@ -314,6 +316,7 @@ export async function convertAttributes(
|
|
|
314
316
|
|
|
315
317
|
convertNodes(
|
|
316
318
|
nodes,
|
|
319
|
+
images,
|
|
317
320
|
cartographicOrigin,
|
|
318
321
|
cartesianModelMatrix,
|
|
319
322
|
attributesMap,
|
|
@@ -344,6 +347,7 @@ export async function convertAttributes(
|
|
|
344
347
|
* Gltf has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.
|
|
345
348
|
* The goal is applying tranformation matrix for all children. Functions "convertNodes" and "convertNode" work together recursively.
|
|
346
349
|
* @param nodes - gltf nodes array
|
|
350
|
+
* @param images - gltf images array
|
|
347
351
|
* @param tileContent - 3d tile content
|
|
348
352
|
* @param attributesMap - for recursive concatenation of attributes
|
|
349
353
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
@@ -353,6 +357,7 @@ export async function convertAttributes(
|
|
|
353
357
|
*/
|
|
354
358
|
function convertNodes(
|
|
355
359
|
nodes: GLTFNodePostprocessed[],
|
|
360
|
+
images: GLTFImagePostprocessed[],
|
|
356
361
|
cartographicOrigin: Vector3,
|
|
357
362
|
cartesianModelMatrix: Matrix4,
|
|
358
363
|
attributesMap: Map<string, ConvertedAttributes>,
|
|
@@ -363,6 +368,7 @@ function convertNodes(
|
|
|
363
368
|
for (const node of nodes) {
|
|
364
369
|
convertNode(
|
|
365
370
|
node,
|
|
371
|
+
images,
|
|
366
372
|
cartographicOrigin,
|
|
367
373
|
cartesianModelMatrix,
|
|
368
374
|
attributesMap,
|
|
@@ -406,6 +412,7 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
406
412
|
/**
|
|
407
413
|
* Convert all primitives of node and all children nodes
|
|
408
414
|
* @param node - gltf node
|
|
415
|
+
* @param images - gltf images array
|
|
409
416
|
* @param {Object} tileContent - 3d tile content
|
|
410
417
|
* @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
|
|
411
418
|
* attributes
|
|
@@ -415,6 +422,7 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
415
422
|
*/
|
|
416
423
|
function convertNode(
|
|
417
424
|
node: GLTFNodePostprocessed,
|
|
425
|
+
images: GLTFImagePostprocessed[],
|
|
418
426
|
cartographicOrigin: Vector3,
|
|
419
427
|
cartesianModelMatrix: Matrix4,
|
|
420
428
|
attributesMap: Map<string, ConvertedAttributes>,
|
|
@@ -424,7 +432,6 @@ function convertNode(
|
|
|
424
432
|
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
425
433
|
|
|
426
434
|
const mesh = node.mesh;
|
|
427
|
-
const images = node.images;
|
|
428
435
|
|
|
429
436
|
if (mesh) {
|
|
430
437
|
convertMesh(
|
|
@@ -440,6 +447,7 @@ function convertNode(
|
|
|
440
447
|
|
|
441
448
|
convertNodes(
|
|
442
449
|
node.children || [],
|
|
450
|
+
images,
|
|
443
451
|
cartographicOrigin,
|
|
444
452
|
cartesianModelMatrix,
|
|
445
453
|
attributesMap,
|
|
@@ -461,7 +469,7 @@ function convertNode(
|
|
|
461
469
|
*/
|
|
462
470
|
function convertMesh(
|
|
463
471
|
mesh: GLTFMeshPostprocessed,
|
|
464
|
-
images:
|
|
472
|
+
images: GLTFImagePostprocessed[],
|
|
465
473
|
cartographicOrigin: Vector3,
|
|
466
474
|
cartesianModelMatrix: Matrix4,
|
|
467
475
|
attributesMap: Map<string, ConvertedAttributes>,
|
|
@@ -695,8 +703,8 @@ function getBatchIds(
|
|
|
695
703
|
attributes: {
|
|
696
704
|
[key: string]: GLTFAccessorPostprocessed;
|
|
697
705
|
},
|
|
698
|
-
primitive:
|
|
699
|
-
images:
|
|
706
|
+
primitive: GLTFMeshPrimitivePostprocessed,
|
|
707
|
+
images: GLTFImagePostprocessed[]
|
|
700
708
|
): number[] {
|
|
701
709
|
const batchIds: number[] = handleBatchIdsExtensions(attributes, primitive, images);
|
|
702
710
|
|
|
@@ -1293,15 +1301,16 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
|
1293
1301
|
* Find property table in tile
|
|
1294
1302
|
* For example it can be batchTable for b3dm files or property table in gLTF extension.
|
|
1295
1303
|
* @param sourceTile
|
|
1304
|
+
* @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
1296
1305
|
*/
|
|
1297
|
-
export function getPropertyTable(
|
|
1298
|
-
const batchTableJson =
|
|
1306
|
+
export function getPropertyTable(tileContent: B3DMContent): FeatureTableJson | null {
|
|
1307
|
+
const batchTableJson = tileContent?.batchTableJson;
|
|
1299
1308
|
|
|
1300
1309
|
if (batchTableJson) {
|
|
1301
1310
|
return batchTableJson;
|
|
1302
1311
|
}
|
|
1303
1312
|
|
|
1304
|
-
const {extensionName, extension} = getPropertyTableExtension(
|
|
1313
|
+
const {extensionName, extension} = getPropertyTableExtension(tileContent);
|
|
1305
1314
|
|
|
1306
1315
|
switch (extensionName) {
|
|
1307
1316
|
case EXT_MESH_FEATURES: {
|
|
@@ -1320,9 +1329,9 @@ export function getPropertyTable(sourceTile: Tile3D): FeatureTableJson | null {
|
|
|
1320
1329
|
* Check extensions which can be with property table inside.
|
|
1321
1330
|
* @param sourceTile
|
|
1322
1331
|
*/
|
|
1323
|
-
function getPropertyTableExtension(
|
|
1332
|
+
function getPropertyTableExtension(tileContent: B3DMContent) {
|
|
1324
1333
|
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
|
|
1325
|
-
const extensionsUsed =
|
|
1334
|
+
const extensionsUsed = tileContent?.gltf?.extensionsUsed;
|
|
1326
1335
|
|
|
1327
1336
|
if (!extensionsUsed) {
|
|
1328
1337
|
return {extensionName: null, extension: null};
|
|
@@ -1330,14 +1339,14 @@ function getPropertyTableExtension(sourceTile: Tile3D) {
|
|
|
1330
1339
|
|
|
1331
1340
|
let extensionName: string = '';
|
|
1332
1341
|
|
|
1333
|
-
for (const extensionItem of
|
|
1342
|
+
for (const extensionItem of tileContent?.gltf?.extensionsUsed || []) {
|
|
1334
1343
|
if (extensionsWithPropertyTables.includes(extensionItem)) {
|
|
1335
1344
|
extensionName = extensionItem;
|
|
1336
1345
|
break;
|
|
1337
1346
|
}
|
|
1338
1347
|
}
|
|
1339
1348
|
|
|
1340
|
-
const extension =
|
|
1349
|
+
const extension = tileContent?.gltf?.extensions?.[extensionName];
|
|
1341
1350
|
|
|
1342
1351
|
return {extensionName, extension};
|
|
1343
1352
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {B3DMContent} from '@loaders.gl/3d-tiles';
|
|
2
|
-
import type {
|
|
2
|
+
import type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';
|
|
3
3
|
import type {B3DMAttributesData} from '../../i3s-attributes-worker';
|
|
4
4
|
|
|
5
5
|
type AttributesObject = {
|
|
6
|
-
[k: string]:
|
|
6
|
+
[k: string]: GLTFAccessorPostprocessed;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -38,46 +38,67 @@ export function prepareDataForAttributesConversion(tileContent: B3DMContent): B3
|
|
|
38
38
|
const images =
|
|
39
39
|
tileContent.gltf?.images?.map((imageObject) => {
|
|
40
40
|
// Need data only for uncompressed images because we can't get batchIds from compressed textures.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
if (imageObject?.image?.compressed) {
|
|
42
|
+
return {
|
|
43
|
+
data: null,
|
|
44
|
+
compressed: true
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
const data = imageObject?.image?.data;
|
|
48
|
+
const dataCopy = new Uint8Array(data.length);
|
|
49
|
+
dataCopy.set(data);
|
|
50
|
+
return {
|
|
51
|
+
data: dataCopy,
|
|
52
|
+
compressed: false,
|
|
53
|
+
height: imageObject.image.height,
|
|
54
|
+
width: imageObject.image.width,
|
|
55
|
+
components: imageObject.image.components,
|
|
56
|
+
mimeType: imageObject.mimeType
|
|
57
|
+
};
|
|
58
|
+
}
|
|
50
59
|
}) || [];
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
if (!node.mesh) {
|
|
54
|
-
return node;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
...node,
|
|
59
|
-
images,
|
|
60
|
-
mesh: {
|
|
61
|
-
...node.mesh,
|
|
62
|
-
primitives: node.mesh?.primitives.map((primitive) => ({
|
|
63
|
-
...primitive,
|
|
64
|
-
indices: {value: primitive?.indices?.value},
|
|
65
|
-
attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
|
|
66
|
-
material: {
|
|
67
|
-
id: primitive?.material?.id
|
|
68
|
-
}
|
|
69
|
-
}))
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
});
|
|
61
|
+
prepareNodes(nodes);
|
|
73
62
|
|
|
74
63
|
const cartographicOrigin = tileContent.cartographicOrigin;
|
|
75
64
|
const cartesianModelMatrix = tileContent.cartesianModelMatrix;
|
|
76
65
|
|
|
77
66
|
return {
|
|
78
67
|
gltfMaterials,
|
|
79
|
-
nodes
|
|
68
|
+
nodes,
|
|
69
|
+
images,
|
|
80
70
|
cartographicOrigin,
|
|
81
71
|
cartesianModelMatrix
|
|
82
72
|
};
|
|
83
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.
|
|
77
|
+
* @param nodes
|
|
78
|
+
*/
|
|
79
|
+
function prepareNodes(nodes: GLTFNodePostprocessed[]): void {
|
|
80
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
81
|
+
const node = nodes[index] as any;
|
|
82
|
+
|
|
83
|
+
if (node.mesh) {
|
|
84
|
+
nodes[index] = {
|
|
85
|
+
...node,
|
|
86
|
+
mesh: {
|
|
87
|
+
...node.mesh,
|
|
88
|
+
primitives: node.mesh?.primitives.map((primitive) => ({
|
|
89
|
+
...primitive,
|
|
90
|
+
indices: {value: primitive?.indices?.value},
|
|
91
|
+
attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
|
|
92
|
+
material: {
|
|
93
|
+
id: primitive?.material?.id
|
|
94
|
+
}
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (node.children) {
|
|
101
|
+
prepareNodes(node.children);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -79,6 +79,14 @@ export default class NodePages {
|
|
|
79
79
|
return this.nodePages[pageIndex].nodes[nodeIndex];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Update all fields in the node excluding id
|
|
84
|
+
*/
|
|
85
|
+
updateAll(id: number, data: NodeInPage): void {
|
|
86
|
+
const node = this.getNodeById(id);
|
|
87
|
+
Object.assign(node, data, {index: node.index});
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
/**
|
|
83
91
|
* Update material in node.mesh object by node id
|
|
84
92
|
* @param id - end-to-end index of the node
|
|
@@ -114,7 +122,7 @@ export default class NodePages {
|
|
|
114
122
|
*/
|
|
115
123
|
updateNodeAttributeByNodeId(id: number): void {
|
|
116
124
|
const node = this.getNodeById(id);
|
|
117
|
-
if (!node.mesh) {
|
|
125
|
+
if (!node.mesh || !node.index) {
|
|
118
126
|
return;
|
|
119
127
|
}
|
|
120
128
|
node.mesh.attribute.resource = node.index;
|
|
@@ -164,7 +172,7 @@ export default class NodePages {
|
|
|
164
172
|
* @param node - node object
|
|
165
173
|
*/
|
|
166
174
|
updateResourceInMesh(node: NodeInPage): void {
|
|
167
|
-
if (node.mesh) {
|
|
175
|
+
if (node.mesh && isFinite(node.index)) {
|
|
168
176
|
node.mesh.geometry.resource = node.index;
|
|
169
177
|
}
|
|
170
178
|
}
|