@loaders.gl/gltf 4.0.0-alpha.23 → 4.0.0-alpha.25
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/dist.min.js +378 -241
- package/dist/es5/index.js +12 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/api/gltf-extensions.js +1 -1
- package/dist/es5/lib/api/gltf-extensions.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_mesh_features.js +13 -25
- package/dist/es5/lib/extensions/EXT_mesh_features.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_structural_metadata.js +152 -106
- package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +64 -16
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/es5/lib/extensions/{data-processing.js → utils/3d-tiles-utils.js} +51 -24
- package/dist/es5/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- package/dist/es5/lib/gltf-utils/gltf-utils.js +29 -0
- package/dist/es5/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js +2 -0
- package/dist/es5/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
- package/dist/es5/lib/types/gltf-ext-mesh-features-schema.js.map +1 -1
- package/dist/es5/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -1
- package/dist/es5/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/es5/lib/types/gltf-types.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/gltf-extensions.js +1 -1
- package/dist/esm/lib/api/gltf-extensions.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_mesh_features.js +13 -25
- package/dist/esm/lib/extensions/EXT_mesh_features.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_structural_metadata.js +127 -89
- package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +64 -17
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js.map +1 -1
- package/dist/esm/lib/extensions/{data-processing.js → utils/3d-tiles-utils.js} +50 -24
- package/dist/esm/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- package/dist/esm/lib/gltf-utils/gltf-utils.js +30 -0
- package/dist/esm/lib/gltf-utils/gltf-utils.js.map +1 -1
- package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js +2 -0
- package/dist/esm/lib/types/gltf-ext-feature-metadata-schema.js.map +1 -0
- package/dist/esm/lib/types/gltf-ext-mesh-features-schema.js.map +1 -1
- package/dist/esm/lib/types/gltf-ext-structural-metadata-schema.js.map +1 -1
- package/dist/esm/lib/types/gltf-json-schema.js.map +1 -1
- package/dist/esm/lib/types/gltf-types.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_mesh_features.d.ts.map +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.d.ts +12 -4
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts +9 -0
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.d.ts.map +1 -1
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts +52 -0
- package/dist/lib/extensions/utils/3d-tiles-utils.d.ts.map +1 -0
- package/dist/lib/gltf-utils/gltf-utils.d.ts +2 -0
- package/dist/lib/gltf-utils/gltf-utils.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts +421 -0
- package/dist/lib/types/gltf-ext-feature-metadata-schema.d.ts.map +1 -0
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts +4 -6
- package/dist/lib/types/gltf-ext-mesh-features-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts +48 -29
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-json-schema.d.ts +1 -420
- package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-types.d.ts +3 -0
- package/dist/lib/types/gltf-types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +10 -5
- package/src/lib/api/gltf-extensions.ts +1 -1
- package/src/lib/extensions/EXT_mesh_features.ts +18 -44
- package/src/lib/extensions/EXT_structural_metadata.ts +364 -217
- package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +193 -30
- package/src/lib/extensions/{data-processing.ts → utils/3d-tiles-utils.ts} +128 -56
- package/src/lib/gltf-utils/gltf-utils.ts +38 -0
- package/src/lib/types/gltf-ext-feature-metadata-schema.ts +470 -0
- package/src/lib/types/gltf-ext-mesh-features-schema.ts +4 -6
- package/src/lib/types/gltf-ext-structural-metadata-schema.ts +52 -31
- package/src/lib/types/gltf-json-schema.ts +1 -468
- package/src/lib/types/gltf-types.ts +4 -0
- package/dist/bundle.js +0 -5
- package/dist/es5/lib/extensions/data-processing.js.map +0 -1
- package/dist/esm/lib/extensions/data-processing.js.map +0 -1
- package/dist/glb-loader.js +0 -34
- package/dist/glb-writer.js +0 -35
- package/dist/gltf-loader.js +0 -50
- package/dist/gltf-writer.js +0 -32
- package/dist/index.js +0 -34
- package/dist/lib/api/gltf-extensions.js +0 -88
- package/dist/lib/api/gltf-scenegraph.js +0 -580
- package/dist/lib/api/normalize-gltf-v1.js +0 -299
- package/dist/lib/api/post-process-gltf.js +0 -433
- package/dist/lib/encoders/encode-glb.js +0 -72
- package/dist/lib/encoders/encode-gltf.js +0 -32
- package/dist/lib/extensions/EXT_mesh_features.js +0 -89
- package/dist/lib/extensions/EXT_meshopt_compression.js +0 -41
- package/dist/lib/extensions/EXT_structural_metadata.js +0 -504
- package/dist/lib/extensions/EXT_texture_webp.js +0 -36
- package/dist/lib/extensions/KHR_binary_gltf.js +0 -39
- package/dist/lib/extensions/KHR_draco_mesh_compression.js +0 -137
- package/dist/lib/extensions/KHR_texture_basisu.js +0 -29
- package/dist/lib/extensions/KHR_texture_transform.js +0 -227
- package/dist/lib/extensions/data-processing.d.ts +0 -34
- package/dist/lib/extensions/data-processing.d.ts.map +0 -1
- package/dist/lib/extensions/data-processing.js +0 -212
- package/dist/lib/extensions/deprecated/EXT_feature_metadata.js +0 -282
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js +0 -59
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js +0 -44
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js +0 -79
- package/dist/lib/gltf-utils/get-typed-array.js +0 -41
- package/dist/lib/gltf-utils/gltf-attribute-utils.js +0 -73
- package/dist/lib/gltf-utils/gltf-constants.js +0 -43
- package/dist/lib/gltf-utils/gltf-utils.js +0 -90
- package/dist/lib/gltf-utils/resolve-url.js +0 -18
- package/dist/lib/parsers/parse-glb.js +0 -166
- package/dist/lib/parsers/parse-gltf.js +0 -185
- package/dist/lib/types/glb-types.js +0 -2
- package/dist/lib/types/gltf-ext-mesh-features-schema.js +0 -2
- package/dist/lib/types/gltf-ext-structural-metadata-schema.js +0 -2
- package/dist/lib/types/gltf-json-schema.js +0 -4
- package/dist/lib/types/gltf-postprocessed-schema.js +0 -4
- package/dist/lib/types/gltf-types.js +0 -3
- package/dist/lib/utils/assert.js +0 -12
- package/dist/lib/utils/version.js +0 -7
- package/dist/meshopt/meshopt-decoder.js +0 -118
- package/dist/webp/webp.js +0 -38
package/dist/dist.min.js
CHANGED
|
@@ -78,15 +78,24 @@
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
DEFAULT_VERSION = "beta";
|
|
85
|
-
VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : DEFAULT_VERSION;
|
|
81
|
+
function getVersion() {
|
|
82
|
+
if (!globalThis._loadersgl_?.version) {
|
|
83
|
+
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
86
84
|
if (typeof __VERSION__ === "undefined") {
|
|
87
85
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
86
|
+
globalThis._loadersgl_.version = NPM_TAG;
|
|
87
|
+
} else {
|
|
88
|
+
globalThis._loadersgl_.version = __VERSION__;
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
return globalThis._loadersgl_.version;
|
|
92
|
+
}
|
|
93
|
+
var NPM_TAG, VERSION2;
|
|
94
|
+
var init_version2 = __esm({
|
|
95
|
+
"../worker-utils/src/lib/env-utils/version.ts"() {
|
|
96
|
+
NPM_TAG = "beta";
|
|
97
|
+
VERSION2 = getVersion();
|
|
98
|
+
}
|
|
90
99
|
});
|
|
91
100
|
|
|
92
101
|
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
@@ -150,7 +159,7 @@
|
|
|
150
159
|
}
|
|
151
160
|
if (options.CDN) {
|
|
152
161
|
assert2(options.CDN.startsWith("http"));
|
|
153
|
-
return `${options.CDN}/${moduleName}@${
|
|
162
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
154
163
|
}
|
|
155
164
|
if (isWorker) {
|
|
156
165
|
return `../src/libs/${libraryName}`;
|
|
@@ -206,15 +215,13 @@
|
|
|
206
215
|
}
|
|
207
216
|
return await node.readFileAsText(url);
|
|
208
217
|
}
|
|
209
|
-
var node,
|
|
218
|
+
var node, loadLibraryPromises;
|
|
210
219
|
var init_library_utils = __esm({
|
|
211
220
|
"../worker-utils/src/lib/library-utils/library-utils.ts"() {
|
|
212
221
|
init_globals2();
|
|
213
222
|
node = __toModule(require_require_utils());
|
|
214
223
|
init_assert2();
|
|
215
224
|
init_version2();
|
|
216
|
-
LATEST = "beta";
|
|
217
|
-
VERSION3 = typeof VERSION2 !== "undefined" ? VERSION2 : LATEST;
|
|
218
225
|
loadLibraryPromises = {};
|
|
219
226
|
}
|
|
220
227
|
});
|
|
@@ -858,6 +865,30 @@
|
|
|
858
865
|
}
|
|
859
866
|
});
|
|
860
867
|
|
|
868
|
+
// src/lib/gltf-utils/gltf-constants.ts
|
|
869
|
+
var COMPONENTS, BYTES;
|
|
870
|
+
var init_gltf_constants = __esm({
|
|
871
|
+
"src/lib/gltf-utils/gltf-constants.ts"() {
|
|
872
|
+
COMPONENTS = {
|
|
873
|
+
SCALAR: 1,
|
|
874
|
+
VEC2: 2,
|
|
875
|
+
VEC3: 3,
|
|
876
|
+
VEC4: 4,
|
|
877
|
+
MAT2: 4,
|
|
878
|
+
MAT3: 9,
|
|
879
|
+
MAT4: 16
|
|
880
|
+
};
|
|
881
|
+
BYTES = {
|
|
882
|
+
5120: 1,
|
|
883
|
+
5121: 1,
|
|
884
|
+
5122: 2,
|
|
885
|
+
5123: 2,
|
|
886
|
+
5125: 4,
|
|
887
|
+
5126: 4
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
|
|
861
892
|
// src/lib/gltf-utils/gltf-utils.ts
|
|
862
893
|
function getAccessorTypeFromSize(size) {
|
|
863
894
|
const type = TYPES[size - 1];
|
|
@@ -879,6 +910,27 @@
|
|
|
879
910
|
assert3(byteLength >= 0 && byteLength <= bufferView.byteLength);
|
|
880
911
|
return { ArrayType, length, byteLength };
|
|
881
912
|
}
|
|
913
|
+
function getFloat32ArrayForAccessor(gltfData, texCoordAccessor) {
|
|
914
|
+
const accessor = gltfData.json.accessors?.[texCoordAccessor];
|
|
915
|
+
if (accessor && typeof accessor.bufferView !== "undefined") {
|
|
916
|
+
const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
|
|
917
|
+
if (bufferView) {
|
|
918
|
+
const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
|
|
919
|
+
const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0);
|
|
920
|
+
const { ArrayType, length } = getAccessorArrayTypeAndLength(accessor, bufferView);
|
|
921
|
+
const bytes = BYTES[accessor.componentType];
|
|
922
|
+
const components = COMPONENTS[accessor.type];
|
|
923
|
+
const elementAddressScale = bufferView.byteStride || bytes * components;
|
|
924
|
+
const result = new Float32Array(length);
|
|
925
|
+
for (let i2 = 0; i2 < accessor.count; i2++) {
|
|
926
|
+
const uv = new ArrayType(arrayBuffer, byteOffset + i2 * elementAddressScale, 2);
|
|
927
|
+
result.set(uv, i2 * components);
|
|
928
|
+
}
|
|
929
|
+
return result;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
882
934
|
function getMemoryUsageGLTF(gltf) {
|
|
883
935
|
let { images, bufferViews } = gltf;
|
|
884
936
|
images = images || [];
|
|
@@ -896,6 +948,7 @@
|
|
|
896
948
|
var init_gltf_utils = __esm({
|
|
897
949
|
"src/lib/gltf-utils/gltf-utils.ts"() {
|
|
898
950
|
init_assert3();
|
|
951
|
+
init_gltf_constants();
|
|
899
952
|
MIPMAP_FACTOR = 1.33;
|
|
900
953
|
TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"];
|
|
901
954
|
ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [
|
|
@@ -2531,25 +2584,44 @@
|
|
|
2531
2584
|
}
|
|
2532
2585
|
});
|
|
2533
2586
|
|
|
2534
|
-
// src/lib/extensions/
|
|
2587
|
+
// src/lib/extensions/utils/3d-tiles-utils.ts
|
|
2535
2588
|
function getArrayElementByteSize(attributeType, componentType) {
|
|
2536
2589
|
return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
|
|
2537
2590
|
}
|
|
2538
|
-
function
|
|
2591
|
+
function getOffsetsForProperty(scenegraph, bufferViewIndex, offsetType, numberOfElements) {
|
|
2592
|
+
if (offsetType !== "UINT8" && offsetType !== "UINT16" && offsetType !== "UINT32" && offsetType !== "UINT64") {
|
|
2593
|
+
return null;
|
|
2594
|
+
}
|
|
2595
|
+
const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex);
|
|
2596
|
+
const arrayOffsets = convertRawBufferToMetadataArray(arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1);
|
|
2597
|
+
if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) {
|
|
2598
|
+
return null;
|
|
2599
|
+
}
|
|
2600
|
+
return arrayOffsets;
|
|
2601
|
+
}
|
|
2602
|
+
function convertRawBufferToMetadataArray(data, attributeType, componentType, elementCount = 1) {
|
|
2539
2603
|
const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS2[attributeType];
|
|
2540
2604
|
const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[componentType];
|
|
2541
|
-
const length = elementCount * numberOfComponents;
|
|
2542
2605
|
const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType];
|
|
2543
|
-
const
|
|
2544
|
-
|
|
2606
|
+
const length = elementCount * numberOfComponents;
|
|
2607
|
+
const byteLength = length * size;
|
|
2608
|
+
let buffer = data.buffer;
|
|
2609
|
+
let offset = data.byteOffset;
|
|
2610
|
+
if (offset % size !== 0) {
|
|
2611
|
+
const bufferArray = new Uint8Array(buffer);
|
|
2612
|
+
buffer = bufferArray.slice(offset, offset + byteLength).buffer;
|
|
2613
|
+
offset = 0;
|
|
2614
|
+
}
|
|
2615
|
+
return new ArrayType(buffer, offset, length);
|
|
2545
2616
|
}
|
|
2546
2617
|
function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
|
|
2547
2618
|
const json = scenegraph.gltf.json;
|
|
2548
2619
|
const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
|
|
2549
2620
|
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
2550
|
-
const
|
|
2551
|
-
|
|
2552
|
-
|
|
2621
|
+
const textureCoordinates = getFloat32ArrayForAccessor(scenegraph.gltf, texCoordAccessorIndex);
|
|
2622
|
+
if (!textureCoordinates) {
|
|
2623
|
+
return null;
|
|
2624
|
+
}
|
|
2553
2625
|
const textureIndex = textureInfo.index;
|
|
2554
2626
|
const imageIndex = json.textures?.[textureIndex]?.source;
|
|
2555
2627
|
if (typeof imageIndex !== "undefined") {
|
|
@@ -2567,8 +2639,9 @@
|
|
|
2567
2639
|
return null;
|
|
2568
2640
|
}
|
|
2569
2641
|
function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) {
|
|
2570
|
-
if (propertyData
|
|
2642
|
+
if (!propertyData?.length) {
|
|
2571
2643
|
return;
|
|
2644
|
+
}
|
|
2572
2645
|
const featureIndices = [];
|
|
2573
2646
|
for (const texelData of propertyData) {
|
|
2574
2647
|
let index = featureTable.findIndex((item) => item === texelData);
|
|
@@ -2592,12 +2665,12 @@
|
|
|
2592
2665
|
primitive.attributes[attributeName] = accessorIndex;
|
|
2593
2666
|
}
|
|
2594
2667
|
function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) {
|
|
2595
|
-
const CHANNELS_MAP =
|
|
2596
|
-
{ offset: 0, shift: 0 },
|
|
2597
|
-
{ offset: 1, shift: 8 },
|
|
2598
|
-
{ offset: 2, shift: 16 },
|
|
2599
|
-
{ offset: 3, shift: 24 }
|
|
2600
|
-
|
|
2668
|
+
const CHANNELS_MAP = {
|
|
2669
|
+
r: { offset: 0, shift: 0 },
|
|
2670
|
+
g: { offset: 1, shift: 8 },
|
|
2671
|
+
b: { offset: 2, shift: 16 },
|
|
2672
|
+
a: { offset: 3, shift: 24 }
|
|
2673
|
+
};
|
|
2601
2674
|
const u = textureCoordinates[index];
|
|
2602
2675
|
const v = textureCoordinates[index + 1];
|
|
2603
2676
|
let components = 1;
|
|
@@ -2606,7 +2679,7 @@
|
|
|
2606
2679
|
const offset = coordinatesToOffset(u, v, parsedImage, components);
|
|
2607
2680
|
let value = 0;
|
|
2608
2681
|
for (const c of channels) {
|
|
2609
|
-
const map = CHANNELS_MAP[c];
|
|
2682
|
+
const map = typeof c === "number" ? Object.values(CHANNELS_MAP)[c] : CHANNELS_MAP[c];
|
|
2610
2683
|
const imageOffset = offset + map.offset;
|
|
2611
2684
|
const imageData = getImageData(parsedImage);
|
|
2612
2685
|
if (imageData.data.length <= imageOffset) {
|
|
@@ -2629,8 +2702,8 @@
|
|
|
2629
2702
|
return offset;
|
|
2630
2703
|
}
|
|
2631
2704
|
var ATTRIBUTE_TYPE_TO_COMPONENTS2, ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2, ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2;
|
|
2632
|
-
var
|
|
2633
|
-
"src/lib/extensions/
|
|
2705
|
+
var init_d_tiles_utils = __esm({
|
|
2706
|
+
"src/lib/extensions/utils/3d-tiles-utils.ts"() {
|
|
2634
2707
|
init_gltf_utils();
|
|
2635
2708
|
init_src3();
|
|
2636
2709
|
init_src4();
|
|
@@ -2673,17 +2746,91 @@
|
|
|
2673
2746
|
}
|
|
2674
2747
|
});
|
|
2675
2748
|
|
|
2749
|
+
// src/lib/extensions/EXT_mesh_features.ts
|
|
2750
|
+
var EXT_mesh_features_exports = {};
|
|
2751
|
+
__export(EXT_mesh_features_exports, {
|
|
2752
|
+
decode: () => decode,
|
|
2753
|
+
name: () => name
|
|
2754
|
+
});
|
|
2755
|
+
async function decode(gltfData, options) {
|
|
2756
|
+
const scenegraph = new GLTFScenegraph(gltfData);
|
|
2757
|
+
decodeExtMeshFeatures(scenegraph, options);
|
|
2758
|
+
}
|
|
2759
|
+
function decodeExtMeshFeatures(scenegraph, options) {
|
|
2760
|
+
const json = scenegraph.gltf.json;
|
|
2761
|
+
if (!json.meshes) {
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2764
|
+
for (const mesh of json.meshes) {
|
|
2765
|
+
for (const primitive of mesh.primitives) {
|
|
2766
|
+
processMeshPrimitiveFeatures(scenegraph, primitive, options);
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
|
|
2771
|
+
if (!options?.gltf?.loadBuffers) {
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
|
|
2775
|
+
const featureIds = extension?.featureIds;
|
|
2776
|
+
if (!featureIds) {
|
|
2777
|
+
return;
|
|
2778
|
+
}
|
|
2779
|
+
for (const featureId of featureIds) {
|
|
2780
|
+
let featureIdData = null;
|
|
2781
|
+
if (typeof featureId.attribute !== "undefined") {
|
|
2782
|
+
const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
|
|
2783
|
+
const accessorIndex = primitive.attributes[accessorKey];
|
|
2784
|
+
featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex);
|
|
2785
|
+
} else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
|
|
2786
|
+
featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
|
|
2787
|
+
} else {
|
|
2788
|
+
}
|
|
2789
|
+
featureId.data = featureIdData;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
var EXT_MESH_FEATURES_NAME, name;
|
|
2793
|
+
var init_EXT_mesh_features = __esm({
|
|
2794
|
+
"src/lib/extensions/EXT_mesh_features.ts"() {
|
|
2795
|
+
init_gltf_scenegraph();
|
|
2796
|
+
init_d_tiles_utils();
|
|
2797
|
+
EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
|
|
2798
|
+
name = EXT_MESH_FEATURES_NAME;
|
|
2799
|
+
}
|
|
2800
|
+
});
|
|
2801
|
+
|
|
2676
2802
|
// src/lib/extensions/EXT_structural_metadata.ts
|
|
2677
2803
|
var EXT_structural_metadata_exports = {};
|
|
2678
2804
|
__export(EXT_structural_metadata_exports, {
|
|
2679
|
-
decode: () =>
|
|
2805
|
+
decode: () => decode2,
|
|
2806
|
+
getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
|
|
2680
2807
|
getPropertyTablePopulated: () => getPropertyTablePopulated,
|
|
2681
|
-
name: () =>
|
|
2808
|
+
name: () => name2
|
|
2682
2809
|
});
|
|
2683
|
-
async function
|
|
2810
|
+
async function decode2(gltfData, options) {
|
|
2684
2811
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
2685
2812
|
decodeExtStructuralMetadata(scenegraph, options);
|
|
2686
2813
|
}
|
|
2814
|
+
function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
|
|
2815
|
+
if (extension.propertyTables) {
|
|
2816
|
+
const firstPropertyTable = extension?.propertyTables[0];
|
|
2817
|
+
const propertyTableWithData = {};
|
|
2818
|
+
for (const propertyName in firstPropertyTable.properties) {
|
|
2819
|
+
propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
|
|
2820
|
+
}
|
|
2821
|
+
return propertyTableWithData;
|
|
2822
|
+
}
|
|
2823
|
+
if (extension.propertyTextures) {
|
|
2824
|
+
const firstPropertyTexture = extension?.propertyTextures[0];
|
|
2825
|
+
const propertyTableWithData = {};
|
|
2826
|
+
for (const propertyName in firstPropertyTexture.properties) {
|
|
2827
|
+
propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
|
|
2828
|
+
}
|
|
2829
|
+
return propertyTableWithData;
|
|
2830
|
+
}
|
|
2831
|
+
console.warn("Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.");
|
|
2832
|
+
return null;
|
|
2833
|
+
}
|
|
2687
2834
|
function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
|
|
2688
2835
|
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
2689
2836
|
const propertyTable = extension?.propertyTables?.[propertyTableIndex];
|
|
@@ -2694,30 +2841,53 @@
|
|
|
2694
2841
|
throw new Error(`Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`);
|
|
2695
2842
|
}
|
|
2696
2843
|
function decodeExtStructuralMetadata(scenegraph, options) {
|
|
2844
|
+
if (!options.gltf?.loadBuffers) {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2697
2847
|
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
2698
|
-
if (!extension
|
|
2848
|
+
if (!extension) {
|
|
2699
2849
|
return;
|
|
2700
2850
|
}
|
|
2851
|
+
if (options.gltf?.loadImages) {
|
|
2852
|
+
decodePropertyTextures(scenegraph, extension);
|
|
2853
|
+
}
|
|
2854
|
+
decodePropertyTables(scenegraph, extension);
|
|
2855
|
+
}
|
|
2856
|
+
function decodePropertyTextures(scenegraph, extension) {
|
|
2701
2857
|
const propertyTextures = extension.propertyTextures;
|
|
2702
2858
|
const json = scenegraph.gltf.json;
|
|
2703
|
-
if (propertyTextures && json.meshes
|
|
2859
|
+
if (propertyTextures && json.meshes) {
|
|
2704
2860
|
for (const mesh of json.meshes) {
|
|
2705
2861
|
for (const primitive of mesh.primitives) {
|
|
2706
2862
|
processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
|
|
2707
2863
|
}
|
|
2708
2864
|
}
|
|
2709
2865
|
}
|
|
2710
|
-
|
|
2866
|
+
}
|
|
2867
|
+
function decodePropertyTables(scenegraph, extension) {
|
|
2868
|
+
const schema = extension.schema;
|
|
2869
|
+
if (!schema) {
|
|
2870
|
+
return;
|
|
2871
|
+
}
|
|
2872
|
+
const schemaClasses = schema.classes;
|
|
2711
2873
|
const propertyTables = extension.propertyTables;
|
|
2712
2874
|
if (schemaClasses && propertyTables) {
|
|
2713
2875
|
for (const schemaName in schemaClasses) {
|
|
2714
2876
|
const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
|
|
2715
2877
|
if (propertyTable) {
|
|
2716
|
-
processPropertyTable(scenegraph,
|
|
2878
|
+
processPropertyTable(scenegraph, schema, propertyTable);
|
|
2717
2879
|
}
|
|
2718
2880
|
}
|
|
2719
2881
|
}
|
|
2720
2882
|
}
|
|
2883
|
+
function findPropertyTableByClass(propertyTables, schemaClassName) {
|
|
2884
|
+
for (const propertyTable of propertyTables) {
|
|
2885
|
+
if (propertyTable.class === schemaClassName) {
|
|
2886
|
+
return propertyTable;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
return null;
|
|
2890
|
+
}
|
|
2721
2891
|
function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
|
|
2722
2892
|
if (!propertyTextures) {
|
|
2723
2893
|
return;
|
|
@@ -2740,9 +2910,9 @@
|
|
|
2740
2910
|
extension.dataAttributeNames = [];
|
|
2741
2911
|
}
|
|
2742
2912
|
const className = propertyTexture.class;
|
|
2743
|
-
for (const
|
|
2744
|
-
const attributeName = `${className}_${
|
|
2745
|
-
const textureInfoTopLevel = propertyTexture.properties?.[
|
|
2913
|
+
for (const propertyName in propertyTexture.properties) {
|
|
2914
|
+
const attributeName = `${className}_${propertyName}`;
|
|
2915
|
+
const textureInfoTopLevel = propertyTexture.properties?.[propertyName];
|
|
2746
2916
|
if (!textureInfoTopLevel) {
|
|
2747
2917
|
continue;
|
|
2748
2918
|
}
|
|
@@ -2778,14 +2948,8 @@
|
|
|
2778
2948
|
let data = [];
|
|
2779
2949
|
const valuesBufferView = propertyTableProperty.values;
|
|
2780
2950
|
const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
arrayOffsets = getOffsetArray(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
|
|
2784
|
-
}
|
|
2785
|
-
let stringOffsets = null;
|
|
2786
|
-
if (typeof propertyTableProperty.stringOffsets !== "undefined" && typeof propertyTableProperty.stringOffsetType !== "undefined") {
|
|
2787
|
-
stringOffsets = getOffsetArray(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
|
|
2788
|
-
}
|
|
2951
|
+
const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements);
|
|
2952
|
+
const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements);
|
|
2789
2953
|
switch (classProperty.type) {
|
|
2790
2954
|
case "SCALAR":
|
|
2791
2955
|
case "VEC2":
|
|
@@ -2813,11 +2977,17 @@
|
|
|
2813
2977
|
}
|
|
2814
2978
|
return data;
|
|
2815
2979
|
}
|
|
2816
|
-
function
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
return
|
|
2980
|
+
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
2981
|
+
if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined") {
|
|
2982
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || "UINT32", numberOfElements);
|
|
2983
|
+
}
|
|
2984
|
+
return null;
|
|
2985
|
+
}
|
|
2986
|
+
function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
|
|
2987
|
+
if (typeof propertyTableProperty.stringOffsets !== "undefined") {
|
|
2988
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType || "UINT32", numberOfElements);
|
|
2989
|
+
}
|
|
2990
|
+
return null;
|
|
2821
2991
|
}
|
|
2822
2992
|
function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
2823
2993
|
const isArray2 = classProperty.array;
|
|
@@ -2827,52 +2997,42 @@
|
|
|
2827
2997
|
let valuesData;
|
|
2828
2998
|
if (classProperty.componentType) {
|
|
2829
2999
|
valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
|
|
3000
|
+
if (!valuesData) {
|
|
3001
|
+
valuesData = valuesDataBytes;
|
|
3002
|
+
}
|
|
2830
3003
|
} else {
|
|
2831
3004
|
valuesData = valuesDataBytes;
|
|
2832
3005
|
}
|
|
2833
3006
|
if (isArray2) {
|
|
2834
3007
|
if (arrayOffsets) {
|
|
2835
|
-
return
|
|
3008
|
+
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
2836
3009
|
}
|
|
2837
3010
|
if (arrayCount) {
|
|
2838
|
-
return
|
|
3011
|
+
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
2839
3012
|
}
|
|
2840
3013
|
return [];
|
|
2841
3014
|
}
|
|
2842
|
-
|
|
2843
|
-
for (let index = 0; index < numberOfElements; index++) {
|
|
2844
|
-
const value = valuesData[index];
|
|
2845
|
-
attributeValueArray.push(value);
|
|
2846
|
-
}
|
|
2847
|
-
return attributeValueArray;
|
|
3015
|
+
return valuesData;
|
|
2848
3016
|
}
|
|
2849
|
-
function
|
|
3017
|
+
function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) {
|
|
2850
3018
|
const attributeValueArray = [];
|
|
2851
3019
|
for (let index = 0; index < numberOfElements; index++) {
|
|
2852
|
-
const array = [];
|
|
2853
3020
|
const arrayOffset = arrayOffsets[index];
|
|
2854
3021
|
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
2855
|
-
if (arrayByteSize + arrayOffset
|
|
2856
|
-
|
|
2857
|
-
const elementCount = arrayByteSize / elementSize;
|
|
2858
|
-
for (let i2 = 0; i2 < elementCount; i2++) {
|
|
2859
|
-
const value = valuesData[typedArrayOffset + i2];
|
|
2860
|
-
array.push(value);
|
|
2861
|
-
}
|
|
3022
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
3023
|
+
break;
|
|
2862
3024
|
}
|
|
2863
|
-
|
|
3025
|
+
const typedArrayOffset = arrayOffset / valueSize;
|
|
3026
|
+
const elementCount = arrayByteSize / valueSize;
|
|
3027
|
+
attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));
|
|
2864
3028
|
}
|
|
2865
3029
|
return attributeValueArray;
|
|
2866
3030
|
}
|
|
2867
|
-
function
|
|
3031
|
+
function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
|
|
2868
3032
|
const attributeValueArray = [];
|
|
2869
3033
|
for (let index = 0; index < numberOfElements; index++) {
|
|
2870
|
-
const
|
|
2871
|
-
|
|
2872
|
-
const value = valuesData[i2];
|
|
2873
|
-
array.push(value);
|
|
2874
|
-
}
|
|
2875
|
-
attributeValueArray.push(array);
|
|
3034
|
+
const elementOffset = index * arrayCount;
|
|
3035
|
+
attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));
|
|
2876
3036
|
}
|
|
2877
3037
|
return attributeValueArray;
|
|
2878
3038
|
}
|
|
@@ -2898,9 +3058,6 @@
|
|
|
2898
3058
|
return [];
|
|
2899
3059
|
}
|
|
2900
3060
|
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
2901
|
-
const data = [];
|
|
2902
|
-
const isArray2 = classProperty.array;
|
|
2903
|
-
const arrayCount = classProperty.count;
|
|
2904
3061
|
const enumType = classProperty.enumType;
|
|
2905
3062
|
if (!enumType) {
|
|
2906
3063
|
throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");
|
|
@@ -2912,69 +3069,77 @@
|
|
|
2912
3069
|
const enumValueType = enumEntry.valueType || "UINT16";
|
|
2913
3070
|
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
2914
3071
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
2915
|
-
|
|
2916
|
-
if (
|
|
3072
|
+
let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
|
|
3073
|
+
if (!valuesData) {
|
|
3074
|
+
valuesData = valuesDataBytes;
|
|
3075
|
+
}
|
|
3076
|
+
if (classProperty.array) {
|
|
2917
3077
|
if (arrayOffsets) {
|
|
2918
|
-
return
|
|
3078
|
+
return parseVariableLengthArrayENUM({
|
|
3079
|
+
valuesData,
|
|
3080
|
+
numberOfElements,
|
|
3081
|
+
arrayOffsets,
|
|
3082
|
+
valuesDataBytesLength: valuesDataBytes.length,
|
|
3083
|
+
elementSize,
|
|
3084
|
+
enumEntry
|
|
3085
|
+
});
|
|
2919
3086
|
}
|
|
3087
|
+
const arrayCount = classProperty.count;
|
|
2920
3088
|
if (arrayCount) {
|
|
2921
|
-
return
|
|
3089
|
+
return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
|
|
2922
3090
|
}
|
|
2923
3091
|
return [];
|
|
2924
3092
|
}
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
3093
|
+
return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);
|
|
3094
|
+
}
|
|
3095
|
+
function parseVariableLengthArrayENUM(params) {
|
|
3096
|
+
const {
|
|
3097
|
+
valuesData,
|
|
3098
|
+
numberOfElements,
|
|
3099
|
+
arrayOffsets,
|
|
3100
|
+
valuesDataBytesLength,
|
|
3101
|
+
elementSize,
|
|
3102
|
+
enumEntry
|
|
3103
|
+
} = params;
|
|
2935
3104
|
const attributeValueArray = [];
|
|
2936
3105
|
for (let index = 0; index < numberOfElements; index++) {
|
|
2937
|
-
const array = [];
|
|
2938
3106
|
const arrayOffset = arrayOffsets[index];
|
|
2939
3107
|
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
2940
|
-
if (arrayByteSize + arrayOffset
|
|
2941
|
-
|
|
2942
|
-
const elementCount = arrayByteSize / elementSize;
|
|
2943
|
-
for (let i2 = 0; i2 < elementCount; i2++) {
|
|
2944
|
-
const value = valuesData[typedArrayOffset + i2];
|
|
2945
|
-
const enumObject = getEnumByValue(enumEntry, value);
|
|
2946
|
-
if (enumObject) {
|
|
2947
|
-
array.push(enumObject.name);
|
|
2948
|
-
}
|
|
2949
|
-
}
|
|
3108
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
3109
|
+
break;
|
|
2950
3110
|
}
|
|
3111
|
+
const typedArrayOffset = arrayOffset / elementSize;
|
|
3112
|
+
const elementCount = arrayByteSize / elementSize;
|
|
3113
|
+
const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);
|
|
2951
3114
|
attributeValueArray.push(array);
|
|
2952
3115
|
}
|
|
2953
3116
|
return attributeValueArray;
|
|
2954
3117
|
}
|
|
2955
|
-
function
|
|
3118
|
+
function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
|
|
2956
3119
|
const attributeValueArray = [];
|
|
2957
3120
|
for (let index = 0; index < numberOfElements; index++) {
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2960
|
-
const value = valuesData[i2];
|
|
2961
|
-
const enumObject = getEnumByValue(enumEntry, value);
|
|
2962
|
-
if (enumObject) {
|
|
2963
|
-
array.push(enumObject.name);
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
3121
|
+
const elementOffset = arrayCount * index;
|
|
3122
|
+
const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);
|
|
2966
3123
|
attributeValueArray.push(array);
|
|
2967
3124
|
}
|
|
2968
3125
|
return attributeValueArray;
|
|
2969
3126
|
}
|
|
2970
|
-
function
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
if (
|
|
2974
|
-
|
|
3127
|
+
function getEnumsArray(valuesData, offset, count, enumEntry) {
|
|
3128
|
+
const array = [];
|
|
3129
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
3130
|
+
if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {
|
|
3131
|
+
array.push("");
|
|
3132
|
+
} else {
|
|
3133
|
+
const value = valuesData[offset + i2];
|
|
3134
|
+
const enumObject = getEnumByValue(enumEntry, value);
|
|
3135
|
+
if (enumObject) {
|
|
3136
|
+
array.push(enumObject.name);
|
|
3137
|
+
} else {
|
|
3138
|
+
array.push("");
|
|
3139
|
+
}
|
|
2975
3140
|
}
|
|
2976
3141
|
}
|
|
2977
|
-
return
|
|
3142
|
+
return array;
|
|
2978
3143
|
}
|
|
2979
3144
|
function getEnumByValue(enumEntry, value) {
|
|
2980
3145
|
for (const enumValue of enumEntry.values) {
|
|
@@ -2984,79 +3149,13 @@
|
|
|
2984
3149
|
}
|
|
2985
3150
|
return null;
|
|
2986
3151
|
}
|
|
2987
|
-
var EXT_STRUCTURAL_METADATA_NAME,
|
|
3152
|
+
var EXT_STRUCTURAL_METADATA_NAME, name2;
|
|
2988
3153
|
var init_EXT_structural_metadata = __esm({
|
|
2989
3154
|
"src/lib/extensions/EXT_structural_metadata.ts"() {
|
|
2990
3155
|
init_gltf_scenegraph();
|
|
2991
|
-
|
|
3156
|
+
init_d_tiles_utils();
|
|
2992
3157
|
EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata";
|
|
2993
|
-
|
|
2994
|
-
}
|
|
2995
|
-
});
|
|
2996
|
-
|
|
2997
|
-
// src/lib/extensions/EXT_mesh_features.ts
|
|
2998
|
-
var EXT_mesh_features_exports = {};
|
|
2999
|
-
__export(EXT_mesh_features_exports, {
|
|
3000
|
-
decode: () => decode2,
|
|
3001
|
-
name: () => name2
|
|
3002
|
-
});
|
|
3003
|
-
async function decode2(gltfData, options) {
|
|
3004
|
-
const scenegraph = new GLTFScenegraph(gltfData);
|
|
3005
|
-
decodeExtMeshFeatures(scenegraph, options);
|
|
3006
|
-
}
|
|
3007
|
-
function decodeExtMeshFeatures(scenegraph, options) {
|
|
3008
|
-
const json = scenegraph.gltf.json;
|
|
3009
|
-
if (!json.meshes) {
|
|
3010
|
-
return;
|
|
3011
|
-
}
|
|
3012
|
-
for (const mesh of json.meshes) {
|
|
3013
|
-
for (const primitive of mesh.primitives) {
|
|
3014
|
-
processMeshPrimitiveFeatures(scenegraph, primitive, options);
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
function processMeshPrimitiveFeatures(scenegraph, primitive, options) {
|
|
3019
|
-
const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME];
|
|
3020
|
-
const featureIds = extension?.featureIds;
|
|
3021
|
-
if (!featureIds)
|
|
3022
|
-
return;
|
|
3023
|
-
if (!extension.dataAttributeNames) {
|
|
3024
|
-
extension.dataAttributeNames = [];
|
|
3025
|
-
}
|
|
3026
|
-
let featureIdCount = 0;
|
|
3027
|
-
for (const featureId of featureIds) {
|
|
3028
|
-
let propertyTable = null;
|
|
3029
|
-
if (typeof featureId.propertyTable === "number") {
|
|
3030
|
-
propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);
|
|
3031
|
-
}
|
|
3032
|
-
let propertyData = null;
|
|
3033
|
-
if (typeof featureId.attribute !== "undefined") {
|
|
3034
|
-
const accessorKey = `_FEATURE_ID_${featureId.attribute}`;
|
|
3035
|
-
const accessorIndex = primitive.attributes[accessorKey];
|
|
3036
|
-
const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);
|
|
3037
|
-
propertyData = Array.prototype.slice.call(propertyDataTypedArray);
|
|
3038
|
-
} else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) {
|
|
3039
|
-
propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);
|
|
3040
|
-
} else {
|
|
3041
|
-
}
|
|
3042
|
-
const attributeName = featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;
|
|
3043
|
-
const featureTable = [];
|
|
3044
|
-
if (propertyData) {
|
|
3045
|
-
primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive);
|
|
3046
|
-
}
|
|
3047
|
-
extension.dataAttributeNames.push(attributeName);
|
|
3048
|
-
featureId.data = featureTable;
|
|
3049
|
-
featureIdCount++;
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
var EXT_MESH_FEATURES_NAME, name2;
|
|
3053
|
-
var init_EXT_mesh_features = __esm({
|
|
3054
|
-
"src/lib/extensions/EXT_mesh_features.ts"() {
|
|
3055
|
-
init_gltf_scenegraph();
|
|
3056
|
-
init_data_processing();
|
|
3057
|
-
init_EXT_structural_metadata();
|
|
3058
|
-
EXT_MESH_FEATURES_NAME = "EXT_mesh_features";
|
|
3059
|
-
name2 = EXT_MESH_FEATURES_NAME;
|
|
3158
|
+
name2 = EXT_STRUCTURAL_METADATA_NAME;
|
|
3060
3159
|
}
|
|
3061
3160
|
});
|
|
3062
3161
|
|
|
@@ -3064,12 +3163,45 @@
|
|
|
3064
3163
|
var EXT_feature_metadata_exports = {};
|
|
3065
3164
|
__export(EXT_feature_metadata_exports, {
|
|
3066
3165
|
decode: () => decode3,
|
|
3166
|
+
getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
|
|
3067
3167
|
name: () => name3
|
|
3068
3168
|
});
|
|
3069
3169
|
async function decode3(gltfData, options) {
|
|
3070
3170
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
3071
3171
|
decodeExtFeatureMetadata(scenegraph, options);
|
|
3072
3172
|
}
|
|
3173
|
+
function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
3174
|
+
if (extension.featureTables) {
|
|
3175
|
+
const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
|
|
3176
|
+
if (firstFeatureTableName) {
|
|
3177
|
+
const featureTable = extension.featureTables[firstFeatureTableName];
|
|
3178
|
+
const propertyTable = {};
|
|
3179
|
+
for (const propertyName in featureTable.properties) {
|
|
3180
|
+
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
3181
|
+
}
|
|
3182
|
+
return propertyTable;
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
if (extension.featureTextures) {
|
|
3186
|
+
let featureTexture;
|
|
3187
|
+
for (const textureKey in extension.featureTextures) {
|
|
3188
|
+
const texture = extension.featureTextures[textureKey];
|
|
3189
|
+
if (texture.class === metadataClass) {
|
|
3190
|
+
featureTexture = textureKey;
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
if (typeof featureTexture === "string") {
|
|
3194
|
+
const featureTable = extension.featureTextures[featureTexture];
|
|
3195
|
+
const propertyTable = {};
|
|
3196
|
+
for (const propertyName in featureTable.properties) {
|
|
3197
|
+
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
3198
|
+
}
|
|
3199
|
+
return propertyTable;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
console.warn("Cannot get property table from EXT_feature_metadata extension. There is neither featureTables, nor featureTextures in the extension.");
|
|
3203
|
+
return null;
|
|
3204
|
+
}
|
|
3073
3205
|
function decodeExtFeatureMetadata(scenegraph, options) {
|
|
3074
3206
|
const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME);
|
|
3075
3207
|
if (!extension)
|
|
@@ -3120,16 +3252,43 @@
|
|
|
3120
3252
|
function getPropertyDataFromBinarySource2(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
|
|
3121
3253
|
const bufferView = featureTableProperty.bufferView;
|
|
3122
3254
|
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
3255
|
+
if (schemaProperty.type === "STRING") {
|
|
3256
|
+
const offsetsData = getStringOffsets(scenegraph, featureTableProperty, numberOfFeatures);
|
|
3257
|
+
if (!offsetsData) {
|
|
3258
|
+
return [];
|
|
3128
3259
|
}
|
|
3129
|
-
|
|
3260
|
+
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
3261
|
+
} else if (isNumericProperty(schemaProperty.type)) {
|
|
3262
|
+
return getNumericAttributes(dataArray, schemaProperty.type, numberOfFeatures);
|
|
3130
3263
|
}
|
|
3131
3264
|
return dataArray;
|
|
3132
3265
|
}
|
|
3266
|
+
function isNumericProperty(schemaPropertyType) {
|
|
3267
|
+
return [
|
|
3268
|
+
"UINT8",
|
|
3269
|
+
"INT16",
|
|
3270
|
+
"UINT16",
|
|
3271
|
+
"INT32",
|
|
3272
|
+
"UINT32",
|
|
3273
|
+
"INT64",
|
|
3274
|
+
"UINT64",
|
|
3275
|
+
"FLOAT32",
|
|
3276
|
+
"FLOAT64"
|
|
3277
|
+
].includes(schemaPropertyType);
|
|
3278
|
+
}
|
|
3279
|
+
function getStringOffsets(scenegraph, featureTableProperty, numberOfElements) {
|
|
3280
|
+
if (typeof featureTableProperty.stringOffsetBufferView !== "undefined") {
|
|
3281
|
+
return getOffsetsForProperty(scenegraph, featureTableProperty.stringOffsetBufferView, featureTableProperty.offsetType || "UINT32", numberOfElements);
|
|
3282
|
+
}
|
|
3283
|
+
return null;
|
|
3284
|
+
}
|
|
3285
|
+
function getNumericAttributes(valuesDataBytes, propertyType, elementCount) {
|
|
3286
|
+
let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, "SCALAR", propertyType, elementCount);
|
|
3287
|
+
if (!valuesData) {
|
|
3288
|
+
valuesData = valuesDataBytes;
|
|
3289
|
+
}
|
|
3290
|
+
return valuesData;
|
|
3291
|
+
}
|
|
3133
3292
|
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
3134
3293
|
const json = scenegraph.gltf.json;
|
|
3135
3294
|
if (!json.meshes) {
|
|
@@ -3148,9 +3307,10 @@
|
|
|
3148
3307
|
const textureData = [];
|
|
3149
3308
|
const texCoordAccessorKey = `TEXCOORD_${featureTextureProperty.texture.texCoord}`;
|
|
3150
3309
|
const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey];
|
|
3151
|
-
const
|
|
3152
|
-
|
|
3153
|
-
|
|
3310
|
+
const textureCoordinates = getFloat32ArrayForAccessor(scenegraph.gltf, texCoordAccessorIndex);
|
|
3311
|
+
if (!textureCoordinates) {
|
|
3312
|
+
return;
|
|
3313
|
+
}
|
|
3154
3314
|
const textureIndex = featureTextureProperty.texture.index;
|
|
3155
3315
|
const texture = json.textures?.[textureIndex];
|
|
3156
3316
|
const imageIndex = texture?.source;
|
|
@@ -3247,14 +3407,10 @@
|
|
|
3247
3407
|
function getStringAttributes(data, offsetsData, stringsCount) {
|
|
3248
3408
|
const stringsArray = [];
|
|
3249
3409
|
const textDecoder = new TextDecoder("utf8");
|
|
3250
|
-
let stringOffset = 0;
|
|
3251
|
-
const bytesPerStringSize = 4;
|
|
3252
3410
|
for (let index = 0; index < stringsCount; index++) {
|
|
3253
|
-
const
|
|
3254
|
-
const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
|
|
3411
|
+
const stringData = data.slice(offsetsData[index], offsetsData[index + 1]);
|
|
3255
3412
|
const stringAttribute = textDecoder.decode(stringData);
|
|
3256
3413
|
stringsArray.push(stringAttribute);
|
|
3257
|
-
stringOffset += stringByteSize;
|
|
3258
3414
|
}
|
|
3259
3415
|
return stringsArray;
|
|
3260
3416
|
}
|
|
@@ -3265,24 +3421,25 @@
|
|
|
3265
3421
|
init_src3();
|
|
3266
3422
|
init_gltf_utils();
|
|
3267
3423
|
init_src4();
|
|
3424
|
+
init_d_tiles_utils();
|
|
3268
3425
|
EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata";
|
|
3269
3426
|
name3 = EXT_FEATURE_METADATA_NAME;
|
|
3270
3427
|
}
|
|
3271
3428
|
});
|
|
3272
3429
|
|
|
3273
3430
|
// src/lib/utils/version.ts
|
|
3274
|
-
var
|
|
3431
|
+
var VERSION3;
|
|
3275
3432
|
var init_version3 = __esm({
|
|
3276
3433
|
"src/lib/utils/version.ts"() {
|
|
3277
|
-
|
|
3434
|
+
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3278
3435
|
}
|
|
3279
3436
|
});
|
|
3280
3437
|
|
|
3281
3438
|
// ../textures/src/lib/utils/version.ts
|
|
3282
|
-
var
|
|
3439
|
+
var VERSION4;
|
|
3283
3440
|
var init_version4 = __esm({
|
|
3284
3441
|
"../textures/src/lib/utils/version.ts"() {
|
|
3285
|
-
|
|
3442
|
+
VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
|
|
3286
3443
|
}
|
|
3287
3444
|
});
|
|
3288
3445
|
|
|
@@ -3721,7 +3878,7 @@
|
|
|
3721
3878
|
name: "Basis",
|
|
3722
3879
|
id: "basis",
|
|
3723
3880
|
module: "textures",
|
|
3724
|
-
version:
|
|
3881
|
+
version: VERSION4,
|
|
3725
3882
|
worker: true,
|
|
3726
3883
|
extensions: ["basis", "ktx2"],
|
|
3727
3884
|
mimeTypes: ["application/octet-stream", "image/ktx2"],
|
|
@@ -4197,10 +4354,10 @@
|
|
|
4197
4354
|
});
|
|
4198
4355
|
|
|
4199
4356
|
// ../draco/src/lib/utils/version.ts
|
|
4200
|
-
var
|
|
4357
|
+
var VERSION5;
|
|
4201
4358
|
var init_version5 = __esm({
|
|
4202
4359
|
"../draco/src/lib/utils/version.ts"() {
|
|
4203
|
-
|
|
4360
|
+
VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
4204
4361
|
}
|
|
4205
4362
|
});
|
|
4206
4363
|
|
|
@@ -4221,7 +4378,7 @@
|
|
|
4221
4378
|
name: "Draco",
|
|
4222
4379
|
id: "draco",
|
|
4223
4380
|
module: "draco",
|
|
4224
|
-
version:
|
|
4381
|
+
version: VERSION5,
|
|
4225
4382
|
worker: true,
|
|
4226
4383
|
extensions: ["drc"],
|
|
4227
4384
|
mimeTypes: ["application/octet-stream"],
|
|
@@ -4765,7 +4922,7 @@
|
|
|
4765
4922
|
var init_draco_module_loader = __esm({
|
|
4766
4923
|
"../draco/src/lib/draco-module-loader.ts"() {
|
|
4767
4924
|
init_src();
|
|
4768
|
-
DRACO_DECODER_VERSION = "1.5.
|
|
4925
|
+
DRACO_DECODER_VERSION = "1.5.6";
|
|
4769
4926
|
DRACO_ENCODER_VERSION = "1.4.1";
|
|
4770
4927
|
STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
|
|
4771
4928
|
DRACO_EXTERNAL_LIBRARIES = {
|
|
@@ -4976,30 +5133,6 @@
|
|
|
4976
5133
|
}
|
|
4977
5134
|
});
|
|
4978
5135
|
|
|
4979
|
-
// src/lib/gltf-utils/gltf-constants.ts
|
|
4980
|
-
var COMPONENTS, BYTES;
|
|
4981
|
-
var init_gltf_constants = __esm({
|
|
4982
|
-
"src/lib/gltf-utils/gltf-constants.ts"() {
|
|
4983
|
-
COMPONENTS = {
|
|
4984
|
-
SCALAR: 1,
|
|
4985
|
-
VEC2: 2,
|
|
4986
|
-
VEC3: 3,
|
|
4987
|
-
VEC4: 4,
|
|
4988
|
-
MAT2: 4,
|
|
4989
|
-
MAT3: 9,
|
|
4990
|
-
MAT4: 16
|
|
4991
|
-
};
|
|
4992
|
-
BYTES = {
|
|
4993
|
-
5120: 1,
|
|
4994
|
-
5121: 1,
|
|
4995
|
-
5122: 2,
|
|
4996
|
-
5123: 2,
|
|
4997
|
-
5125: 4,
|
|
4998
|
-
5126: 4
|
|
4999
|
-
};
|
|
5000
|
-
}
|
|
5001
|
-
});
|
|
5002
|
-
|
|
5003
5136
|
// src/lib/extensions/KHR_texture_transform.ts
|
|
5004
5137
|
var KHR_texture_transform_exports = {};
|
|
5005
5138
|
__export(KHR_texture_transform_exports, {
|
|
@@ -5355,8 +5488,8 @@
|
|
|
5355
5488
|
init_KHR_techniques_webgl();
|
|
5356
5489
|
init_EXT_feature_metadata();
|
|
5357
5490
|
EXTENSIONS2 = [
|
|
5358
|
-
EXT_mesh_features_exports,
|
|
5359
5491
|
EXT_structural_metadata_exports,
|
|
5492
|
+
EXT_mesh_features_exports,
|
|
5360
5493
|
EXT_meshopt_compression_exports,
|
|
5361
5494
|
EXT_texture_webp_exports,
|
|
5362
5495
|
KHR_texture_basisu_exports,
|
|
@@ -5748,7 +5881,7 @@
|
|
|
5748
5881
|
name: "glTF",
|
|
5749
5882
|
id: "gltf",
|
|
5750
5883
|
module: "gltf",
|
|
5751
|
-
version:
|
|
5884
|
+
version: VERSION3,
|
|
5752
5885
|
extensions: ["gltf", "glb"],
|
|
5753
5886
|
mimeTypes: ["model/gltf+json", "model/gltf-binary"],
|
|
5754
5887
|
text: true,
|
|
@@ -5865,7 +5998,7 @@
|
|
|
5865
5998
|
name: "glTF",
|
|
5866
5999
|
id: "gltf",
|
|
5867
6000
|
module: "gltf",
|
|
5868
|
-
version:
|
|
6001
|
+
version: VERSION3,
|
|
5869
6002
|
extensions: ["glb"],
|
|
5870
6003
|
mimeTypes: ["model/gltf-binary"],
|
|
5871
6004
|
binary: true,
|
|
@@ -5896,7 +6029,7 @@
|
|
|
5896
6029
|
name: "GLB",
|
|
5897
6030
|
id: "glb",
|
|
5898
6031
|
module: "gltf",
|
|
5899
|
-
version:
|
|
6032
|
+
version: VERSION3,
|
|
5900
6033
|
extensions: ["glb"],
|
|
5901
6034
|
mimeTypes: ["model/gltf-binary"],
|
|
5902
6035
|
binary: true,
|
|
@@ -5929,7 +6062,7 @@
|
|
|
5929
6062
|
name: "GLB",
|
|
5930
6063
|
id: "glb",
|
|
5931
6064
|
module: "gltf",
|
|
5932
|
-
version:
|
|
6065
|
+
version: VERSION3,
|
|
5933
6066
|
extensions: ["glb"],
|
|
5934
6067
|
mimeTypes: ["model/gltf-binary"],
|
|
5935
6068
|
binary: true,
|
|
@@ -6319,14 +6452,16 @@
|
|
|
6319
6452
|
var src_exports = {};
|
|
6320
6453
|
__export(src_exports, {
|
|
6321
6454
|
EXT_FEATURE_METADATA: () => name3,
|
|
6322
|
-
EXT_MESH_FEATURES: () =>
|
|
6323
|
-
EXT_STRUCTURAL_METADATA: () =>
|
|
6455
|
+
EXT_MESH_FEATURES: () => name,
|
|
6456
|
+
EXT_STRUCTURAL_METADATA: () => name2,
|
|
6324
6457
|
GLBLoader: () => GLBLoader,
|
|
6325
6458
|
GLBWriter: () => GLBWriter,
|
|
6326
6459
|
GLTFLoader: () => GLTFLoader,
|
|
6327
6460
|
GLTFScenegraph: () => GLTFScenegraph,
|
|
6328
6461
|
GLTFWriter: () => GLTFWriter,
|
|
6329
6462
|
_getMemoryUsageGLTF: () => getMemoryUsageGLTF,
|
|
6463
|
+
getPropertyTableFromExtFeatureMetadata: () => getPropertyTableFromExtFeatureMetadata,
|
|
6464
|
+
getPropertyTableFromExtStructuralMetadata: () => getPropertyTableFromExtStructuralMetadata,
|
|
6330
6465
|
postProcessGLTF: () => postProcessGLTF
|
|
6331
6466
|
});
|
|
6332
6467
|
var init_src8 = __esm({
|
|
@@ -6334,6 +6469,8 @@
|
|
|
6334
6469
|
init_EXT_mesh_features();
|
|
6335
6470
|
init_EXT_structural_metadata();
|
|
6336
6471
|
init_EXT_feature_metadata();
|
|
6472
|
+
init_EXT_feature_metadata();
|
|
6473
|
+
init_EXT_structural_metadata();
|
|
6337
6474
|
init_gltf_loader();
|
|
6338
6475
|
init_gltf_writer();
|
|
6339
6476
|
init_glb_loader();
|