@loaders.gl/tile-converter 4.2.0-alpha.5 → 4.2.0-alpha.6
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 +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +42 -22
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +4 -0
- package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/load-i3s.js +3 -28
- package/dist/converter-cli.js +4 -2
- package/dist/converter.min.cjs +95 -95
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +6 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +4 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +2 -2
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +4 -2
- package/dist/i3s-converter/helpers/geometry-attributes.js +6 -5
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +15 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +52 -12
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +12 -14
- package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +18 -11
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +27 -26
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/progress.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/progress.js +23 -18
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +8 -1
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/tileset-traversal.js +12 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +190 -66
- package/dist/i3s-converter/json-templates/node.js +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +69 -69
- package/dist/i3s-server/bin/www.js +6 -4
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
- package/dist/i3s-server/controllers/slpk-controller.js +3 -1
- package/dist/i3s-server/routes/index.js +11 -8
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
- package/dist/i3s-server/routes/slpk-router.js +24 -18
- package/dist/i3s-server/utils/server-utils.d.ts.map +1 -1
- package/dist/i3s-server/utils/server-utils.js +8 -5
- package/dist/index.cjs +419 -211
- package/dist/index.cjs.map +3 -3
- package/dist/lib/utils/cli-utils.d.ts.map +1 -1
- package/dist/lib/utils/cli-utils.js +2 -0
- package/dist/lib/utils/conversion-dump.d.ts +9 -1
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +44 -21
- package/dist/lib/utils/file-utils.d.ts +1 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +10 -12
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/statistic-utills.js +5 -7
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +7 -3
- package/dist/pgm-loader.js +1 -1
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -1
- package/dist/slpk-extractor/slpk-extractor.js +2 -1
- package/dist/slpk-extractor-cli.d.ts.map +1 -1
- package/dist/slpk-extractor-cli.js +16 -8
- package/dist/slpk-extractor.min.cjs +1 -1
- package/package.json +23 -22
- package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -10
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +1 -0
- package/src/3d-tiles-converter/helpers/load-i3s.ts +3 -27
- package/src/converter-cli.ts +4 -2
- package/src/deps-installer/deps-installer.ts +7 -0
- package/src/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -1
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +5 -2
- package/src/i3s-converter/helpers/geometry-attributes.ts +6 -5
- package/src/i3s-converter/helpers/geometry-converter.ts +118 -72
- package/src/i3s-converter/helpers/gltf-attributes.ts +12 -13
- package/src/i3s-converter/helpers/node-index-document.ts +18 -10
- package/src/i3s-converter/helpers/node-pages.ts +27 -29
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -0
- package/src/i3s-converter/helpers/progress.ts +1 -0
- package/src/i3s-converter/helpers/tileset-traversal.ts +22 -13
- package/src/i3s-converter/i3s-converter.ts +173 -114
- package/src/i3s-converter/json-templates/node.ts +1 -1
- package/src/i3s-server/bin/www.ts +6 -4
- package/src/i3s-server/controllers/slpk-controller.ts +4 -2
- package/src/i3s-server/routes/index.ts +10 -7
- package/src/i3s-server/routes/slpk-router.ts +22 -16
- package/src/i3s-server/utils/server-utils.ts +6 -4
- package/src/lib/utils/cli-utils.ts +2 -0
- package/src/lib/utils/conversion-dump.ts +35 -20
- package/src/lib/utils/file-utils.ts +11 -11
- package/src/lib/utils/statistic-utills.ts +5 -6
- package/src/lib/utils/write-queue.ts +2 -2
- package/src/slpk-extractor/slpk-extractor.ts +2 -1
- package/src/slpk-extractor-cli.ts +16 -8
- package/src/lib/utils/statistic-utills.d.ts +0 -25
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
1
2
|
import type {FeatureTableJson, Tiles3DTileContent} from '@loaders.gl/3d-tiles';
|
|
2
3
|
import type {
|
|
3
4
|
GLTFAccessorPostprocessed,
|
|
@@ -95,21 +96,35 @@ let scratchVector = new Vector3();
|
|
|
95
96
|
* @param metadataClass `- user selected feature metadata class name`
|
|
96
97
|
* @returns Array of node resources to create one or more i3s nodes
|
|
97
98
|
*/
|
|
98
|
-
export default async function convertB3dmToI3sGeometry(
|
|
99
|
-
tileContent
|
|
100
|
-
tileTransform
|
|
101
|
-
tileBoundingVolume
|
|
102
|
-
addNodeToNodePage
|
|
103
|
-
propertyTable
|
|
104
|
-
featuresHashArray
|
|
105
|
-
attributeStorageInfo
|
|
106
|
-
draco
|
|
107
|
-
generateBoundingVolumes
|
|
108
|
-
shouldMergeMaterials
|
|
109
|
-
geoidHeightModel
|
|
110
|
-
libraries
|
|
111
|
-
metadataClass
|
|
112
|
-
|
|
99
|
+
export default async function convertB3dmToI3sGeometry({
|
|
100
|
+
tileContent,
|
|
101
|
+
tileTransform,
|
|
102
|
+
tileBoundingVolume,
|
|
103
|
+
addNodeToNodePage,
|
|
104
|
+
propertyTable,
|
|
105
|
+
featuresHashArray,
|
|
106
|
+
attributeStorageInfo,
|
|
107
|
+
draco,
|
|
108
|
+
generateBoundingVolumes,
|
|
109
|
+
shouldMergeMaterials,
|
|
110
|
+
geoidHeightModel,
|
|
111
|
+
libraries,
|
|
112
|
+
metadataClass
|
|
113
|
+
}: {
|
|
114
|
+
tileContent: Tiles3DTileContent;
|
|
115
|
+
tileTransform: Matrix4;
|
|
116
|
+
tileBoundingVolume: OrientedBoundingBox | BoundingSphere;
|
|
117
|
+
addNodeToNodePage: () => Promise<number>;
|
|
118
|
+
propertyTable: FeatureTableJson | null;
|
|
119
|
+
featuresHashArray: string[];
|
|
120
|
+
attributeStorageInfo: AttributeStorageInfo[] | undefined;
|
|
121
|
+
draco: boolean;
|
|
122
|
+
generateBoundingVolumes: boolean;
|
|
123
|
+
shouldMergeMaterials: boolean;
|
|
124
|
+
geoidHeightModel: Geoid;
|
|
125
|
+
libraries: Record<string, string>;
|
|
126
|
+
metadataClass?: string;
|
|
127
|
+
}): Promise<I3SConvertedResources[] | null> {
|
|
113
128
|
const useCartesianPositions = generateBoundingVolumes;
|
|
114
129
|
const materialAndTextureList: I3SMaterialWithTexture[] = await convertMaterials(
|
|
115
130
|
tileContent.gltf?.materials,
|
|
@@ -149,7 +164,7 @@ export default async function convertB3dmToI3sGeometry(
|
|
|
149
164
|
}
|
|
150
165
|
const convertedAttributes = convertedAttributesMap.get(originarMaterialId);
|
|
151
166
|
if (!convertedAttributes) {
|
|
152
|
-
continue;
|
|
167
|
+
continue; // eslint-disable-line no-continue
|
|
153
168
|
}
|
|
154
169
|
const {material, texture} = materialAndTexture;
|
|
155
170
|
const nodeId = await addNodeToNodePage();
|
|
@@ -278,21 +293,22 @@ async function _makeNodeResources({
|
|
|
278
293
|
faceRange.buffer
|
|
279
294
|
)
|
|
280
295
|
);
|
|
296
|
+
// prettier-ignore
|
|
281
297
|
const compressedGeometry = draco
|
|
282
298
|
? generateCompressedGeometry(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
299
|
+
vertexCount,
|
|
300
|
+
convertedAttributes,
|
|
301
|
+
{
|
|
302
|
+
positions,
|
|
303
|
+
normals,
|
|
304
|
+
texCoords: texture ? texCoords : new Float32Array(0),
|
|
305
|
+
colors,
|
|
306
|
+
uvRegions,
|
|
307
|
+
featureIds,
|
|
308
|
+
faceRange
|
|
309
|
+
},
|
|
310
|
+
libraries
|
|
311
|
+
)
|
|
296
312
|
: null;
|
|
297
313
|
|
|
298
314
|
let attributes: ArrayBuffer[] = [];
|
|
@@ -356,21 +372,20 @@ export async function convertAttributes(
|
|
|
356
372
|
}
|
|
357
373
|
}
|
|
358
374
|
|
|
359
|
-
convertNodes(
|
|
375
|
+
convertNodes({
|
|
360
376
|
nodes,
|
|
361
377
|
images,
|
|
362
378
|
cartographicOrigin,
|
|
363
379
|
cartesianModelMatrix,
|
|
364
380
|
attributesMap,
|
|
365
381
|
useCartesianPositions,
|
|
366
|
-
undefined,
|
|
367
382
|
featureTexture
|
|
368
|
-
);
|
|
383
|
+
});
|
|
369
384
|
|
|
370
385
|
for (const attrKey of attributesMap.keys()) {
|
|
371
386
|
const attributes = attributesMap.get(attrKey);
|
|
372
387
|
if (!attributes) {
|
|
373
|
-
continue;
|
|
388
|
+
continue; // eslint-disable-line no-continue
|
|
374
389
|
}
|
|
375
390
|
if (attributes.positions.length === 0) {
|
|
376
391
|
attributesMap.delete(attrKey);
|
|
@@ -401,19 +416,28 @@ export async function convertAttributes(
|
|
|
401
416
|
* @param featureTexture - feature texture key
|
|
402
417
|
* @returns {void}
|
|
403
418
|
*/
|
|
404
|
-
function convertNodes(
|
|
405
|
-
nodes
|
|
406
|
-
images
|
|
407
|
-
cartographicOrigin
|
|
408
|
-
cartesianModelMatrix
|
|
409
|
-
attributesMap
|
|
410
|
-
useCartesianPositions
|
|
411
|
-
matrix
|
|
412
|
-
featureTexture
|
|
413
|
-
|
|
419
|
+
function convertNodes({
|
|
420
|
+
nodes,
|
|
421
|
+
images,
|
|
422
|
+
cartographicOrigin,
|
|
423
|
+
cartesianModelMatrix,
|
|
424
|
+
attributesMap,
|
|
425
|
+
useCartesianPositions,
|
|
426
|
+
matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
|
|
427
|
+
featureTexture
|
|
428
|
+
}: {
|
|
429
|
+
nodes: GLTFNodePostprocessed[];
|
|
430
|
+
images: (TextureImageProperties | null)[];
|
|
431
|
+
cartographicOrigin: Vector3;
|
|
432
|
+
cartesianModelMatrix: Matrix4;
|
|
433
|
+
attributesMap: Map<string, ConvertedAttributes>;
|
|
434
|
+
useCartesianPositions: boolean;
|
|
435
|
+
matrix?: Matrix4;
|
|
436
|
+
featureTexture: string | null;
|
|
437
|
+
}) {
|
|
414
438
|
if (nodes) {
|
|
415
439
|
for (const node of nodes) {
|
|
416
|
-
convertNode(
|
|
440
|
+
convertNode({
|
|
417
441
|
node,
|
|
418
442
|
images,
|
|
419
443
|
cartographicOrigin,
|
|
@@ -422,7 +446,7 @@ function convertNodes(
|
|
|
422
446
|
useCartesianPositions,
|
|
423
447
|
matrix,
|
|
424
448
|
featureTexture
|
|
425
|
-
);
|
|
449
|
+
});
|
|
426
450
|
}
|
|
427
451
|
}
|
|
428
452
|
}
|
|
@@ -470,43 +494,52 @@ function getCompositeTransformationMatrix(node: GLTFNodePostprocessed, matrix: M
|
|
|
470
494
|
* @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
471
495
|
* @param featureTexture - feature texture key
|
|
472
496
|
*/
|
|
473
|
-
function convertNode(
|
|
474
|
-
node
|
|
475
|
-
images
|
|
476
|
-
cartographicOrigin
|
|
477
|
-
cartesianModelMatrix
|
|
478
|
-
attributesMap
|
|
497
|
+
function convertNode({
|
|
498
|
+
node,
|
|
499
|
+
images,
|
|
500
|
+
cartographicOrigin,
|
|
501
|
+
cartesianModelMatrix,
|
|
502
|
+
attributesMap,
|
|
479
503
|
useCartesianPositions,
|
|
480
504
|
matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
|
|
481
|
-
featureTexture
|
|
482
|
-
|
|
505
|
+
featureTexture
|
|
506
|
+
}: {
|
|
507
|
+
node: GLTFNodePostprocessed;
|
|
508
|
+
images: (TextureImageProperties | null)[];
|
|
509
|
+
cartographicOrigin: Vector3;
|
|
510
|
+
cartesianModelMatrix: Matrix4;
|
|
511
|
+
attributesMap: Map<string, ConvertedAttributes>;
|
|
512
|
+
useCartesianPositions: boolean;
|
|
513
|
+
matrix: Matrix4;
|
|
514
|
+
featureTexture: string | null;
|
|
515
|
+
}) {
|
|
483
516
|
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
484
517
|
|
|
485
518
|
const mesh = node.mesh;
|
|
486
519
|
|
|
487
520
|
if (mesh) {
|
|
488
|
-
convertMesh(
|
|
521
|
+
convertMesh({
|
|
489
522
|
mesh,
|
|
490
523
|
images,
|
|
491
524
|
cartographicOrigin,
|
|
492
525
|
cartesianModelMatrix,
|
|
493
526
|
attributesMap,
|
|
494
527
|
useCartesianPositions,
|
|
495
|
-
transformationMatrix,
|
|
528
|
+
matrix: transformationMatrix,
|
|
496
529
|
featureTexture
|
|
497
|
-
);
|
|
530
|
+
});
|
|
498
531
|
}
|
|
499
532
|
|
|
500
|
-
convertNodes(
|
|
501
|
-
node.children || [],
|
|
533
|
+
convertNodes({
|
|
534
|
+
nodes: node.children || [],
|
|
502
535
|
images,
|
|
503
536
|
cartographicOrigin,
|
|
504
537
|
cartesianModelMatrix,
|
|
505
538
|
attributesMap,
|
|
506
539
|
useCartesianPositions,
|
|
507
|
-
transformationMatrix,
|
|
540
|
+
matrix: transformationMatrix,
|
|
508
541
|
featureTexture
|
|
509
|
-
);
|
|
542
|
+
});
|
|
510
543
|
}
|
|
511
544
|
|
|
512
545
|
/**
|
|
@@ -524,16 +557,25 @@ function convertNode(
|
|
|
524
557
|
* @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
525
558
|
* @param featureTexture - feature texture key
|
|
526
559
|
*/
|
|
527
|
-
function convertMesh(
|
|
528
|
-
mesh
|
|
529
|
-
images
|
|
530
|
-
cartographicOrigin
|
|
531
|
-
cartesianModelMatrix
|
|
532
|
-
attributesMap
|
|
560
|
+
function convertMesh({
|
|
561
|
+
mesh,
|
|
562
|
+
images,
|
|
563
|
+
cartographicOrigin,
|
|
564
|
+
cartesianModelMatrix,
|
|
565
|
+
attributesMap,
|
|
533
566
|
useCartesianPositions = false,
|
|
534
|
-
matrix
|
|
535
|
-
featureTexture
|
|
536
|
-
|
|
567
|
+
matrix,
|
|
568
|
+
featureTexture
|
|
569
|
+
}: {
|
|
570
|
+
mesh: GLTFMeshPostprocessed;
|
|
571
|
+
images: (TextureImageProperties | null)[];
|
|
572
|
+
cartographicOrigin: Vector3;
|
|
573
|
+
cartesianModelMatrix: Matrix4;
|
|
574
|
+
attributesMap: Map<string, ConvertedAttributes>;
|
|
575
|
+
useCartesianPositions: boolean;
|
|
576
|
+
matrix: Matrix4;
|
|
577
|
+
featureTexture: string | null;
|
|
578
|
+
}) {
|
|
537
579
|
for (const primitive of mesh.primitives) {
|
|
538
580
|
let outputAttributes: ConvertedAttributes | null | undefined = null;
|
|
539
581
|
let materialUvRegion: Uint16Array | undefined;
|
|
@@ -556,7 +598,7 @@ function convertMesh(
|
|
|
556
598
|
);
|
|
557
599
|
const attributes = primitive.attributes;
|
|
558
600
|
if (!outputAttributes) {
|
|
559
|
-
continue;
|
|
601
|
+
continue; // eslint-disable-line no-continue
|
|
560
602
|
}
|
|
561
603
|
|
|
562
604
|
const indices = normalizeIndices(primitive);
|
|
@@ -647,7 +689,7 @@ function normalizeIndices(primitive: GLTFMeshPrimitivePostprocessed): TypedArray
|
|
|
647
689
|
}
|
|
648
690
|
indices = newIndices;
|
|
649
691
|
}
|
|
650
|
-
return indices
|
|
692
|
+
return indices;
|
|
651
693
|
}
|
|
652
694
|
|
|
653
695
|
/**
|
|
@@ -893,6 +935,7 @@ async function convertMaterials(
|
|
|
893
935
|
* @param materials materials array
|
|
894
936
|
* @returns merged materials array
|
|
895
937
|
*/
|
|
938
|
+
// eslint-disable-next-line max-statements, complexity
|
|
896
939
|
async function mergeAllMaterials(
|
|
897
940
|
materials: I3SMaterialWithTexture[]
|
|
898
941
|
): Promise<I3SMaterialWithTexture[]> {
|
|
@@ -984,6 +1027,7 @@ async function mergeMaterials(
|
|
|
984
1027
|
.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg')
|
|
985
1028
|
.toBuffer();
|
|
986
1029
|
} catch (error) {
|
|
1030
|
+
// eslint-disable-next-line no-console
|
|
987
1031
|
console.log(
|
|
988
1032
|
'Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)'
|
|
989
1033
|
);
|
|
@@ -1035,7 +1079,7 @@ function convertMaterial(sourceMaterial: GLTFMaterialPostprocessed): I3SMaterial
|
|
|
1035
1079
|
}
|
|
1036
1080
|
|
|
1037
1081
|
sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : uuidv4();
|
|
1038
|
-
|
|
1082
|
+
const mergedMaterials: MergedMaterial[] = [{originalMaterialId: sourceMaterial.id}];
|
|
1039
1083
|
if (!texture) {
|
|
1040
1084
|
// Should use default baseColorFactor if it is not present in source material
|
|
1041
1085
|
// https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-pbrmetallicroughness
|
|
@@ -1419,6 +1463,7 @@ function generateAttributeBuffer(type: string, value: any): ArrayBuffer {
|
|
|
1419
1463
|
function getAttributeType(key: string, attributeStorageInfo: any[]): string {
|
|
1420
1464
|
const attribute = attributeStorageInfo.find((attr) => attr.name === key);
|
|
1421
1465
|
if (!attribute) {
|
|
1466
|
+
// eslint-disable-next-line no-console
|
|
1422
1467
|
console.error(
|
|
1423
1468
|
`attribute is null, key=${key}, attributeStorageInfo=${JSON.stringify(
|
|
1424
1469
|
attributeStorageInfo,
|
|
@@ -1429,6 +1474,7 @@ function getAttributeType(key: string, attributeStorageInfo: any[]): string {
|
|
|
1429
1474
|
return '';
|
|
1430
1475
|
}
|
|
1431
1476
|
if (!attribute.attributeValues) {
|
|
1477
|
+
// eslint-disable-next-line no-console
|
|
1432
1478
|
console.error(`attributeValues is null, attribute=${attribute}`);
|
|
1433
1479
|
return '';
|
|
1434
1480
|
}
|
|
@@ -18,7 +18,7 @@ export function prepareDataForAttributesConversion(
|
|
|
18
18
|
tileTransform: Matrix4,
|
|
19
19
|
boundingVolume: OrientedBoundingBox | BoundingSphere
|
|
20
20
|
): GLTFAttributesData {
|
|
21
|
-
|
|
21
|
+
const nodes =
|
|
22
22
|
tileContent.gltf?.scene?.nodes ||
|
|
23
23
|
tileContent.gltf?.scenes?.[0]?.nodes ||
|
|
24
24
|
tileContent.gltf?.nodes ||
|
|
@@ -29,19 +29,18 @@ export function prepareDataForAttributesConversion(
|
|
|
29
29
|
// Need data only for uncompressed images because we can't get batchIds from compressed textures.
|
|
30
30
|
if (imageObject?.image?.compressed) {
|
|
31
31
|
return null;
|
|
32
|
-
} else {
|
|
33
|
-
const data = imageObject?.image?.data;
|
|
34
|
-
const dataCopy = new Uint8Array(data.length);
|
|
35
|
-
dataCopy.set(data);
|
|
36
|
-
return {
|
|
37
|
-
data: dataCopy,
|
|
38
|
-
compressed: false,
|
|
39
|
-
height: imageObject.image.height,
|
|
40
|
-
width: imageObject.image.width,
|
|
41
|
-
components: imageObject.image.components,
|
|
42
|
-
mimeType: imageObject.mimeType
|
|
43
|
-
};
|
|
44
32
|
}
|
|
33
|
+
const data = imageObject?.image?.data;
|
|
34
|
+
const dataCopy = new Uint8Array(data.length);
|
|
35
|
+
dataCopy.set(data);
|
|
36
|
+
return {
|
|
37
|
+
data: dataCopy,
|
|
38
|
+
compressed: false,
|
|
39
|
+
height: imageObject.image.height,
|
|
40
|
+
width: imageObject.image.width,
|
|
41
|
+
components: imageObject.image.components,
|
|
42
|
+
mimeType: imageObject.mimeType
|
|
43
|
+
};
|
|
45
44
|
}) || [];
|
|
46
45
|
|
|
47
46
|
prepareNodes(nodes);
|
|
@@ -85,7 +85,7 @@ export class NodeIndexDocument {
|
|
|
85
85
|
|
|
86
86
|
let data: Node3DIndexDocument | null = this.data;
|
|
87
87
|
if (this.converter.options.instantNodeWriting) {
|
|
88
|
-
data =
|
|
88
|
+
data = await this.load();
|
|
89
89
|
}
|
|
90
90
|
if (data) {
|
|
91
91
|
data.children = data.children ?? [];
|
|
@@ -227,14 +227,21 @@ export class NodeIndexDocument {
|
|
|
227
227
|
* @param converter - I3SConverter instance
|
|
228
228
|
* @returns NodeIndexDocument instance
|
|
229
229
|
*/
|
|
230
|
-
static async createNode(
|
|
231
|
-
parentNode
|
|
232
|
-
boundingVolumes
|
|
233
|
-
lodSelection
|
|
234
|
-
nodeInPage
|
|
235
|
-
resources
|
|
236
|
-
converter
|
|
237
|
-
|
|
230
|
+
static async createNode({
|
|
231
|
+
parentNode,
|
|
232
|
+
boundingVolumes,
|
|
233
|
+
lodSelection,
|
|
234
|
+
nodeInPage,
|
|
235
|
+
resources,
|
|
236
|
+
converter
|
|
237
|
+
}: {
|
|
238
|
+
parentNode: NodeIndexDocument;
|
|
239
|
+
boundingVolumes: BoundingVolumes;
|
|
240
|
+
lodSelection: LodSelection[];
|
|
241
|
+
nodeInPage: NodeInPage;
|
|
242
|
+
resources: I3SConvertedResources;
|
|
243
|
+
converter: I3SConverter;
|
|
244
|
+
}): Promise<NodeIndexDocument> {
|
|
238
245
|
const data = await NodeIndexDocument.createNodeIndexDocument(
|
|
239
246
|
parentNode,
|
|
240
247
|
boundingVolumes,
|
|
@@ -283,6 +290,7 @@ export class NodeIndexDocument {
|
|
|
283
290
|
* @param resources.attributes - feature attributes
|
|
284
291
|
* @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
|
|
285
292
|
*/
|
|
293
|
+
// eslint-disable-next-line complexity
|
|
286
294
|
static async createNodeIndexDocument(
|
|
287
295
|
parentNode: NodeIndexDocument,
|
|
288
296
|
boundingVolumes: BoundingVolumes,
|
|
@@ -290,7 +298,7 @@ export class NodeIndexDocument {
|
|
|
290
298
|
nodeInPage: NodeInPage,
|
|
291
299
|
resources: I3SConvertedResources | DumpMetadata
|
|
292
300
|
): Promise<Node3DIndexDocument> {
|
|
293
|
-
const nodeId = nodeInPage.index
|
|
301
|
+
const nodeId = nodeInPage.index;
|
|
294
302
|
const parentNodeData = await parentNode.load();
|
|
295
303
|
const nodeData = {
|
|
296
304
|
version: parentNodeData.version,
|
|
@@ -99,9 +99,8 @@ export default class NodePages {
|
|
|
99
99
|
if (await isFileExists(fullName)) {
|
|
100
100
|
console.log(`load ${fullName}.`); // eslint-disable-line
|
|
101
101
|
return (await openJson(filePath, fileName)) as {nodes: NodeInPage[]};
|
|
102
|
-
} else {
|
|
103
|
-
return {nodes: []};
|
|
104
102
|
}
|
|
103
|
+
return {nodes: []};
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
/**
|
|
@@ -180,34 +179,33 @@ export default class NodePages {
|
|
|
180
179
|
async saveNode(node: NodeInPage): Promise<void> {
|
|
181
180
|
if (!this.converter.options.instantNodeWriting) {
|
|
182
181
|
return;
|
|
182
|
+
}
|
|
183
|
+
const nodePageIndex = this.getPageIndexByNodeId(node.index);
|
|
184
|
+
const nodePage = await this.getPageByNodeId(node.index);
|
|
185
|
+
const {filePath, fileName} = this.getNodePageFileName(nodePageIndex);
|
|
186
|
+
const nodeToUpdate = await this.getNodeById(node.index, nodePage);
|
|
187
|
+
if (nodeToUpdate) {
|
|
188
|
+
NodePages.updateAll(nodeToUpdate, node);
|
|
183
189
|
} else {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
} else {
|
|
204
|
-
await this.converter.writeQueue.enqueue(
|
|
205
|
-
{
|
|
206
|
-
writePromise: () => this.writeFile(filePath, nodePageStr)
|
|
207
|
-
},
|
|
208
|
-
true
|
|
209
|
-
);
|
|
210
|
-
}
|
|
190
|
+
nodePage.nodes.push(node);
|
|
191
|
+
}
|
|
192
|
+
const nodePageStr = JSON.stringify(nodePage);
|
|
193
|
+
if (this.converter.options.slpk) {
|
|
194
|
+
await this.converter.writeQueue.enqueue(
|
|
195
|
+
{
|
|
196
|
+
archiveKey: `nodePages/${nodePageIndex.toString()}.json.gz`,
|
|
197
|
+
writePromise: () =>
|
|
198
|
+
this.writeFile(filePath, nodePageStr, fileName, true, this.converter.compressList)
|
|
199
|
+
},
|
|
200
|
+
true
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
await this.converter.writeQueue.enqueue(
|
|
204
|
+
{
|
|
205
|
+
writePromise: () => this.writeFile(filePath, nodePageStr)
|
|
206
|
+
},
|
|
207
|
+
true
|
|
208
|
+
);
|
|
211
209
|
}
|
|
212
210
|
}
|
|
213
211
|
|
|
@@ -32,6 +32,7 @@ export class Progress {
|
|
|
32
32
|
private getTime: () => bigint;
|
|
33
33
|
|
|
34
34
|
constructor(options: {threshold?: number; getTime?: () => bigint} = {}) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
35
36
|
this.getTime = options.getTime || process.hrtime.bigint;
|
|
36
37
|
this.threshold = options.threshold || THRESHOLD_DEFAULT;
|
|
37
38
|
}
|
|
@@ -23,14 +23,21 @@ export type TraversalConversionProps = {
|
|
|
23
23
|
* traversal at the some level of the tree
|
|
24
24
|
* @returns void
|
|
25
25
|
*/
|
|
26
|
-
export const traverseDatasetWith = async <TProps>(
|
|
27
|
-
tile
|
|
28
|
-
traversalProps
|
|
29
|
-
processTile
|
|
30
|
-
postprocessTile
|
|
31
|
-
maxDepth
|
|
26
|
+
export const traverseDatasetWith = async <TProps>({
|
|
27
|
+
tile,
|
|
28
|
+
traversalProps,
|
|
29
|
+
processTile,
|
|
30
|
+
postprocessTile,
|
|
31
|
+
maxDepth,
|
|
32
32
|
level = 0
|
|
33
|
-
|
|
33
|
+
}: {
|
|
34
|
+
tile: Tiles3DTileJSONPostprocessed;
|
|
35
|
+
traversalProps: TProps;
|
|
36
|
+
processTile: (tile: Tiles3DTileJSONPostprocessed, traversalProps: TProps) => Promise<TProps>;
|
|
37
|
+
postprocessTile?: (processResults: TProps[], currentTraversalProps: TProps) => Promise<void>;
|
|
38
|
+
maxDepth?: number;
|
|
39
|
+
level?: number;
|
|
40
|
+
}): Promise<void> => {
|
|
34
41
|
if (maxDepth && level > maxDepth) {
|
|
35
42
|
return;
|
|
36
43
|
}
|
|
@@ -38,14 +45,16 @@ export const traverseDatasetWith = async <TProps>(
|
|
|
38
45
|
const newTraversalProps: TProps = await processTile(tile, traversalProps);
|
|
39
46
|
processResults.push(newTraversalProps);
|
|
40
47
|
for (const childTile of tile.children) {
|
|
41
|
-
await traverseDatasetWith(
|
|
42
|
-
childTile,
|
|
43
|
-
newTraversalProps,
|
|
48
|
+
await traverseDatasetWith({
|
|
49
|
+
tile: childTile,
|
|
50
|
+
traversalProps: newTraversalProps,
|
|
44
51
|
processTile,
|
|
45
52
|
postprocessTile,
|
|
46
53
|
maxDepth,
|
|
47
|
-
level + 1
|
|
48
|
-
);
|
|
54
|
+
level: level + 1
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (postprocessTile) {
|
|
58
|
+
await postprocessTile(processResults, traversalProps);
|
|
49
59
|
}
|
|
50
|
-
postprocessTile && (await postprocessTile(processResults, traversalProps));
|
|
51
60
|
};
|