@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
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { GLTFScenegraph } from '../api/gltf-scenegraph';
|
|
2
|
-
import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize } from './
|
|
2
|
+
import { convertRawBufferToMetadataArray, getPrimitiveTextureData, primitivePropertyDataToAttributes, getArrayElementByteSize, getOffsetsForProperty } from './utils/3d-tiles-utils';
|
|
3
3
|
const EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';
|
|
4
4
|
export const name = EXT_STRUCTURAL_METADATA_NAME;
|
|
5
5
|
export async function decode(gltfData, options) {
|
|
6
6
|
const scenegraph = new GLTFScenegraph(gltfData);
|
|
7
7
|
decodeExtStructuralMetadata(scenegraph, options);
|
|
8
8
|
}
|
|
9
|
+
export function getPropertyTableFromExtStructuralMetadata(extension, metadataClass) {
|
|
10
|
+
if (extension.propertyTables) {
|
|
11
|
+
const firstPropertyTable = extension === null || extension === void 0 ? void 0 : extension.propertyTables[0];
|
|
12
|
+
const propertyTableWithData = {};
|
|
13
|
+
for (const propertyName in firstPropertyTable.properties) {
|
|
14
|
+
propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;
|
|
15
|
+
}
|
|
16
|
+
return propertyTableWithData;
|
|
17
|
+
}
|
|
18
|
+
if (extension.propertyTextures) {
|
|
19
|
+
const firstPropertyTexture = extension === null || extension === void 0 ? void 0 : extension.propertyTextures[0];
|
|
20
|
+
const propertyTableWithData = {};
|
|
21
|
+
for (const propertyName in firstPropertyTexture.properties) {
|
|
22
|
+
propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;
|
|
23
|
+
}
|
|
24
|
+
return propertyTableWithData;
|
|
25
|
+
}
|
|
26
|
+
console.warn('Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.');
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
9
29
|
export function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
|
|
10
30
|
var _extension$propertyTa;
|
|
11
31
|
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
@@ -17,31 +37,54 @@ export function getPropertyTablePopulated(scenegraph, propertyTableIndex) {
|
|
|
17
37
|
throw new Error("Incorrect data in the EXT_structural_metadata extension: no property table with index ".concat(propertyTableIndex));
|
|
18
38
|
}
|
|
19
39
|
function decodeExtStructuralMetadata(scenegraph, options) {
|
|
20
|
-
var _options$gltf;
|
|
40
|
+
var _options$gltf, _options$gltf2;
|
|
41
|
+
if (!((_options$gltf = options.gltf) !== null && _options$gltf !== void 0 && _options$gltf.loadBuffers)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
21
44
|
const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME);
|
|
22
|
-
if (!
|
|
45
|
+
if (!extension) {
|
|
23
46
|
return;
|
|
24
47
|
}
|
|
48
|
+
if ((_options$gltf2 = options.gltf) !== null && _options$gltf2 !== void 0 && _options$gltf2.loadImages) {
|
|
49
|
+
decodePropertyTextures(scenegraph, extension);
|
|
50
|
+
}
|
|
51
|
+
decodePropertyTables(scenegraph, extension);
|
|
52
|
+
}
|
|
53
|
+
function decodePropertyTextures(scenegraph, extension) {
|
|
25
54
|
const propertyTextures = extension.propertyTextures;
|
|
26
55
|
const json = scenegraph.gltf.json;
|
|
27
|
-
if (propertyTextures && json.meshes
|
|
56
|
+
if (propertyTextures && json.meshes) {
|
|
28
57
|
for (const mesh of json.meshes) {
|
|
29
58
|
for (const primitive of mesh.primitives) {
|
|
30
59
|
processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);
|
|
31
60
|
}
|
|
32
61
|
}
|
|
33
62
|
}
|
|
34
|
-
|
|
63
|
+
}
|
|
64
|
+
function decodePropertyTables(scenegraph, extension) {
|
|
65
|
+
const schema = extension.schema;
|
|
66
|
+
if (!schema) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const schemaClasses = schema.classes;
|
|
35
70
|
const propertyTables = extension.propertyTables;
|
|
36
71
|
if (schemaClasses && propertyTables) {
|
|
37
72
|
for (const schemaName in schemaClasses) {
|
|
38
73
|
const propertyTable = findPropertyTableByClass(propertyTables, schemaName);
|
|
39
74
|
if (propertyTable) {
|
|
40
|
-
processPropertyTable(scenegraph,
|
|
75
|
+
processPropertyTable(scenegraph, schema, propertyTable);
|
|
41
76
|
}
|
|
42
77
|
}
|
|
43
78
|
}
|
|
44
79
|
}
|
|
80
|
+
function findPropertyTableByClass(propertyTables, schemaClassName) {
|
|
81
|
+
for (const propertyTable of propertyTables) {
|
|
82
|
+
if (propertyTable.class === schemaClassName) {
|
|
83
|
+
return propertyTable;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
45
88
|
function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
|
|
46
89
|
var _primitive$extensions;
|
|
47
90
|
if (!propertyTextures) {
|
|
@@ -65,10 +108,10 @@ function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive,
|
|
|
65
108
|
extension.dataAttributeNames = [];
|
|
66
109
|
}
|
|
67
110
|
const className = propertyTexture.class;
|
|
68
|
-
for (const
|
|
111
|
+
for (const propertyName in propertyTexture.properties) {
|
|
69
112
|
var _propertyTexture$prop;
|
|
70
|
-
const attributeName = "".concat(className, "_").concat(
|
|
71
|
-
const textureInfoTopLevel = (_propertyTexture$prop = propertyTexture.properties) === null || _propertyTexture$prop === void 0 ? void 0 : _propertyTexture$prop[
|
|
113
|
+
const attributeName = "".concat(className, "_").concat(propertyName);
|
|
114
|
+
const textureInfoTopLevel = (_propertyTexture$prop = propertyTexture.properties) === null || _propertyTexture$prop === void 0 ? void 0 : _propertyTexture$prop[propertyName];
|
|
72
115
|
if (!textureInfoTopLevel) {
|
|
73
116
|
continue;
|
|
74
117
|
}
|
|
@@ -106,14 +149,8 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
|
|
|
106
149
|
let data = [];
|
|
107
150
|
const valuesBufferView = propertyTableProperty.values;
|
|
108
151
|
const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
arrayOffsets = getOffsetArray(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
|
|
112
|
-
}
|
|
113
|
-
let stringOffsets = null;
|
|
114
|
-
if (typeof propertyTableProperty.stringOffsets !== 'undefined' && typeof propertyTableProperty.stringOffsetType !== 'undefined') {
|
|
115
|
-
stringOffsets = getOffsetArray(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
|
|
116
|
-
}
|
|
152
|
+
const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements);
|
|
153
|
+
const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements);
|
|
117
154
|
switch (classProperty.type) {
|
|
118
155
|
case 'SCALAR':
|
|
119
156
|
case 'VEC2':
|
|
@@ -145,11 +182,17 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
|
|
|
145
182
|
}
|
|
146
183
|
return data;
|
|
147
184
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return
|
|
185
|
+
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
186
|
+
if (classProperty.array && typeof classProperty.count === 'undefined' && typeof propertyTableProperty.arrayOffsets !== 'undefined') {
|
|
187
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || 'UINT32', numberOfElements);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
|
|
192
|
+
if (typeof propertyTableProperty.stringOffsets !== 'undefined') {
|
|
193
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType || 'UINT32', numberOfElements);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
153
196
|
}
|
|
154
197
|
function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
155
198
|
const isArray = classProperty.array;
|
|
@@ -159,52 +202,42 @@ function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes
|
|
|
159
202
|
let valuesData;
|
|
160
203
|
if (classProperty.componentType) {
|
|
161
204
|
valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
|
|
205
|
+
if (!valuesData) {
|
|
206
|
+
valuesData = valuesDataBytes;
|
|
207
|
+
}
|
|
162
208
|
} else {
|
|
163
209
|
valuesData = valuesDataBytes;
|
|
164
210
|
}
|
|
165
211
|
if (isArray) {
|
|
166
212
|
if (arrayOffsets) {
|
|
167
|
-
return
|
|
213
|
+
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
168
214
|
}
|
|
169
215
|
if (arrayCount) {
|
|
170
|
-
return
|
|
216
|
+
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
171
217
|
}
|
|
172
218
|
return [];
|
|
173
219
|
}
|
|
174
|
-
|
|
175
|
-
for (let index = 0; index < numberOfElements; index++) {
|
|
176
|
-
const value = valuesData[index];
|
|
177
|
-
attributeValueArray.push(value);
|
|
178
|
-
}
|
|
179
|
-
return attributeValueArray;
|
|
220
|
+
return valuesData;
|
|
180
221
|
}
|
|
181
|
-
function
|
|
222
|
+
function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) {
|
|
182
223
|
const attributeValueArray = [];
|
|
183
224
|
for (let index = 0; index < numberOfElements; index++) {
|
|
184
|
-
const array = [];
|
|
185
225
|
const arrayOffset = arrayOffsets[index];
|
|
186
226
|
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
187
|
-
if (arrayByteSize + arrayOffset
|
|
188
|
-
|
|
189
|
-
const elementCount = arrayByteSize / elementSize;
|
|
190
|
-
for (let i = 0; i < elementCount; i++) {
|
|
191
|
-
const value = valuesData[typedArrayOffset + i];
|
|
192
|
-
array.push(value);
|
|
193
|
-
}
|
|
227
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
228
|
+
break;
|
|
194
229
|
}
|
|
195
|
-
|
|
230
|
+
const typedArrayOffset = arrayOffset / valueSize;
|
|
231
|
+
const elementCount = arrayByteSize / valueSize;
|
|
232
|
+
attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));
|
|
196
233
|
}
|
|
197
234
|
return attributeValueArray;
|
|
198
235
|
}
|
|
199
|
-
function
|
|
236
|
+
function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
|
|
200
237
|
const attributeValueArray = [];
|
|
201
238
|
for (let index = 0; index < numberOfElements; index++) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const value = valuesData[i];
|
|
205
|
-
array.push(value);
|
|
206
|
-
}
|
|
207
|
-
attributeValueArray.push(array);
|
|
239
|
+
const elementOffset = index * arrayCount;
|
|
240
|
+
attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));
|
|
208
241
|
}
|
|
209
242
|
return attributeValueArray;
|
|
210
243
|
}
|
|
@@ -231,9 +264,6 @@ function getPropertyDataString(classProperty, numberOfElements, valuesDataBytes,
|
|
|
231
264
|
}
|
|
232
265
|
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
233
266
|
var _schema$enums;
|
|
234
|
-
const data = [];
|
|
235
|
-
const isArray = classProperty.array;
|
|
236
|
-
const arrayCount = classProperty.count;
|
|
237
267
|
const enumType = classProperty.enumType;
|
|
238
268
|
if (!enumType) {
|
|
239
269
|
throw new Error('Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM');
|
|
@@ -245,69 +275,77 @@ function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesData
|
|
|
245
275
|
const enumValueType = enumEntry.valueType || 'UINT16';
|
|
246
276
|
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
247
277
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
248
|
-
|
|
249
|
-
if (
|
|
278
|
+
let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
|
|
279
|
+
if (!valuesData) {
|
|
280
|
+
valuesData = valuesDataBytes;
|
|
281
|
+
}
|
|
282
|
+
if (classProperty.array) {
|
|
250
283
|
if (arrayOffsets) {
|
|
251
|
-
return
|
|
284
|
+
return parseVariableLengthArrayENUM({
|
|
285
|
+
valuesData,
|
|
286
|
+
numberOfElements,
|
|
287
|
+
arrayOffsets,
|
|
288
|
+
valuesDataBytesLength: valuesDataBytes.length,
|
|
289
|
+
elementSize,
|
|
290
|
+
enumEntry
|
|
291
|
+
});
|
|
252
292
|
}
|
|
293
|
+
const arrayCount = classProperty.count;
|
|
253
294
|
if (arrayCount) {
|
|
254
|
-
return
|
|
295
|
+
return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
|
|
255
296
|
}
|
|
256
297
|
return [];
|
|
257
298
|
}
|
|
258
|
-
|
|
259
|
-
const enumValue = valuesData[index];
|
|
260
|
-
const enumObject = getEnumByValue(enumEntry, enumValue);
|
|
261
|
-
if (enumObject) {
|
|
262
|
-
data.push(enumObject.name);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
return data;
|
|
299
|
+
return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);
|
|
266
300
|
}
|
|
267
|
-
function
|
|
301
|
+
function parseVariableLengthArrayENUM(params) {
|
|
302
|
+
const {
|
|
303
|
+
valuesData,
|
|
304
|
+
numberOfElements,
|
|
305
|
+
arrayOffsets,
|
|
306
|
+
valuesDataBytesLength,
|
|
307
|
+
elementSize,
|
|
308
|
+
enumEntry
|
|
309
|
+
} = params;
|
|
268
310
|
const attributeValueArray = [];
|
|
269
311
|
for (let index = 0; index < numberOfElements; index++) {
|
|
270
|
-
const array = [];
|
|
271
312
|
const arrayOffset = arrayOffsets[index];
|
|
272
313
|
const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];
|
|
273
|
-
if (arrayByteSize + arrayOffset
|
|
274
|
-
|
|
275
|
-
const elementCount = arrayByteSize / elementSize;
|
|
276
|
-
for (let i = 0; i < elementCount; i++) {
|
|
277
|
-
const value = valuesData[typedArrayOffset + i];
|
|
278
|
-
const enumObject = getEnumByValue(enumEntry, value);
|
|
279
|
-
if (enumObject) {
|
|
280
|
-
array.push(enumObject.name);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
314
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
315
|
+
break;
|
|
283
316
|
}
|
|
317
|
+
const typedArrayOffset = arrayOffset / elementSize;
|
|
318
|
+
const elementCount = arrayByteSize / elementSize;
|
|
319
|
+
const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);
|
|
284
320
|
attributeValueArray.push(array);
|
|
285
321
|
}
|
|
286
322
|
return attributeValueArray;
|
|
287
323
|
}
|
|
288
|
-
function
|
|
324
|
+
function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
|
|
289
325
|
const attributeValueArray = [];
|
|
290
326
|
for (let index = 0; index < numberOfElements; index++) {
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
const value = valuesData[i];
|
|
294
|
-
const enumObject = getEnumByValue(enumEntry, value);
|
|
295
|
-
if (enumObject) {
|
|
296
|
-
array.push(enumObject.name);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
327
|
+
const elementOffset = arrayCount * index;
|
|
328
|
+
const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);
|
|
299
329
|
attributeValueArray.push(array);
|
|
300
330
|
}
|
|
301
331
|
return attributeValueArray;
|
|
302
332
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
|
|
333
|
+
function getEnumsArray(valuesData, offset, count, enumEntry) {
|
|
334
|
+
const array = [];
|
|
335
|
+
for (let i = 0; i < count; i++) {
|
|
336
|
+
if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {
|
|
337
|
+
array.push('');
|
|
338
|
+
} else {
|
|
339
|
+
const value = valuesData[offset + i];
|
|
340
|
+
const enumObject = getEnumByValue(enumEntry, value);
|
|
341
|
+
if (enumObject) {
|
|
342
|
+
array.push(enumObject.name);
|
|
343
|
+
} else {
|
|
344
|
+
array.push('');
|
|
345
|
+
}
|
|
308
346
|
}
|
|
309
347
|
}
|
|
310
|
-
return
|
|
348
|
+
return array;
|
|
311
349
|
}
|
|
312
350
|
function getEnumByValue(enumEntry, value) {
|
|
313
351
|
for (const enumValue of enumEntry.values) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","getPropertyTablePopulated","propertyTableIndex","_extension$propertyTa","extension","getExtension","propertyTable","propertyTables","schema","processPropertyTable","Error","concat","_options$gltf","propertyTextures","json","gltf","meshes","loadImages","mesh","primitive","primitives","processPrimitivePropertyTextures","schemaClasses","classes","schemaName","findPropertyTableByClass","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","properties","dataAttributeNames","className","class","propName","_propertyTexture$prop","attributeName","textureInfoTopLevel","data","featureTextureTable","propertyData","push","_schema$classes","schemaClass","numberOfElements","count","propertyName","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","array","arrayOffsetType","getOffsetArray","stringOffsets","stringOffsetType","type","getPropertyDataNumeric","getPropertyDataString","getPropertyDataENUM","offsets","offsetType","arrayOffsetsBufferView","arrayOffsetsBytes","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","handleVariableLengthArrayNumeric","length","handleFixedLengthArrayNumeric","attributeValueArray","index","value","valuesDataBytesLength","arrayOffset","arrayByteSize","typedArrayOffset","i","stringsArray","textDecoder","TextDecoder","stringOffset","stringByteSize","stringData","subarray","stringAttribute","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","handleVariableLengthArrayENUM","handleFixedLengthArrayENUM","enumValue","enumObject","getEnumByValue","schemaClassName","len"],"sources":["../../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\n\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize\n} from './data-processing';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Returns the property table populated with the data taken according to the extension schema.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {number} propertyTableIndex - Index of the property table to locate.\n * @returns {GLTF_EXT_structural_metadata_PropertyTable} Property table populated with the data.\n * Throws an exception if no property table was found for propertyTableIndex provided.\n */\nexport function getPropertyTablePopulated(\n scenegraph: GLTFScenegraph,\n propertyTableIndex: number\n): GLTF_EXT_structural_metadata_PropertyTable {\n const extension: GLTF_EXT_structural_metadata | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n const propertyTable = extension?.propertyTables?.[propertyTableIndex];\n if (extension?.schema && propertyTable) {\n processPropertyTable(scenegraph, extension.schema, propertyTable);\n return propertyTable;\n }\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`\n );\n}\n\n/**\n * Decodes feature metadata from extension\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFLoaderOptions} options - loader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const extension: GLTF_EXT_structural_metadata | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension?.schema) {\n return;\n }\n\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes && options?.gltf?.loadImages) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n\n const schemaClasses = extension.schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, extension.schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Takes data from property textures reffered by the primitive\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTF_EXT_structural_metadata_PropertyTexture[]} propertyTextures - propertyTexture definition taken from the top-level extention\n * @param {GLTFMeshPrimitive} primitive - Primitive object\n * @param {GLTF_EXT_structural_metadata} extension - top-level extension\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTF_EXT_structural_metadata_PropertyTexture} propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param {GLTFMeshPrimitive} primitive - Primitive object\n * @param {GLTF_EXT_structural_metadata} extension - top-level extension\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propName in propertyTexture.properties) {\n // propName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTF_EXT_structural_metadata_Schema} schema - schema object\n * @param {GLTF_EXT_structural_metadata_PropertyTable} propertyTable - propertyTable definition taken from the top-level extension\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes properties from binary sourse based on property type.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTF_EXT_structural_metadata_Schema} schema - Schema object\n * @param {GLTF_EXT_structural_metadata_ClassProperty} classProperty - class property object\n * @param {GLTF_EXT_structural_metadata_PropertyTable_Property} propertyTableProperty\n * @param {number} numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\n/* eslint complexity: [\"error\", 17]*/\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | number[] | string[][] | number[][] {\n let data: string[] | number[] | string[][] | number[][] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n let arrayOffsets: TypedArray | null = null;\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n typeof classProperty.count === 'undefined' && // If `count` is NOT defined, it's a VARIABLE-length array\n typeof propertyTableProperty.arrayOffsets !== 'undefined' && // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsetType !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n arrayOffsets = getOffsetArray(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType,\n numberOfElements\n );\n }\n\n let stringOffsets: TypedArray | null = null;\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' && // `stringOffsets` is an index of the buffer view containing offsets for strings.\n typeof propertyTableProperty.stringOffsetType !== 'undefined'\n ) {\n // Data are in a FIXED-length array\n stringOffsets = getOffsetArray(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType,\n numberOfElements\n );\n }\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets,\n stringOffsets\n );\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Gets offset array from `arrayOffsets` or `stringOffsets`.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {number} offsets - Buffer view index\n * @param offsetType - The type of values in `arrayOffsets` or `stringOffsets`.\n * @param {number} numberOfElements - The number of elements in each property array.\n * @returns {TypedArray}\n */\nfunction getOffsetArray(\n scenegraph: GLTFScenegraph,\n offsets: number,\n offsetType: 'UINT8' | 'UINT16' | 'UINT32' | 'UINT64',\n numberOfElements: number\n): TypedArray {\n const arrayOffsetsBufferView = offsets;\n const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(arrayOffsetsBufferView);\n\n const arrayOffsets = convertRawBufferToMetadataArray(\n arrayOffsetsBytes,\n 'SCALAR', // offsets consist of ONE component\n offsetType,\n numberOfElements + 1 // The number of offsets is equal to the property table `count` plus one.\n );\n return arrayOffsets;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param {GLTF_EXT_structural_metadata_ClassProperty} classProperty - class property object\n * @param {number} numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param {Uint8Array} valuesDataBytes - data taken from values property of the property table property.\n * @param {TypedArray | null} arrayOffsets - offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns {number[] | number[][]}\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): number[] | number[][] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: TypedArray;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n classProperty.componentType, // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n elementCount\n );\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return handleVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return handleFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n // Single value (not an array)\n const attributeValueArray: number[] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const value = valuesData[index];\n attributeValueArray.push(value);\n }\n return attributeValueArray;\n}\n\nfunction handleVariableLengthArrayNumeric(\n valuesData: TypedArray,\n numberOfElements: number,\n arrayOffsets: TypedArray,\n valuesDataBytesLength: number,\n elementSize: number\n) {\n const attributeValueArray: number[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const array: number[] = [];\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n for (let i = 0; i < elementCount; i++) {\n const value = valuesData[typedArrayOffset + i];\n array.push(value);\n }\n }\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\nfunction handleFixedLengthArrayNumeric(\n valuesData: TypedArray,\n numberOfElements: number,\n arrayCount: number\n) {\n const attributeValueArray: number[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const array: number[] = [];\n for (let i = 0; i < arrayCount; i++) {\n const value = valuesData[i];\n array.push(value);\n }\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Decodes properties of string type from binary sourse.\n * @param {GLTF_EXT_structural_metadata_ClassProperty} classProperty - class property object\n * @param {number} numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param {Uint8Array} valuesDataBytes - data taken from values property of the property table property.\n * @param {TypedArray | null} arrayOffsets - offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param {TypedArray | null} stringOffsets - index of the buffer view containing offsets for strings. It should be available for string type.\n * @returns {string[] | string[][]}\n */\nfunction getPropertyDataString(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null,\n stringOffsets: TypedArray | null\n): string[] | string[][] {\n if (arrayOffsets) {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n\n if (stringOffsets) {\n const stringsArray: string[] = [];\n const textDecoder = new TextDecoder('utf8');\n\n let stringOffset = 0;\n for (let index = 0; index < numberOfElements; index++) {\n const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];\n\n if (stringByteSize + stringOffset <= valuesDataBytes.length) {\n const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);\n const stringAttribute = textDecoder.decode(stringData);\n\n stringsArray.push(stringAttribute);\n stringOffset += stringByteSize;\n }\n }\n\n return stringsArray;\n }\n return [];\n}\n\n/**\n * Decodes properties of enum type from binary sourse.\n * @param {GLTF_EXT_structural_metadata_Schema} schema - schema object\n * @param {GLTF_EXT_structural_metadata_ClassProperty} classProperty - class property object\n * @param {number} numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param {Uint8Array} valuesDataBytes - data taken from values property of the property table property.\n * @param {TypedArray | null} arrayOffsets - offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns {string[] | string[][]}\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const data: string[] = [];\n\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n const valuesData: TypedArray = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return handleVariableLengthArrayENUM(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize,\n enumEntry\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return handleFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n for (let index = 0; index < numberOfElements; index++) {\n const enumValue = valuesData[index];\n const enumObject = getEnumByValue(enumEntry, enumValue);\n if (enumObject) {\n data.push(enumObject.name);\n }\n }\n\n return data;\n}\n\n/* eslint max-params: [\"error\", 6]*/\nfunction handleVariableLengthArrayENUM(\n valuesData: TypedArray,\n numberOfElements: number,\n arrayOffsets: TypedArray,\n valuesDataBytesLength: number,\n elementSize: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n) {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const array: string[] = [];\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset <= valuesDataBytesLength) {\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n for (let i = 0; i < elementCount; i++) {\n const value = valuesData[typedArrayOffset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n }\n }\n }\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\nfunction handleFixedLengthArrayENUM(\n valuesData: TypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n) {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const array: string[] = [];\n for (let i = 0; i < arrayCount; i++) {\n const value = valuesData[i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n }\n }\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n/**\n * Find the property table by class name.\n * @param {GLTF_EXT_structural_metadata_PropertyTable[]} propertyTables\n * @param {string} schemaClassName\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (let i = 0, len = propertyTables.length; i < len; i++) {\n const propertyTable = propertyTables[i];\n\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - the value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return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/C,KAAK,MAAMsB,SAAS,IAAIN,SAAS,CAAC7C,MAAM,EAAE;IACxC,IAAImD,SAAS,CAACtB,KAAK,KAAKA,KAAK,EAAE;MAC7B,OAAOsB,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
|
|
1
|
+
{"version":3,"file":"EXT_structural_metadata.js","names":["GLTFScenegraph","convertRawBufferToMetadataArray","getPrimitiveTextureData","primitivePropertyDataToAttributes","getArrayElementByteSize","getOffsetsForProperty","EXT_STRUCTURAL_METADATA_NAME","name","decode","gltfData","options","scenegraph","decodeExtStructuralMetadata","getPropertyTableFromExtStructuralMetadata","extension","metadataClass","propertyTables","firstPropertyTable","propertyTableWithData","propertyName","properties","data","propertyTextures","firstPropertyTexture","console","warn","getPropertyTablePopulated","propertyTableIndex","_extension$propertyTa","getExtension","propertyTable","schema","processPropertyTable","Error","concat","_options$gltf","_options$gltf2","gltf","loadBuffers","loadImages","decodePropertyTextures","decodePropertyTables","json","meshes","mesh","primitive","primitives","processPrimitivePropertyTextures","schemaClasses","classes","schemaName","findPropertyTableByClass","schemaClassName","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","dataAttributeNames","className","_propertyTexture$prop","attributeName","textureInfoTopLevel","featureTextureTable","propertyData","push","_schema$classes","schemaClass","numberOfElements","count","_propertyTable$proper","classProperty","propertyTableProperty","getPropertyDataFromBinarySource","valuesBufferView","values","valuesDataBytes","getTypedArrayForBufferView","arrayOffsets","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataString","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","parseVariableLengthArrayNumeric","length","parseFixedLengthArrayNumeric","valuesDataBytesLength","valueSize","attributeValueArray","index","arrayOffset","arrayByteSize","typedArrayOffset","slice","elementOffset","stringsArray","textDecoder","TextDecoder","stringOffset","stringByteSize","stringData","subarray","stringAttribute","_schema$enums","enumType","enumEntry","enums","enumValueType","valueType","parseVariableLengthArrayENUM","parseFixedLengthArrayENUM","getEnumsArray","params","offset","i","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["// GLTF EXTENSION: EXT_structural_metadata\n// https://github.com/CesiumGS/glTF/blob/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\n/* eslint-disable camelcase */\nimport type {BigTypedArray, TypedArray} from '@loaders.gl/schema';\nimport type {GLTF, GLTFTextureInfoMetadata, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport type {\n GLTF_EXT_structural_metadata_Schema,\n GLTF_EXT_structural_metadata_ClassProperty,\n GLTF_EXT_structural_metadata_Enum,\n GLTF_EXT_structural_metadata_EnumValue,\n GLTF_EXT_structural_metadata_PropertyTable,\n GLTF_EXT_structural_metadata_GLTF,\n GLTF_EXT_structural_metadata_PropertyTexture,\n GLTF_EXT_structural_metadata_PropertyTable_Property,\n GLTF_EXT_structural_metadata_Primitive\n} from '../types/gltf-ext-structural-metadata-schema';\nimport type {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {FeatureTableJson} from '../types/gltf-types';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {\n convertRawBufferToMetadataArray,\n getPrimitiveTextureData,\n primitivePropertyDataToAttributes,\n getArrayElementByteSize,\n NumericComponentType,\n getOffsetsForProperty\n} from './utils/3d-tiles-utils';\n\nconst EXT_STRUCTURAL_METADATA_NAME = 'EXT_structural_metadata';\nexport const name = EXT_STRUCTURAL_METADATA_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtStructuralMetadata(scenegraph, options);\n}\n\n/**\n * Handles EXT_structural_metadata to get property table.\n * @param extension - Global level of EXT_STRUCTURAL_METADATA extension.\n * @param metadataClass - User selected feature metadata class name.\n * @returns {FeatureTableJson | null} Property table or null if the extension can't be handled properly.\n */\nexport function getPropertyTableFromExtStructuralMetadata(\n extension: GLTF_EXT_structural_metadata_GLTF,\n metadataClass?: string\n): FeatureTableJson | null {\n if (extension.propertyTables) {\n /**\n * Take only first feature table to generate attributes storage info object.\n * TODO: Think about getting data from all feature tables?\n * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.\n * In I3S we should decide which featureIds attribute will be passed to geometry data.\n */\n const firstPropertyTable = extension?.propertyTables[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTable.properties) {\n propertyTableWithData[propertyName] = firstPropertyTable.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n if (extension.propertyTextures) {\n // TODO: Think about getting data from all property textures.\n const firstPropertyTexture = extension?.propertyTextures[0];\n const propertyTableWithData = {};\n\n for (const propertyName in firstPropertyTexture.properties) {\n propertyTableWithData[propertyName] = firstPropertyTexture.properties[propertyName].data;\n }\n\n return propertyTableWithData;\n }\n\n // eslint-disable-next-line no-console\n console.warn(\n 'Cannot get property table from EXT_structural_metadata extension. There is neither propertyTables, nor propertyTextures in the extension.'\n );\n return null;\n}\n\n/*\n// Example of the extension.\n// See more info at https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata\nconst extensions = {\n \"extensions\": {\n \"EXT_structural_metadata\": {\n \"schema\": {\n \"classes\": {\n \"tree\": {\n \"name\": \"Tree\",\n \"description\": \"Woody, perennial plant.\",\n \"properties\": {\n \"species\": {\n \"description\": \"Type of tree.\",\n \"type\": \"ENUM\",\n \"enumType\": \"speciesEnum\",\n \"required\": true\n },\n \"age\": {\n \"description\": \"The age of the tree, in years\",\n \"type\": \"SCALAR\",\n \"componentType\": \"UINT8\",\n \"required\": true\n }\n }\n }\n },\n \"enums\": {\n \"speciesEnum\": {\n \"name\": \"Species\",\n \"description\": \"An example enum for tree species.\",\n // valueType is not defined here. Default is \"UINT16\"\n \"values\": [\n { \"name\": \"Unspecified\", \"value\": 0 },\n { \"name\": \"Oak\", \"value\": 1 }\n ]\n }\n }\n },\n \"propertyTables\": [{\n \"name\": \"tree_survey_2021-09-29\",\n \"class\": \"tree\",\n \"count\": 10, // The number of elements in each property array (in `species`, in `age`).\n \"properties\": {\n \"species\": {\n \"values\": 0, // It's an index of the buffer view containing property values.\n },\n \"age\": {\n \"values\": 1\n }\n }\n }]\n }\n }\n}\n*/\n\n/**\n * Returns the property table populated with the data taken according to the extension schema.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableIndex - Index of the property table to locate.\n * @returns Property table populated with the data.\n * Throws an exception if no property table was found for propertyTableIndex provided.\n */\nexport function getPropertyTablePopulated(\n scenegraph: GLTFScenegraph,\n propertyTableIndex: number\n): GLTF_EXT_structural_metadata_PropertyTable {\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n const propertyTable = extension?.propertyTables?.[propertyTableIndex];\n if (extension?.schema && propertyTable) {\n processPropertyTable(scenegraph, extension.schema, propertyTable);\n return propertyTable;\n }\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no property table with index ${propertyTableIndex}`\n );\n}\n\n/**\n * Decodes feature metadata from extension.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param options - GLTFLoader options.\n */\nfunction decodeExtStructuralMetadata(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n // Decoding metadata involves buffers processing.\n // So, if buffers have not been loaded, there is no reason to process metadata.\n if (!options.gltf?.loadBuffers) {\n return;\n }\n const extension: GLTF_EXT_structural_metadata_GLTF | null = scenegraph.getExtension(\n EXT_STRUCTURAL_METADATA_NAME\n );\n if (!extension) {\n return;\n }\n\n if (options.gltf?.loadImages) {\n decodePropertyTextures(scenegraph, extension);\n }\n\n decodePropertyTables(scenegraph, extension);\n}\n\n/**\n * Processes the data stored in the textures\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTextures(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const propertyTextures = extension.propertyTextures;\n const json = scenegraph.gltf.json;\n if (propertyTextures && json.meshes) {\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension);\n }\n }\n }\n}\n\n/**\n * Processes the data stored in the property tables.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param extension - Top-level extension.\n */\nfunction decodePropertyTables(\n scenegraph: GLTFScenegraph,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n const schema = extension.schema;\n if (!schema) {\n return;\n }\n const schemaClasses = schema.classes;\n const propertyTables = extension.propertyTables;\n if (schemaClasses && propertyTables) {\n for (const schemaName in schemaClasses) {\n const propertyTable = findPropertyTableByClass(propertyTables, schemaName);\n if (propertyTable) {\n processPropertyTable(scenegraph, schema, propertyTable);\n }\n }\n }\n}\n\n/**\n * Finds the property table by class name.\n * @param propertyTables - propertyTable definition taken from the top-level extension.\n * @param schemaClassName - class name in the extension schema.\n */\nfunction findPropertyTableByClass(\n propertyTables: GLTF_EXT_structural_metadata_PropertyTable[],\n schemaClassName: string\n): GLTF_EXT_structural_metadata_PropertyTable | null {\n for (const propertyTable of propertyTables) {\n if (propertyTable.class === schemaClassName) {\n return propertyTable;\n }\n }\n\n return null;\n}\n\n/**\n * Takes data from property textures reffered by the primitive.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTextures - propertyTexture definition taken from the top-level extention.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTextures(\n scenegraph: GLTFScenegraph,\n propertyTextures: GLTF_EXT_structural_metadata_PropertyTexture[],\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTextures) {\n return;\n }\n const primitiveExtension: GLTF_EXT_structural_metadata_Primitive = primitive.extensions?.[\n EXT_STRUCTURAL_METADATA_NAME\n ] as GLTF_EXT_structural_metadata_Primitive;\n const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures;\n if (!primitivePropertyTextureIndices) {\n return;\n }\n\n for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) {\n const propertyTexture = propertyTextures[primitivePropertyTextureIndex];\n processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension);\n }\n}\n\n/**\n * Takes property data from the texture pointed by the primitive and appends them to `exension.data`.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTexture - propertyTexture definition taken from the top-level extension.\n * @param primitive - Primitive object.\n * @param extension - Top-level extension.\n */\nfunction processPrimitivePropertyTexture(\n scenegraph: GLTFScenegraph,\n propertyTexture: GLTF_EXT_structural_metadata_PropertyTexture,\n primitive: GLTFMeshPrimitive,\n extension: GLTF_EXT_structural_metadata_GLTF\n): void {\n if (!propertyTexture.properties) {\n return;\n }\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n /* Iterate through all properties defined in propertyTexture, e.g. \"speed\" and \"direction\":\n {\n \"class\": \"wind\",\n \"properties\": {\n \"speed\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [0]\n },\n \"direction\": {\n \"index\": 0,\n \"texCoord\": 0,\n \"channels\": [1, 2]\n }\n }\n }\n */\n const className = propertyTexture.class;\n for (const propertyName in propertyTexture.properties) {\n // propertyName has values like \"speed\", \"direction\"\n // Make attributeName as a combination of the class name and the propertyName like \"wind_speed\" or \"wind_direction\"\n const attributeName = `${className}_${propertyName}`;\n const textureInfoTopLevel: GLTFTextureInfoMetadata | undefined =\n propertyTexture.properties?.[propertyName];\n if (!textureInfoTopLevel) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // The data taken from all meshes/primitives (the same property, e.g. \"speed\" or \"direction\") will be combined into one array and saved in textureInfoTopLevel.data\n // Initially textureInfoTopLevel.data will be initialized with an empty array.\n if (!textureInfoTopLevel.data) {\n textureInfoTopLevel.data = [];\n }\n const featureTextureTable: number[] = textureInfoTopLevel.data as number[];\n\n const propertyData: number[] | null = getPrimitiveTextureData(\n scenegraph,\n textureInfoTopLevel,\n primitive\n );\n if (propertyData === null) {\n // eslint-disable-next-line no-continue\n continue;\n }\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTextureTable,\n primitive\n );\n textureInfoTopLevel.data = featureTextureTable;\n extension.dataAttributeNames.push(attributeName);\n }\n}\n\n/**\n * Navigates through all properies in the property table, gets properties data,\n * and put the data to `propertyTable.data` as an array.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - schema object.\n * @param propertyTable - propertyTable definition taken from the top-level extension.\n */\nfunction processPropertyTable(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n propertyTable: GLTF_EXT_structural_metadata_PropertyTable\n): void {\n const schemaClass = schema.classes?.[propertyTable.class];\n if (!schemaClass) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`\n );\n }\n\n const numberOfElements = propertyTable.count; // `propertyTable.count` is a number of elements in each property array.\n\n for (const propertyName in schemaClass.properties) {\n const classProperty = schemaClass.properties[propertyName];\n const propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property | undefined =\n propertyTable.properties?.[propertyName];\n\n if (propertyTableProperty) {\n // Getting all elements (`numberOfElements`) of the array in the `propertyTableProperty`\n const data = getPropertyDataFromBinarySource(\n scenegraph,\n schema,\n classProperty,\n numberOfElements,\n propertyTableProperty\n );\n propertyTableProperty.data = data;\n }\n }\n}\n\n/**\n * Decodes a propertyTable column from binary source based on property type.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param schema - Schema object.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @returns {string[] | number[] | string[][] | number[][]}\n */\nfunction getPropertyDataFromBinarySource(\n scenegraph: GLTFScenegraph,\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property\n): string[] | BigTypedArray | string[][] | BigTypedArray[] {\n let data: string[] | BigTypedArray | string[][] | BigTypedArray[] = [];\n const valuesBufferView = propertyTableProperty.values;\n const valuesDataBytes: Uint8Array = scenegraph.getTypedArrayForBufferView(valuesBufferView);\n\n const arrayOffsets = getArrayOffsetsForProperty(\n scenegraph,\n classProperty,\n propertyTableProperty,\n numberOfElements\n );\n const stringOffsets = getStringOffsetsForProperty(\n scenegraph,\n propertyTableProperty,\n numberOfElements\n );\n\n switch (classProperty.type) {\n case 'SCALAR':\n case 'VEC2':\n case 'VEC3':\n case 'VEC4':\n case 'MAT2':\n case 'MAT3':\n case 'MAT4': {\n data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets);\n break;\n }\n case 'BOOLEAN': {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n case 'STRING': {\n data = getPropertyDataString(\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets,\n stringOffsets\n );\n break;\n }\n case 'ENUM': {\n data = getPropertyDataENUM(\n schema,\n classProperty,\n numberOfElements,\n valuesDataBytes,\n arrayOffsets\n );\n break;\n }\n default:\n throw new Error(`Unknown classProperty type ${classProperty.type}`);\n }\n\n return data;\n}\n\n/**\n * Parses propertyTable.property.arrayOffsets that are offsets of sub-arrays in a flatten array of values.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param classProperty - class property object.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L21\n */\nfunction getArrayOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n classProperty.array &&\n // `count` is a number of array elements. May only be defined when `array` is true.\n // If `count` is NOT defined, it's a VARIABLE-length array\n typeof classProperty.count === 'undefined' &&\n // `arrayOffsets` is an index of the buffer view containing offsets for variable-length arrays.\n typeof propertyTableProperty.arrayOffsets !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parses propertyTable.property.stringOffsets.\n * @param scenegraph - Instance of the class for structured access to GLTF data.\n * @param propertyTableProperty - propertyTable's property metadata.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @returns Typed array with offset values.\n * @see https://github.com/CesiumGS/glTF/blob/2976f1183343a47a29e4059a70961371cd2fcee8/extensions/2.0/Vendor/EXT_structural_metadata/schema/propertyTable.property.schema.json#L29C10-L29C23\n */\nfunction getStringOffsetsForProperty(\n scenegraph: GLTFScenegraph,\n propertyTableProperty: GLTF_EXT_structural_metadata_PropertyTable_Property,\n numberOfElements: number\n): TypedArray | null {\n if (\n typeof propertyTableProperty.stringOffsets !== 'undefined' // `stringOffsets` is an index of the buffer view containing offsets for strings.\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType || 'UINT32',\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Decodes properties of SCALAR, VEC-N, MAT-N types from binary sourse.\n * @param classProperty - class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Property values in a typed array or in an array of typed arrays.\n */\nfunction getPropertyDataNumeric(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): BigTypedArray | BigTypedArray[] {\n const isArray = classProperty.array;\n const arrayCount = classProperty.count;\n\n const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n\n let valuesData: BigTypedArray | null;\n if (classProperty.componentType) {\n valuesData = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n // The datatype of the element's components. Only applicable to `SCALAR`, `VECN`, and `MATN` types.\n classProperty.componentType as NumericComponentType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n } else {\n // The spec doesn't provide any info what to do if componentType is not set.\n valuesData = valuesDataBytes;\n }\n\n if (isArray) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayNumeric(\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytes.length,\n elementSize\n );\n }\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);\n }\n return [];\n }\n\n return valuesData;\n}\n\n/**\n * Parses variable-length array data.\n * In this case every value of the property in the table will be an array\n * of arbitrary length.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - Number of rows in the property table.\n * @param arrayOffsets - Offsets of nested arrays in the flat values array.\n * @param valuesDataBytesLength - Data byte length.\n * @param valueSize - Value size in bytes.\n * @returns Array of typed arrays.\n */\nfunction parseVariableLengthArrayNumeric(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayOffsets: TypedArray,\n valuesDataBytesLength: number,\n valueSize: number\n): BigTypedArray[] {\n const attributeValueArray: BigTypedArray[] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n const typedArrayOffset = arrayOffset / valueSize;\n const elementCount = arrayByteSize / valueSize;\n attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed-length array data.\n * In this case every value of the property in the table will be an array\n * of constant length equal to `arrayCount`.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - Number of rows in the property table.\n * @param arrayCount - Nested arrays length.\n * @returns Array of typed arrays.\n */\nfunction parseFixedLengthArrayNumeric(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number\n): BigTypedArray[] {\n const attributeValueArray: BigTypedArray[] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = index * arrayCount;\n attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));\n }\n return attributeValueArray;\n}\n\n/**\n * Decodes properties of string type from binary source.\n * @param classProperty - Class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param stringOffsets - Index of the buffer view containing offsets for strings. It should be available for string type.\n * @returns String property values\n */\nfunction getPropertyDataString(\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null,\n stringOffsets: TypedArray | null\n): string[] | string[][] {\n if (arrayOffsets) {\n // TODO: implement it as soon as we have the corresponding tileset\n throw new Error(`Not implemented - classProperty.type=${classProperty.type}`);\n }\n\n if (stringOffsets) {\n const stringsArray: string[] = [];\n const textDecoder = new TextDecoder('utf8');\n\n let stringOffset = 0;\n for (let index = 0; index < numberOfElements; index++) {\n const stringByteSize = stringOffsets[index + 1] - stringOffsets[index];\n\n if (stringByteSize + stringOffset <= valuesDataBytes.length) {\n const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset);\n const stringAttribute = textDecoder.decode(stringData);\n\n stringsArray.push(stringAttribute);\n stringOffset += stringByteSize;\n }\n }\n\n return stringsArray;\n }\n return [];\n}\n\n/**\n * Decodes properties of enum type from binary source.\n * @param schema - Schema object.\n * @param classProperty - Class property object.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param valuesDataBytes - Data taken from values property of the property table property.\n * @param arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @returns Strings array of nested strings array.\n */\nfunction getPropertyDataENUM(\n schema: GLTF_EXT_structural_metadata_Schema,\n classProperty: GLTF_EXT_structural_metadata_ClassProperty,\n numberOfElements: number,\n valuesDataBytes: Uint8Array,\n arrayOffsets: TypedArray | null\n): string[] | string[][] {\n const enumType = classProperty.enumType;\n // Enum ID as declared in the `enums` dictionary. Required when `type` is `ENUM`.\n if (!enumType) {\n throw new Error(\n 'Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM'\n );\n }\n\n const enumEntry: GLTF_EXT_structural_metadata_Enum | undefined = schema.enums?.[enumType];\n if (!enumEntry) {\n throw new Error(\n `Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`\n );\n }\n\n const enumValueType = enumEntry.valueType || 'UINT16';\n const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);\n const elementCount = valuesDataBytes.byteLength / elementSize;\n let valuesData: BigTypedArray | null = convertRawBufferToMetadataArray(\n valuesDataBytes,\n classProperty.type,\n enumValueType,\n elementCount\n );\n if (!valuesData) {\n valuesData = valuesDataBytes;\n }\n\n if (classProperty.array) {\n if (arrayOffsets) {\n // VARIABLE-length array\n return parseVariableLengthArrayENUM({\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength: valuesDataBytes.length,\n elementSize,\n enumEntry\n });\n }\n\n const arrayCount = classProperty.count;\n if (arrayCount) {\n // FIXED-length array\n return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);\n }\n return [];\n }\n\n // Single value (not an array)\n return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);\n}\n\n/**\n * Parses variable length nested ENUM arrays.\n * @param params.valuesData - Values in a flat typed array.\n * @param params.numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param params.arrayOffsets - Offsets for variable-length arrays. It's null for fixed-length arrays or scalar types.\n * @param params.valuesDataBytesLength - Byte length of values array.\n * @param params.elementSize - Single element byte size.\n * @param params.enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseVariableLengthArrayENUM(params: {\n valuesData: BigTypedArray;\n numberOfElements: number;\n arrayOffsets: TypedArray;\n valuesDataBytesLength: number;\n elementSize: number;\n enumEntry: GLTF_EXT_structural_metadata_Enum;\n}): string[][] {\n const {\n valuesData,\n numberOfElements,\n arrayOffsets,\n valuesDataBytesLength,\n elementSize,\n enumEntry\n } = params;\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const arrayOffset = arrayOffsets[index];\n const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index];\n if (arrayByteSize + arrayOffset > valuesDataBytesLength) {\n break;\n }\n\n const typedArrayOffset = arrayOffset / elementSize;\n const elementCount = arrayByteSize / elementSize;\n const array: string[] = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses fixed length ENUM arrays.\n * @param valuesData - Values in a flat typed array.\n * @param numberOfElements - The number of elements in each property array that propertyTableProperty contains. It's a number of rows in the table.\n * @param arrayCount - Nested arrays length.\n * @param enumEntry - Enums dictionary.\n * @returns Nested strings array.\n */\nfunction parseFixedLengthArrayENUM(\n valuesData: BigTypedArray,\n numberOfElements: number,\n arrayCount: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[][] {\n const attributeValueArray: string[][] = [];\n for (let index = 0; index < numberOfElements; index++) {\n const elementOffset = arrayCount * index;\n const array: string[] = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);\n attributeValueArray.push(array);\n }\n return attributeValueArray;\n}\n\n/**\n * Parses ENUM values into a string array.\n * @param valuesData - Values in a flat typed array.\n * @param offset - Offset to start parse from.\n * @param count - Values length to parse.\n * @param enumEntry - Enums dictionary.\n * @returns Array of strings with parsed ENUM names.\n */\nfunction getEnumsArray(\n valuesData: BigTypedArray,\n offset: number,\n count: number,\n enumEntry: GLTF_EXT_structural_metadata_Enum\n): string[] {\n const array: string[] = [];\n for (let i = 0; i < count; i++) {\n // At the moment we don't support BigInt. It requires additional calculations logic\n // and might be an issue in Safari\n if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {\n array.push('');\n } else {\n const value = valuesData[offset + i];\n\n const enumObject = getEnumByValue(enumEntry, value);\n if (enumObject) {\n array.push(enumObject.name);\n } else {\n array.push('');\n }\n }\n }\n return array;\n}\n\n/**\n * Looks up ENUM whose `value` property matches the specified number in the parameter `value`.\n * @param {GLTF_EXT_structural_metadata_Enum} enumEntry - ENUM entry containing the array of possible enums.\n * @param {number} value - The value of the ENUM to locate.\n * @returns {GLTF_EXT_structural_metadata_EnumValue | null} ENUM matcihng the specified value or null of no ENUM object was found.\n */\nfunction getEnumByValue(\n enumEntry: GLTF_EXT_structural_metadata_Enum,\n value: number\n): GLTF_EXT_structural_metadata_EnumValue | null {\n for (const enumValue of enumEntry.values) {\n if (enumValue.value === value) {\n return enumValue;\n }\n }\n\n return null;\n}\n"],"mappings":"AAmBA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SACEC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,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