@loaders.gl/tile-converter 5.0.0-alpha.11 → 5.0.0-alpha.14
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/LICENSE +1 -1
- package/README.md +180 -4
- package/bin/converter-v5.js +2 -0
- package/dist/converter.min.cjs +172 -182
- package/dist/i3s-server/bin/i3s-server.min.cjs +113 -158
- package/dist/index.cjs +18832 -19228
- package/dist/index.js +19566 -19968
- package/dist/v5/adapters.cjs +2002 -230
- package/dist/v5/adapters.d.ts +20 -0
- package/dist/v5/adapters.js +2005 -214
- package/dist/v5/archive-source.d.ts +36 -0
- package/dist/v5/browser-tileset-source.d.ts +55 -11
- package/dist/v5/browser.cjs +18 -0
- package/dist/v5/browser.d.ts +15 -1
- package/dist/v5/browser.js +26 -0
- package/dist/v5/conversion-api.d.ts +34 -0
- package/dist/v5/converter-cli.d.ts +1 -0
- package/dist/v5/converter-cli.js +1230 -0
- package/dist/v5/core.cjs +547 -77
- package/dist/v5/core.d.ts +3 -1
- package/dist/v5/core.js +540 -70
- package/dist/v5/feature-arrow.d.ts +1 -1
- package/dist/v5/i3s-mesh-conversion.d.ts +5 -1
- package/dist/v5/i3s-mesh-source-features.d.ts +2 -2
- package/dist/v5/i3s-mesh-source-material.d.ts +1 -1
- package/dist/v5/i3s-mesh-source.d.ts +2 -2
- package/dist/v5/i3s-selection-source.d.ts +70 -0
- package/dist/v5/index.cjs +15 -0
- package/dist/v5/index.d.ts +13 -1
- package/dist/v5/index.js +22 -0
- package/dist/v5/mesh-conversion.d.ts +21 -3
- package/dist/v5/mesh-draco.d.ts +2 -2
- package/dist/v5/mesh-features.d.ts +2 -2
- package/dist/v5/mesh-hierarchy.d.ts +47 -0
- package/dist/v5/mesh-source-features.d.ts +6 -5
- package/dist/v5/mesh-source-schema.d.ts +12 -0
- package/dist/v5/mesh-source-texture.d.ts +3 -3
- package/dist/v5/mesh-source.d.ts +10 -7
- package/dist/v5/mesh-tileset-sink.d.ts +5 -0
- package/dist/v5/mesh.d.ts +1 -1
- package/dist/v5/node-cli.d.ts +9 -0
- package/dist/v5/node-conversion.d.ts +34 -0
- package/dist/v5/node-feature-schema.d.ts +3 -0
- package/dist/v5/node-i3s-source.d.ts +41 -0
- package/dist/v5/node-source.d.ts +47 -0
- package/dist/v5/node.cjs +913 -0
- package/dist/v5/node.d.ts +6 -0
- package/dist/v5/node.js +890 -0
- package/dist/v5/point-cloud-attributes.d.ts +19 -0
- package/dist/v5/point-cloud-conversion.d.ts +1 -1
- package/dist/v5/point-cloud-copc.d.ts +44 -0
- package/dist/v5/point-cloud-file.d.ts +83 -0
- package/dist/v5/point-cloud-potree.d.ts +47 -0
- package/dist/v5/point-cloud-source-encoder.d.ts +1 -1
- package/dist/v5/point-cloud-source.d.ts +1 -1
- package/dist/v5/point-cloud-tileset.d.ts +44 -0
- package/dist/v5/point-cloud.d.ts +1 -1
- package/dist/v5/resource-manifest.d.ts +10 -1
- package/dist/v5/selected-mesh-source.d.ts +53 -0
- package/dist/v5/spatial-conversion.d.ts +1 -1
- package/dist/v5/tileset-source.d.ts +1 -1
- package/package.json +25 -32
- package/src/index.ts +4 -1
- package/src/v4/3d-tiles-converter/3d-tiles-converter.ts +11 -12
- package/src/v4/3d-tiles-converter/helpers/3d-tiles-content-converter.ts +7 -3
- package/src/v4/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts +2 -2
- package/src/v4/3d-tiles-converter/helpers/load-i3s.ts +4 -6
- package/src/v4/3d-tiles-converter/helpers/texture-atlas.ts +1 -1
- package/src/v4/3d-tiles-converter/helpers/validate-i3s-spatial-reference.ts +2 -2
- package/src/v4/3d-tiles-converter/json-templates/tileset.ts +58 -39
- package/src/v4/converter-cli.ts +10 -4
- package/src/v4/deps-installer/deps-installer.ts +3 -3
- package/src/v4/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
- package/src/v4/i3s-converter/helpers/batch-ids-extensions.ts +9 -10
- package/src/v4/i3s-converter/helpers/conversion-gltf.ts +108 -0
- package/src/v4/i3s-converter/helpers/coordinate-converter.ts +6 -5
- package/src/v4/i3s-converter/helpers/create-scene-server-path.ts +5 -6
- package/src/v4/i3s-converter/helpers/feature-attributes.ts +4 -4
- package/src/v4/i3s-converter/helpers/geometry-attributes.ts +1 -1
- package/src/v4/i3s-converter/helpers/geometry-converter.ts +69 -77
- package/src/v4/i3s-converter/helpers/gltf-attributes.ts +58 -74
- package/src/v4/i3s-converter/helpers/load-3d-tiles.ts +6 -54
- package/src/v4/i3s-converter/helpers/node-debug.ts +7 -3
- package/src/v4/i3s-converter/helpers/node-index-document.ts +11 -9
- package/src/v4/i3s-converter/helpers/node-pages.ts +3 -4
- package/src/v4/i3s-converter/helpers/preprocess-3d-tiles.ts +2 -2
- package/src/v4/i3s-converter/helpers/tileset-traversal.ts +1 -1
- package/src/v4/i3s-converter/i3s-converter.ts +29 -31
- package/src/v4/i3s-converter/json-templates/geometry-definitions.ts +71 -66
- package/src/v4/i3s-converter/json-templates/layers.ts +97 -132
- package/src/v4/i3s-converter/json-templates/metadata.ts +31 -21
- package/src/v4/i3s-converter/json-templates/node.ts +60 -74
- package/src/v4/i3s-converter/json-templates/scene-server.ts +36 -27
- package/src/v4/i3s-converter/json-templates/shared-resources.ts +62 -123
- package/src/v4/i3s-converter/json-templates/store.ts +39 -57
- package/src/v4/i3s-converter/types.ts +4 -4
- package/src/v4/i3s-server/controllers/slpk-controller.ts +3 -3
- package/src/v4/i3s-server/utils/create-scene-server.ts +3 -3
- package/src/v4/lib/utils/builder-input.ts +8 -0
- package/src/v4/lib/utils/conversion-dump.ts +5 -1
- package/src/v4/lib/utils/file-utils.ts +1 -1
- package/src/v4/lib/utils/hash-string.ts +21 -0
- package/src/v4/lib/utils/lod-conversion-utils.ts +3 -3
- package/src/v4/pgm-loader.ts +2 -2
- package/src/v5/adapters.ts +53 -0
- package/src/v5/archive-source.ts +235 -0
- package/src/v5/browser-tileset-source.ts +418 -48
- package/src/v5/browser.ts +46 -0
- package/src/v5/conversion-api.ts +184 -17
- package/src/v5/conversion-archive.ts +2 -2
- package/src/v5/converter-cli.ts +28 -0
- package/src/v5/core.ts +7 -0
- package/src/v5/feature-arrow.ts +2 -2
- package/src/v5/i3s-mesh-conversion.ts +41 -3
- package/src/v5/i3s-mesh-sink.ts +1 -1
- package/src/v5/i3s-mesh-source-features.ts +3 -3
- package/src/v5/i3s-mesh-source-material.ts +18 -11
- package/src/v5/i3s-mesh-source.ts +3 -2
- package/src/v5/i3s-selection-source.ts +298 -0
- package/src/v5/index.ts +41 -0
- package/src/v5/mesh-conversion.ts +24 -4
- package/src/v5/mesh-draco.ts +2 -2
- package/src/v5/mesh-features.ts +3 -3
- package/src/v5/mesh-hierarchy.ts +648 -0
- package/src/v5/mesh-source-features.ts +165 -51
- package/src/v5/mesh-source-schema.ts +140 -0
- package/src/v5/mesh-source-texture.ts +49 -19
- package/src/v5/mesh-source.ts +80 -49
- package/src/v5/mesh-tileset-archive.ts +1 -1
- package/src/v5/mesh-tileset-sink.ts +2 -2
- package/src/v5/mesh.ts +1 -1
- package/src/v5/node-cli.ts +201 -0
- package/src/v5/node-conversion.ts +362 -0
- package/src/v5/node-feature-schema.ts +155 -0
- package/src/v5/node-i3s-source.ts +181 -0
- package/src/v5/node-source.ts +328 -0
- package/src/v5/node.ts +16 -0
- package/src/v5/point-cloud-attributes.ts +113 -0
- package/src/v5/point-cloud-conversion.ts +1 -1
- package/src/v5/point-cloud-copc.ts +289 -0
- package/src/v5/point-cloud-file.ts +306 -0
- package/src/v5/point-cloud-potree.ts +134 -0
- package/src/v5/point-cloud-source-encoder.ts +1 -1
- package/src/v5/point-cloud-source.ts +1 -1
- package/src/v5/point-cloud-spatial.ts +2 -2
- package/src/v5/point-cloud-tileset.ts +137 -0
- package/src/v5/point-cloud.ts +3 -3
- package/src/v5/resource-fetcher.ts +4 -1
- package/src/v5/resource-manifest.ts +40 -5
- package/src/v5/selected-mesh-source.ts +384 -0
- package/src/v5/spatial-conversion.ts +90 -19
- package/src/v5/tileset-source.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
|
-
import {Tiles3DTileContent} from '@loaders.gl/3d-tiles';
|
|
2
|
+
import {Tiles3DTileContent} from '@loaders.gl/tiles-3d/3d-tiles';
|
|
3
3
|
import {GLTFPrimitiveModeString, PreprocessData} from '../types';
|
|
4
4
|
import {
|
|
5
5
|
EXT_STRUCTURAL_METADATA,
|
|
@@ -43,7 +43,7 @@ export const analyzeTileContent = async (
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const gltfData = await parse(tileContent.gltfArrayBuffer, GLTFLoader, {
|
|
46
|
-
gltf: {normalize:
|
|
46
|
+
gltf: {normalize: true, loadBuffers: false, loadImages: false, decompressMeshes: false}
|
|
47
47
|
});
|
|
48
48
|
const gltf = gltfData.json;
|
|
49
49
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type {ConversionImage} from './helpers/conversion-gltf';
|
|
1
2
|
// loaders.gl
|
|
2
3
|
// SPDX-License-Identifier: MIT
|
|
3
4
|
// Copyright (c) vis.gl contributors
|
|
@@ -10,7 +11,7 @@ import type {
|
|
|
10
11
|
Tiles3DTileContent,
|
|
11
12
|
Tiles3DTileJSONPostprocessed,
|
|
12
13
|
Tiles3DTilesetJSONPostprocessed
|
|
13
|
-
} from '@loaders.gl/3d-tiles';
|
|
14
|
+
} from '@loaders.gl/tiles-3d/3d-tiles';
|
|
14
15
|
import type {WriteQueueItem} from '../lib/utils/write-queue';
|
|
15
16
|
import type {
|
|
16
17
|
SceneLayer3D,
|
|
@@ -19,15 +20,14 @@ import type {
|
|
|
19
20
|
NodeInPage,
|
|
20
21
|
Attribute,
|
|
21
22
|
Node3DIndexDocument
|
|
22
|
-
} from '@loaders.gl/i3s';
|
|
23
|
+
} from '@loaders.gl/tiles-3d/i3s';
|
|
23
24
|
import {load, encode, isBrowser} from '@loaders.gl/core';
|
|
24
|
-
import {CesiumIonLoader, Tiles3DLoader} from '@loaders.gl/3d-tiles';
|
|
25
|
-
import {Geoid} from '@math.gl/geoid';
|
|
25
|
+
import {CesiumIonLoader, Tiles3DLoader} from '@loaders.gl/tiles-3d/3d-tiles';
|
|
26
|
+
import {Geoid} from '@math.gl/earth/geoid';
|
|
26
27
|
import {join} from 'path';
|
|
27
|
-
import {
|
|
28
|
+
import {randomUUID} from 'node:crypto';
|
|
28
29
|
import process from 'process';
|
|
29
|
-
import
|
|
30
|
-
import md5 from 'md5';
|
|
30
|
+
import {hashString} from '../lib/utils/hash-string';
|
|
31
31
|
|
|
32
32
|
import NodePages from './helpers/node-pages';
|
|
33
33
|
import {writeFile, removeDir, writeFileForSlpk, removeFile} from '../lib/utils/file-utils';
|
|
@@ -42,15 +42,14 @@ import {createSceneServerPath} from './helpers/create-scene-server-path';
|
|
|
42
42
|
import {convertGeometricErrorToScreenThreshold} from '../lib/utils/lod-conversion-utils';
|
|
43
43
|
import {PGMLoader} from '../pgm-loader';
|
|
44
44
|
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
45
|
+
import {createLayers} from './json-templates/layers';
|
|
46
|
+
import {createGeometryDefinition} from './json-templates/geometry-definitions';
|
|
47
|
+
import {createSharedResources} from './json-templates/shared-resources';
|
|
48
48
|
import {validateNodeBoundingVolumes} from './helpers/node-debug';
|
|
49
49
|
import {KTX2BasisWriterWorker} from '@loaders.gl/textures';
|
|
50
|
-
import {LoaderWithParser} from '@loaders.gl/loader-utils';
|
|
51
|
-
import {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s';
|
|
50
|
+
import {LoaderWithParser} from '@loaders.gl/core/loader-utils';
|
|
51
|
+
import {I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/tiles-3d/i3s';
|
|
52
52
|
import {getImageData, ImageWriter} from '@loaders.gl/images';
|
|
53
|
-
import {GLTFImagePostprocessed} from '@loaders.gl/gltf';
|
|
54
53
|
import {
|
|
55
54
|
GLTFPrimitiveModeString,
|
|
56
55
|
I3SConvertedResources,
|
|
@@ -58,7 +57,7 @@ import {
|
|
|
58
57
|
ResourceType,
|
|
59
58
|
SharedResourcesArrays
|
|
60
59
|
} from './types';
|
|
61
|
-
import {WorkerFarm} from '@loaders.gl/worker-utils';
|
|
60
|
+
import {WorkerFarm} from '@loaders.gl/core/worker-utils';
|
|
62
61
|
import WriteQueue from '../lib/utils/write-queue';
|
|
63
62
|
import {BROWSER_ERROR_MESSAGE} from '../constants';
|
|
64
63
|
import {
|
|
@@ -73,12 +72,12 @@ import {
|
|
|
73
72
|
loadFromArchive
|
|
74
73
|
} from './helpers/load-3d-tiles';
|
|
75
74
|
import {Matrix4} from '@math.gl/core';
|
|
76
|
-
import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
|
|
77
|
-
import {TILE_REFINEMENT, createBoundingVolume} from '@loaders.gl/tiles';
|
|
75
|
+
import {BoundingSphere, OrientedBoundingBox} from '@math.gl/geometry/culling';
|
|
76
|
+
import {TILE_REFINEMENT, createBoundingVolume} from '@loaders.gl/tiles-3d';
|
|
78
77
|
import {TraversalConversionProps, traverseDatasetWith} from './helpers/tileset-traversal';
|
|
79
78
|
import {analyzeTileContent, mergePreprocessData} from './helpers/preprocess-3d-tiles';
|
|
80
79
|
import {Progress} from './helpers/progress';
|
|
81
|
-
import {composeHashFile, createZip} from '@loaders.gl/zip';
|
|
80
|
+
import {composeHashFile, createZip} from '@loaders.gl/archives/zip';
|
|
82
81
|
import {ConversionDump, ConversionDumpOptions, DumpMetadata} from '../lib/utils/conversion-dump';
|
|
83
82
|
import {PromptModule} from 'inquirer';
|
|
84
83
|
|
|
@@ -475,7 +474,7 @@ export default class I3SConverter {
|
|
|
475
474
|
|
|
476
475
|
if (this.conversionDump.restored && this.conversionDump.materialDefinitions) {
|
|
477
476
|
for (let i = 0; i < this.conversionDump.materialDefinitions.length; i++) {
|
|
478
|
-
const hash =
|
|
477
|
+
const hash = hashString(JSON.stringify(this.conversionDump.materialDefinitions[i]));
|
|
479
478
|
this.materialMap.set(hash, i);
|
|
480
479
|
}
|
|
481
480
|
this.materialDefinitions = this.conversionDump.materialDefinitions;
|
|
@@ -531,12 +530,11 @@ export default class I3SConverter {
|
|
|
531
530
|
|
|
532
531
|
this.layers0!.materialDefinitions = this.materialDefinitions;
|
|
533
532
|
// @ts-ignore
|
|
534
|
-
this.layers0.geometryDefinitions =
|
|
535
|
-
|
|
533
|
+
this.layers0.geometryDefinitions = this.geometryConfigs
|
|
534
|
+
.map(config => ({
|
|
536
535
|
geometryConfig: {...config, draco: this.options.draco}
|
|
537
|
-
}))
|
|
538
|
-
|
|
539
|
-
);
|
|
536
|
+
}))
|
|
537
|
+
.map(createGeometryDefinition);
|
|
540
538
|
|
|
541
539
|
if (this.layersHasTexture === false) {
|
|
542
540
|
this.layers0!.store.defaultGeometrySchema.ordering =
|
|
@@ -575,12 +573,12 @@ export default class I3SConverter {
|
|
|
575
573
|
}
|
|
576
574
|
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
577
575
|
const layers0data = {
|
|
578
|
-
version: `{${
|
|
576
|
+
version: `{${randomUUID().toUpperCase()}}`,
|
|
579
577
|
id: 0,
|
|
580
578
|
name: tilesetName,
|
|
581
579
|
href: './layers/0',
|
|
582
580
|
store: {
|
|
583
|
-
id: `{${
|
|
581
|
+
id: `{${randomUUID().toUpperCase()}}`,
|
|
584
582
|
extent
|
|
585
583
|
},
|
|
586
584
|
nodePages: {
|
|
@@ -589,7 +587,7 @@ export default class I3SConverter {
|
|
|
589
587
|
compressGeometry: this.options.draco,
|
|
590
588
|
fullExtent
|
|
591
589
|
};
|
|
592
|
-
this.layers0 =
|
|
590
|
+
this.layers0 = createLayers(layers0data);
|
|
593
591
|
}
|
|
594
592
|
|
|
595
593
|
/**
|
|
@@ -1210,7 +1208,7 @@ export default class I3SConverter {
|
|
|
1210
1208
|
return;
|
|
1211
1209
|
}
|
|
1212
1210
|
sharedResources.nodePath = nodePath;
|
|
1213
|
-
const sharedData =
|
|
1211
|
+
const sharedData = createSharedResources(sharedResources);
|
|
1214
1212
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
1215
1213
|
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.SHARED, false);
|
|
1216
1214
|
const slpkSharedPath = join(childPath, 'shared');
|
|
@@ -1233,7 +1231,7 @@ export default class I3SConverter {
|
|
|
1233
1231
|
*/
|
|
1234
1232
|
// eslint-disable-next-line max-statements
|
|
1235
1233
|
private async _writeTexture(
|
|
1236
|
-
texture:
|
|
1234
|
+
texture: ConversionImage,
|
|
1237
1235
|
childPath: string,
|
|
1238
1236
|
slpkChildPath: string,
|
|
1239
1237
|
sourceId: string,
|
|
@@ -1462,7 +1460,7 @@ export default class I3SConverter {
|
|
|
1462
1460
|
* @return material id
|
|
1463
1461
|
*/
|
|
1464
1462
|
private _findOrCreateMaterial(material: I3SMaterialDefinition): number {
|
|
1465
|
-
const hash =
|
|
1463
|
+
const hash = hashString(JSON.stringify(material));
|
|
1466
1464
|
if (this.materialMap.has(hash)) {
|
|
1467
1465
|
return this.materialMap.get(hash) || 0;
|
|
1468
1466
|
}
|
|
@@ -1480,7 +1478,7 @@ export default class I3SConverter {
|
|
|
1480
1478
|
*/
|
|
1481
1479
|
private findOrCreateGeometryDefinition(hasTexture: boolean, hasUvRegions: boolean): number {
|
|
1482
1480
|
const geometryConfig = {hasTexture, hasUvRegions};
|
|
1483
|
-
const hash =
|
|
1481
|
+
const hash = hashString(JSON.stringify(geometryConfig));
|
|
1484
1482
|
if (this.geometryMap.has(hash)) {
|
|
1485
1483
|
return this.geometryMap.get(hash) || 0;
|
|
1486
1484
|
}
|
|
@@ -1508,7 +1506,7 @@ export default class I3SConverter {
|
|
|
1508
1506
|
if (this.options.metadataClass) {
|
|
1509
1507
|
if (!this.attributeMetadataInfo.attributeStorageInfo.length && tileContent?.gltf) {
|
|
1510
1508
|
attributeTypesMap = getAttributeTypesMapFromSchema(
|
|
1511
|
-
tileContent.gltf,
|
|
1509
|
+
tileContent.gltf.json,
|
|
1512
1510
|
this.options.metadataClass
|
|
1513
1511
|
);
|
|
1514
1512
|
}
|
|
@@ -1,83 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import type {BuilderInput} from '../../lib/utils/builder-input';
|
|
6
|
+
|
|
7
|
+
import type {SceneLayer3D} from '@loaders.gl/tiles-3d/i3s';
|
|
8
|
+
/** Legacy geometry layout choices. */
|
|
9
|
+
export type GeometryConfiguration = {
|
|
10
|
+
/** Whether texture coordinates are present. */
|
|
11
|
+
hasTexture?: boolean;
|
|
12
|
+
/** Whether UV regions are present. */
|
|
13
|
+
hasUvRegions?: boolean;
|
|
14
|
+
/** Whether Draco is emitted. */
|
|
15
|
+
draco?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Input to one geometry layout builder. */
|
|
18
|
+
export type GeometryDefinitionInput = {
|
|
19
|
+
/** Geometry layout choices. */
|
|
20
|
+
geometryConfig: GeometryConfiguration;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Builds plain geometry definition with the legacy field selection and defaults. */
|
|
24
|
+
function createPlainGeometryDefinition(
|
|
25
|
+
input: BuilderInput<GeometryConfiguration> | null | undefined
|
|
26
|
+
) {
|
|
27
|
+
const source = input ?? {};
|
|
28
|
+
return {
|
|
29
|
+
offset: 8,
|
|
30
|
+
position: {
|
|
9
31
|
type: 'Float32',
|
|
10
32
|
component: 3
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
normal: {
|
|
14
|
-
default: {
|
|
33
|
+
},
|
|
34
|
+
normal: {
|
|
15
35
|
type: 'Float32',
|
|
16
36
|
component: 3
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
path: 'hasTexture',
|
|
21
|
-
transform: val => (val && {type: 'Float32', component: 2}) || false,
|
|
22
|
-
omitValues: [false]
|
|
23
|
-
},
|
|
24
|
-
color: {
|
|
25
|
-
default: {
|
|
37
|
+
},
|
|
38
|
+
...(source.hasTexture ? {uv0: {type: 'Float32', component: 2}} : {}),
|
|
39
|
+
color: {
|
|
26
40
|
type: 'UInt8',
|
|
27
41
|
component: 4
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
path: 'hasUvRegions',
|
|
32
|
-
transform: val => (val && {type: 'UInt16', component: 4}) || false,
|
|
33
|
-
omitValues: [false]
|
|
34
|
-
},
|
|
35
|
-
featureId: {
|
|
36
|
-
default: {
|
|
42
|
+
},
|
|
43
|
+
...(source.hasUvRegions ? {uvRegion: {type: 'UInt16', component: 4}} : {}),
|
|
44
|
+
featureId: {
|
|
37
45
|
binding: 'per-feature',
|
|
38
46
|
type: 'UInt64',
|
|
39
47
|
component: 1
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
faceRange: {
|
|
43
|
-
default: {
|
|
48
|
+
},
|
|
49
|
+
faceRange: {
|
|
44
50
|
binding: 'per-feature',
|
|
45
51
|
type: 'UInt32',
|
|
46
52
|
component: 2
|
|
47
53
|
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
50
56
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return result;
|
|
57
|
+
/** Builds compressed geometry definition with the legacy field selection and defaults. */
|
|
58
|
+
function createCompressedGeometryDefinition(
|
|
59
|
+
input: BuilderInput<GeometryDefinitionInput> | null | undefined
|
|
60
|
+
) {
|
|
61
|
+
const configuration = input!.geometryConfig!;
|
|
62
|
+
return {
|
|
63
|
+
compressedAttributes: {
|
|
64
|
+
encoding: 'draco',
|
|
65
|
+
attributes: [
|
|
66
|
+
'position',
|
|
67
|
+
'normal',
|
|
68
|
+
...(configuration.hasTexture ? ['uv0'] : []),
|
|
69
|
+
'color',
|
|
70
|
+
...(configuration.hasUvRegions ? ['uv-region'] : []),
|
|
71
|
+
'feature-index'
|
|
72
|
+
]
|
|
68
73
|
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
77
|
+
/** Builds geometry definition with the legacy field selection and defaults. */
|
|
78
|
+
export function createGeometryDefinition(
|
|
79
|
+
input: BuilderInput<GeometryDefinitionInput> | null | undefined
|
|
80
|
+
): NonNullable<SceneLayer3D['geometryDefinitions']>[number] {
|
|
81
|
+
const source = input ?? {};
|
|
82
|
+
return {
|
|
83
|
+
geometryBuffers: [
|
|
84
|
+
createPlainGeometryDefinition(source.geometryConfig),
|
|
85
|
+
...(source.geometryConfig!.draco ? [createCompressedGeometryDefinition(source)] : [])
|
|
86
|
+
]
|
|
87
|
+
} as NonNullable<SceneLayer3D['geometryDefinitions']>[number];
|
|
88
|
+
}
|
|
@@ -1,137 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
wkid: {
|
|
6
|
-
path: 'wkid',
|
|
7
|
-
default: 4326
|
|
8
|
-
},
|
|
9
|
-
latestWkid: {
|
|
10
|
-
path: 'latestWkid',
|
|
11
|
-
default: 4326
|
|
12
|
-
},
|
|
13
|
-
vcsWkid: {
|
|
14
|
-
path: 'vcsWkid',
|
|
15
|
-
default: 5773
|
|
16
|
-
},
|
|
17
|
-
latestVcsWkid: {
|
|
18
|
-
path: 'latestVcsWkid',
|
|
19
|
-
default: 5773
|
|
20
|
-
}
|
|
21
|
-
});
|
|
5
|
+
import type {BuilderInput} from '../../lib/utils/builder-input';
|
|
22
6
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
path: 'heightModel',
|
|
26
|
-
default: 'gravity_related_height'
|
|
27
|
-
},
|
|
28
|
-
vertCRS: {
|
|
29
|
-
path: 'vertCRS',
|
|
30
|
-
default: 'EGM96_Geoid'
|
|
31
|
-
},
|
|
32
|
-
heightUnit: {
|
|
33
|
-
path: 'heightUnit',
|
|
34
|
-
default: 'meter'
|
|
35
|
-
}
|
|
36
|
-
});
|
|
7
|
+
import type {SceneLayer3D} from '@loaders.gl/tiles-3d/i3s';
|
|
8
|
+
import {createStore, type StoreBuilderRecord} from './store';
|
|
37
9
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
10
|
+
/** Partially specified nested records completed by the legacy layer builder. */
|
|
11
|
+
type LayerBuilderRecord = Omit<
|
|
12
|
+
SceneLayer3D,
|
|
13
|
+
'store' | 'nodePages' | 'spatialReference' | 'heightModelInfo' | 'fullExtent'
|
|
14
|
+
> & {
|
|
15
|
+
/** Store values completed with defaults. */
|
|
16
|
+
store: BuilderInput<StoreBuilderRecord>;
|
|
17
|
+
/** Node page settings. */
|
|
18
|
+
nodePages?: BuilderInput<NonNullable<SceneLayer3D['nodePages']>>;
|
|
19
|
+
/** Spatial reference identifiers. */
|
|
20
|
+
spatialReference?: BuilderInput<NonNullable<SceneLayer3D['spatialReference']>>;
|
|
21
|
+
/** Height model settings. */
|
|
22
|
+
heightModelInfo?: BuilderInput<NonNullable<SceneLayer3D['heightModelInfo']>>;
|
|
23
|
+
/** Extent fields retained without defaults. */
|
|
24
|
+
fullExtent?: BuilderInput<NonNullable<SceneLayer3D['fullExtent']>>;
|
|
25
|
+
};
|
|
47
26
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
zmin: {
|
|
62
|
-
path: 'zmin'
|
|
63
|
-
},
|
|
64
|
-
zmax: {
|
|
65
|
-
path: 'zmax'
|
|
66
|
-
}
|
|
67
|
-
});
|
|
27
|
+
/** Builds spatial reference with the legacy field selection and defaults. */
|
|
28
|
+
function createSpatialReference(
|
|
29
|
+
input: BuilderInput<NonNullable<SceneLayer3D['spatialReference']>> | null | undefined
|
|
30
|
+
) {
|
|
31
|
+
const source = input ?? {};
|
|
32
|
+
return {
|
|
33
|
+
wkid: source.wkid ?? 4326,
|
|
34
|
+
latestWkid: source.latestWkid ?? 4326,
|
|
35
|
+
vcsWkid: source.vcsWkid ?? 5773,
|
|
36
|
+
latestVcsWkid: source.latestVcsWkid ?? 5773
|
|
37
|
+
};
|
|
38
|
+
}
|
|
68
39
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
popupInfo: {
|
|
134
|
-
path: 'popupInfo',
|
|
135
|
-
default: null
|
|
136
|
-
}
|
|
137
|
-
});
|
|
40
|
+
/** Builds height model info with the legacy field selection and defaults. */
|
|
41
|
+
function createHeightModelInfo(
|
|
42
|
+
input: BuilderInput<NonNullable<SceneLayer3D['heightModelInfo']>> | null | undefined
|
|
43
|
+
) {
|
|
44
|
+
const source = input ?? {};
|
|
45
|
+
return {
|
|
46
|
+
heightModel: source.heightModel ?? 'gravity_related_height',
|
|
47
|
+
vertCRS: source.vertCRS ?? 'EGM96_Geoid',
|
|
48
|
+
heightUnit: source.heightUnit ?? 'meter'
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Builds node pages with the legacy field selection and defaults. */
|
|
53
|
+
function createNodePages(
|
|
54
|
+
input: BuilderInput<NonNullable<SceneLayer3D['nodePages']>> | null | undefined
|
|
55
|
+
) {
|
|
56
|
+
const source = input ?? {};
|
|
57
|
+
return {
|
|
58
|
+
nodesPerPage: source.nodesPerPage ?? undefined,
|
|
59
|
+
lodSelectionMetricType: source.lodSelectionMetricType ?? 'maxScreenThresholdSQ'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Builds full extent with the legacy field selection and defaults. */
|
|
64
|
+
function createFullExtent(
|
|
65
|
+
input: BuilderInput<NonNullable<SceneLayer3D['fullExtent']>> | null | undefined
|
|
66
|
+
) {
|
|
67
|
+
const source = input ?? {};
|
|
68
|
+
return {
|
|
69
|
+
xmin: source.xmin ?? undefined,
|
|
70
|
+
ymin: source.ymin ?? undefined,
|
|
71
|
+
xmax: source.xmax ?? undefined,
|
|
72
|
+
ymax: source.ymax ?? undefined,
|
|
73
|
+
zmin: source.zmin ?? undefined,
|
|
74
|
+
zmax: source.zmax ?? undefined
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Builds layers with the legacy field selection and defaults. */
|
|
79
|
+
export function createLayers(
|
|
80
|
+
input: BuilderInput<LayerBuilderRecord> | null | undefined
|
|
81
|
+
): SceneLayer3D {
|
|
82
|
+
const source = input ?? {};
|
|
83
|
+
return {
|
|
84
|
+
version: source.version!.toUpperCase(),
|
|
85
|
+
id: source.id ?? 0,
|
|
86
|
+
name: source.name ?? undefined,
|
|
87
|
+
href: source.href ?? './layers/0',
|
|
88
|
+
layerType: source.layerType ?? 'IntegratedMesh',
|
|
89
|
+
spatialReference: createSpatialReference(source.spatialReference),
|
|
90
|
+
capabilities: source.capabilities ?? ['View', 'Query'],
|
|
91
|
+
store: createStore(source.store),
|
|
92
|
+
fullExtent: createFullExtent(source.fullExtent),
|
|
93
|
+
heightModelInfo: createHeightModelInfo(source.heightModelInfo),
|
|
94
|
+
nodePages: createNodePages(source.nodePages),
|
|
95
|
+
materialDefinitions: source.materialDefinitions ?? [],
|
|
96
|
+
textureSetDefinitions: source.textureSetDefinitions ?? [],
|
|
97
|
+
geometryDefinitions: source.geometryDefinitions ?? [],
|
|
98
|
+
attributeStorageInfo: source.attributeStorageInfo ?? [],
|
|
99
|
+
fields: source.fields ?? [],
|
|
100
|
+
popupInfo: source.popupInfo ?? undefined
|
|
101
|
+
} as SceneLayer3D;
|
|
102
|
+
}
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
nodeCount
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {BuilderInput} from '../../lib/utils/builder-input';
|
|
6
|
+
|
|
7
|
+
/** Serialized legacy archive metadata. */
|
|
8
|
+
export type ConversionMetadata = {
|
|
9
|
+
/** Folder layout. */
|
|
10
|
+
folderPattern: string;
|
|
11
|
+
/** Archive compression. */
|
|
12
|
+
archiveCompressionType: string;
|
|
13
|
+
/** Resource compression. */
|
|
14
|
+
resourceCompressionType: string;
|
|
15
|
+
/** I3S version. */
|
|
16
|
+
I3SVersion: string;
|
|
17
|
+
/** Number of nodes. */
|
|
18
|
+
nodeCount?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Builds metadata with the legacy field selection and defaults. */
|
|
22
|
+
export function createMetadata(input: BuilderInput<ConversionMetadata> | null | undefined) {
|
|
23
|
+
const source = input ?? {};
|
|
24
|
+
return {
|
|
25
|
+
folderPattern: source.folderPattern ?? 'BASIC',
|
|
26
|
+
archiveCompressionType: source.archiveCompressionType ?? 'STORE',
|
|
27
|
+
resourceCompressionType: source.resourceCompressionType ?? 'GZIP',
|
|
28
|
+
I3SVersion: source.I3SVersion ?? '1.8',
|
|
29
|
+
nodeCount: source.nodeCount ?? undefined
|
|
30
|
+
};
|
|
31
|
+
}
|