@loaders.gl/gltf 4.0.0-alpha.23 → 4.0.0-alpha.24
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 +148 -102
- package/dist/es5/lib/extensions/EXT_mesh_features.js +3 -3
- package/dist/es5/lib/extensions/EXT_mesh_features.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_structural_metadata.js +88 -86
- package/dist/es5/lib/extensions/EXT_structural_metadata.js.map +1 -1
- package/dist/es5/lib/extensions/deprecated/EXT_feature_metadata.js +26 -13
- 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} +25 -6
- package/dist/es5/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- 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/utils/version.js +1 -1
- package/dist/esm/lib/extensions/EXT_mesh_features.js +1 -1
- package/dist/esm/lib/extensions/EXT_mesh_features.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_structural_metadata.js +85 -81
- package/dist/esm/lib/extensions/EXT_structural_metadata.js.map +1 -1
- package/dist/esm/lib/extensions/deprecated/EXT_feature_metadata.js +26 -13
- 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} +24 -6
- package/dist/esm/lib/extensions/utils/3d-tiles-utils.js.map +1 -0
- 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/utils/version.js +1 -1
- package/dist/lib/extensions/EXT_structural_metadata.d.ts +3 -3
- package/dist/lib/extensions/EXT_structural_metadata.d.ts.map +1 -1
- 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/types/gltf-ext-structural-metadata-schema.d.ts +4 -4
- package/dist/lib/types/gltf-ext-structural-metadata-schema.d.ts.map +1 -1
- package/dist/lib/types/gltf-json-schema.d.ts +1 -1
- package/dist/lib/types/gltf-json-schema.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/lib/extensions/EXT_mesh_features.ts +1 -1
- package/src/lib/extensions/EXT_structural_metadata.ts +267 -200
- package/src/lib/extensions/deprecated/EXT_feature_metadata.ts +123 -19
- package/src/lib/extensions/{data-processing.ts → utils/3d-tiles-utils.ts} +95 -34
- package/src/lib/types/gltf-ext-structural-metadata-schema.ts +6 -4
- package/src/lib/types/gltf-json-schema.ts +1 -1
- 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,5 +1,5 @@
|
|
|
1
1
|
import { GLTFScenegraph } from '../api/gltf-scenegraph';
|
|
2
|
-
import { getPrimitiveTextureData, primitivePropertyDataToAttributes } from './
|
|
2
|
+
import { getPrimitiveTextureData, primitivePropertyDataToAttributes } from './utils/3d-tiles-utils';
|
|
3
3
|
import { getPropertyTablePopulated } from './EXT_structural_metadata';
|
|
4
4
|
const EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';
|
|
5
5
|
export const name = EXT_MESH_FEATURES_NAME;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EXT_mesh_features.js","names":["GLTFScenegraph","getPrimitiveTextureData","primitivePropertyDataToAttributes","getPropertyTablePopulated","EXT_MESH_FEATURES_NAME","name","decode","gltfData","options","scenegraph","decodeExtMeshFeatures","json","gltf","meshes","mesh","primitive","primitives","processMeshPrimitiveFeatures","_primitive$extensions","extension","extensions","featureIds","dataAttributeNames","featureIdCount","featureId","_options$gltf","_propertyTable","propertyTable","propertyData","attribute","accessorKey","concat","accessorIndex","attributes","propertyDataTypedArray","getTypedArrayForAccessor","Array","prototype","slice","call","texture","loadImages","attributeName","label","featureTable","push","data"],"sources":["../../../../src/lib/extensions/EXT_mesh_features.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from '../types/gltf-ext-mesh-features-schema';\nimport type {GLTF_EXT_structural_metadata_PropertyTable} from '../types/gltf-ext-structural-metadata-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getPrimitiveTextureData, primitivePropertyDataToAttributes} from './
|
|
1
|
+
{"version":3,"file":"EXT_mesh_features.js","names":["GLTFScenegraph","getPrimitiveTextureData","primitivePropertyDataToAttributes","getPropertyTablePopulated","EXT_MESH_FEATURES_NAME","name","decode","gltfData","options","scenegraph","decodeExtMeshFeatures","json","gltf","meshes","mesh","primitive","primitives","processMeshPrimitiveFeatures","_primitive$extensions","extension","extensions","featureIds","dataAttributeNames","featureIdCount","featureId","_options$gltf","_propertyTable","propertyTable","propertyData","attribute","accessorKey","concat","accessorIndex","attributes","propertyDataTypedArray","getTypedArrayForAccessor","Array","prototype","slice","call","texture","loadImages","attributeName","label","featureTable","push","data"],"sources":["../../../../src/lib/extensions/EXT_mesh_features.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport type {GLTF, GLTFMeshPrimitive} from '../types/gltf-json-schema';\nimport {GLTFLoaderOptions} from '../../gltf-loader';\nimport type {\n GLTF_EXT_mesh_features,\n GLTF_EXT_mesh_features_featureId\n} from '../types/gltf-ext-mesh-features-schema';\nimport type {GLTF_EXT_structural_metadata_PropertyTable} from '../types/gltf-ext-structural-metadata-schema';\n\nimport {GLTFScenegraph} from '../api/gltf-scenegraph';\nimport {getPrimitiveTextureData, primitivePropertyDataToAttributes} from './utils/3d-tiles-utils';\nimport {getPropertyTablePopulated} from './EXT_structural_metadata';\n\nconst EXT_MESH_FEATURES_NAME = 'EXT_mesh_features';\nexport const name = EXT_MESH_FEATURES_NAME;\n\nexport async function decode(gltfData: {json: GLTF}, options: GLTFLoaderOptions): Promise<void> {\n const scenegraph = new GLTFScenegraph(gltfData);\n decodeExtMeshFeatures(scenegraph, options);\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 decodeExtMeshFeatures(scenegraph: GLTFScenegraph, options: GLTFLoaderOptions): void {\n const json = scenegraph.gltf.json;\n if (!json.meshes) {\n return;\n }\n\n // Iterate through all meshes/primitives.\n for (const mesh of json.meshes) {\n for (const primitive of mesh.primitives) {\n processMeshPrimitiveFeatures(scenegraph, primitive, options);\n }\n }\n}\n\n/**\n * Takes data from EXT_mesh_features and store it in 'data' property of featureIds.\n * If combined with EXT_structural_metadata, corresponding data are taken from the property tables of that extension.\n * @param {GLTFScenegraph} scenegraph - Instance of the class for structured access to GLTF data.\n * @param {GLTFMeshPrimitive} primitive - primitive that contains extensions.\n * @param {GLTFLoaderOptions} options - loader options.\n */\nfunction processMeshPrimitiveFeatures(\n scenegraph: GLTFScenegraph,\n primitive: GLTFMeshPrimitive,\n options: GLTFLoaderOptions\n): void {\n const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME] as GLTF_EXT_mesh_features;\n const featureIds: GLTF_EXT_mesh_features_featureId[] = extension?.featureIds;\n if (!featureIds) return;\n\n if (!extension.dataAttributeNames) {\n extension.dataAttributeNames = [];\n }\n\n let featureIdCount = 0; // It can be used to name the feature if neither label nor property table name is provided.\n for (const featureId of featureIds) {\n /*\n When combined with the EXT_structural_metadata extension, feature ID sets can be associated with property tables.\n A property table maps each feature ID to a set of values that are associated with the respective feature.\n The feature ID in this case serves as an index for the row of the table.\n The index of the property table that a certain set of feature IDs is associated with is stored in the propertyTable of the feature ID set definition.\n */\n let propertyTable: GLTF_EXT_structural_metadata_PropertyTable | null = null;\n if (typeof featureId.propertyTable === 'number') {\n propertyTable = getPropertyTablePopulated(scenegraph, featureId.propertyTable);\n }\n\n let propertyData: number[] | null = null;\n // Process \"Feature ID by Vertex\"\n if (typeof featureId.attribute !== 'undefined') {\n const accessorKey = `_FEATURE_ID_${featureId.attribute}`;\n const accessorIndex = primitive.attributes[accessorKey];\n const propertyDataTypedArray = scenegraph.getTypedArrayForAccessor(accessorIndex);\n propertyData = Array.prototype.slice.call(propertyDataTypedArray);\n }\n\n // Process \"Feature ID by Texture Coordinates\"\n else if (typeof featureId.texture !== 'undefined' && options?.gltf?.loadImages) {\n propertyData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive);\n }\n\n // Process \"Feature ID by Index\"\n else {\n /*\n When both featureId.attribute and featureId.texture are undefined,\n then the feature ID value for each vertex is given implicitly, via the index of the vertex.\n In this case, the featureCount must match the number of vertices of the mesh primitive.\n */\n // TODO: At the moment of writing we don't have a tileset with the data of that kind. Implement it later.\n }\n\n const attributeName =\n featureId.label || propertyTable?.name || `featureAttribute${featureIdCount}`;\n\n // featureTable - an array where unique data from the property data are being stored\n const featureTable: number[] = [];\n if (propertyData) {\n primitivePropertyDataToAttributes(\n scenegraph,\n attributeName,\n propertyData,\n featureTable,\n primitive\n );\n }\n extension.dataAttributeNames.push(attributeName);\n featureId.data = featureTable;\n\n featureIdCount++;\n }\n}\n"],"mappings":"AASA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SAAQC,uBAAuB,EAAEC,iCAAiC,QAAO,wBAAwB;AACjG,SAAQC,y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
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) {
|
|
@@ -42,6 +42,15 @@ function decodeExtStructuralMetadata(scenegraph, options) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
function findPropertyTableByClass(propertyTables, schemaClassName) {
|
|
46
|
+
for (let i = 0, len = propertyTables.length; i < len; i++) {
|
|
47
|
+
const propertyTable = propertyTables[i];
|
|
48
|
+
if (propertyTable.class === schemaClassName) {
|
|
49
|
+
return propertyTable;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
45
54
|
function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) {
|
|
46
55
|
var _primitive$extensions;
|
|
47
56
|
if (!propertyTextures) {
|
|
@@ -106,14 +115,8 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
|
|
|
106
115
|
let data = [];
|
|
107
116
|
const valuesBufferView = propertyTableProperty.values;
|
|
108
117
|
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
|
-
}
|
|
118
|
+
const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements);
|
|
119
|
+
const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements);
|
|
117
120
|
switch (classProperty.type) {
|
|
118
121
|
case 'SCALAR':
|
|
119
122
|
case 'VEC2':
|
|
@@ -145,11 +148,17 @@ function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numb
|
|
|
145
148
|
}
|
|
146
149
|
return data;
|
|
147
150
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return
|
|
151
|
+
function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) {
|
|
152
|
+
if (classProperty.array && typeof classProperty.count === 'undefined' && typeof propertyTableProperty.arrayOffsets !== 'undefined' && typeof propertyTableProperty.arrayOffsetType !== 'undefined') {
|
|
153
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType, numberOfElements);
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) {
|
|
158
|
+
if (typeof propertyTableProperty.stringOffsets !== 'undefined' && typeof propertyTableProperty.stringOffsetType !== 'undefined') {
|
|
159
|
+
return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType, numberOfElements);
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
153
162
|
}
|
|
154
163
|
function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
155
164
|
const isArray = classProperty.array;
|
|
@@ -159,52 +168,42 @@ function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes
|
|
|
159
168
|
let valuesData;
|
|
160
169
|
if (classProperty.componentType) {
|
|
161
170
|
valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, classProperty.componentType, elementCount);
|
|
171
|
+
if (!valuesData) {
|
|
172
|
+
valuesData = valuesDataBytes;
|
|
173
|
+
}
|
|
162
174
|
} else {
|
|
163
175
|
valuesData = valuesDataBytes;
|
|
164
176
|
}
|
|
165
177
|
if (isArray) {
|
|
166
178
|
if (arrayOffsets) {
|
|
167
|
-
return
|
|
179
|
+
return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize);
|
|
168
180
|
}
|
|
169
181
|
if (arrayCount) {
|
|
170
|
-
return
|
|
182
|
+
return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount);
|
|
171
183
|
}
|
|
172
184
|
return [];
|
|
173
185
|
}
|
|
174
|
-
|
|
175
|
-
for (let index = 0; index < numberOfElements; index++) {
|
|
176
|
-
const value = valuesData[index];
|
|
177
|
-
attributeValueArray.push(value);
|
|
178
|
-
}
|
|
179
|
-
return attributeValueArray;
|
|
186
|
+
return valuesData;
|
|
180
187
|
}
|
|
181
|
-
function
|
|
188
|
+
function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) {
|
|
182
189
|
const attributeValueArray = [];
|
|
183
190
|
for (let index = 0; index < numberOfElements; index++) {
|
|
184
|
-
const array = [];
|
|
185
191
|
const arrayOffset = arrayOffsets[index];
|
|
186
192
|
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
|
-
}
|
|
193
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
194
|
+
break;
|
|
194
195
|
}
|
|
195
|
-
|
|
196
|
+
const typedArrayOffset = arrayOffset / valueSize;
|
|
197
|
+
const elementCount = arrayByteSize / valueSize;
|
|
198
|
+
attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount));
|
|
196
199
|
}
|
|
197
200
|
return attributeValueArray;
|
|
198
201
|
}
|
|
199
|
-
function
|
|
202
|
+
function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) {
|
|
200
203
|
const attributeValueArray = [];
|
|
201
204
|
for (let index = 0; index < numberOfElements; index++) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
const value = valuesData[i];
|
|
205
|
-
array.push(value);
|
|
206
|
-
}
|
|
207
|
-
attributeValueArray.push(array);
|
|
205
|
+
const elementOffset = index * arrayCount;
|
|
206
|
+
attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount));
|
|
208
207
|
}
|
|
209
208
|
return attributeValueArray;
|
|
210
209
|
}
|
|
@@ -231,9 +230,6 @@ function getPropertyDataString(classProperty, numberOfElements, valuesDataBytes,
|
|
|
231
230
|
}
|
|
232
231
|
function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) {
|
|
233
232
|
var _schema$enums;
|
|
234
|
-
const data = [];
|
|
235
|
-
const isArray = classProperty.array;
|
|
236
|
-
const arrayCount = classProperty.count;
|
|
237
233
|
const enumType = classProperty.enumType;
|
|
238
234
|
if (!enumType) {
|
|
239
235
|
throw new Error('Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM');
|
|
@@ -245,69 +241,77 @@ function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesData
|
|
|
245
241
|
const enumValueType = enumEntry.valueType || 'UINT16';
|
|
246
242
|
const elementSize = getArrayElementByteSize(classProperty.type, enumValueType);
|
|
247
243
|
const elementCount = valuesDataBytes.byteLength / elementSize;
|
|
248
|
-
|
|
249
|
-
if (
|
|
244
|
+
let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount);
|
|
245
|
+
if (!valuesData) {
|
|
246
|
+
valuesData = valuesDataBytes;
|
|
247
|
+
}
|
|
248
|
+
if (classProperty.array) {
|
|
250
249
|
if (arrayOffsets) {
|
|
251
|
-
return
|
|
250
|
+
return parseVariableLengthArrayENUM({
|
|
251
|
+
valuesData,
|
|
252
|
+
numberOfElements,
|
|
253
|
+
arrayOffsets,
|
|
254
|
+
valuesDataBytesLength: valuesDataBytes.length,
|
|
255
|
+
elementSize,
|
|
256
|
+
enumEntry
|
|
257
|
+
});
|
|
252
258
|
}
|
|
259
|
+
const arrayCount = classProperty.count;
|
|
253
260
|
if (arrayCount) {
|
|
254
|
-
return
|
|
261
|
+
return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry);
|
|
255
262
|
}
|
|
256
263
|
return [];
|
|
257
264
|
}
|
|
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;
|
|
265
|
+
return getEnumsArray(valuesData, 0, numberOfElements, enumEntry);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function parseVariableLengthArrayENUM(params) {
|
|
268
|
+
const {
|
|
269
|
+
valuesData,
|
|
270
|
+
numberOfElements,
|
|
271
|
+
arrayOffsets,
|
|
272
|
+
valuesDataBytesLength,
|
|
273
|
+
elementSize,
|
|
274
|
+
enumEntry
|
|
275
|
+
} = params;
|
|
268
276
|
const attributeValueArray = [];
|
|
269
277
|
for (let index = 0; index < numberOfElements; index++) {
|
|
270
|
-
const array = [];
|
|
271
278
|
const arrayOffset = arrayOffsets[index];
|
|
272
279
|
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
|
-
}
|
|
280
|
+
if (arrayByteSize + arrayOffset > valuesDataBytesLength) {
|
|
281
|
+
break;
|
|
283
282
|
}
|
|
283
|
+
const typedArrayOffset = arrayOffset / elementSize;
|
|
284
|
+
const elementCount = arrayByteSize / elementSize;
|
|
285
|
+
const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry);
|
|
284
286
|
attributeValueArray.push(array);
|
|
285
287
|
}
|
|
286
288
|
return attributeValueArray;
|
|
287
289
|
}
|
|
288
|
-
function
|
|
290
|
+
function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) {
|
|
289
291
|
const attributeValueArray = [];
|
|
290
292
|
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
|
-
}
|
|
293
|
+
const elementOffset = arrayCount * index;
|
|
294
|
+
const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry);
|
|
299
295
|
attributeValueArray.push(array);
|
|
300
296
|
}
|
|
301
297
|
return attributeValueArray;
|
|
302
298
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (
|
|
307
|
-
|
|
299
|
+
function getEnumsArray(valuesData, offset, count, enumEntry) {
|
|
300
|
+
const array = [];
|
|
301
|
+
for (let i = 0; i < count; i++) {
|
|
302
|
+
if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) {
|
|
303
|
+
array.push('');
|
|
304
|
+
} else {
|
|
305
|
+
const value = valuesData[offset + i];
|
|
306
|
+
const enumObject = getEnumByValue(enumEntry, value);
|
|
307
|
+
if (enumObject) {
|
|
308
|
+
array.push(enumObject.name);
|
|
309
|
+
} else {
|
|
310
|
+
array.push('');
|
|
311
|
+
}
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
|
-
return
|
|
314
|
+
return array;
|
|
311
315
|
}
|
|
312
316
|
function getEnumByValue(enumEntry, value) {
|
|
313
317
|
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 null;\n}\n"],"mappings":"AAiBA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SACEC,+BAA+B,EAC/BC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tB,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","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","schemaClassName","i","len","length","class","_primitive$extensions","primitiveExtension","extensions","primitivePropertyTextureIndices","primitivePropertyTextureIndex","propertyTexture","processPrimitivePropertyTexture","properties","dataAttributeNames","className","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","getArrayOffsetsForProperty","stringOffsets","getStringOffsetsForProperty","type","getPropertyDataNumeric","getPropertyDataString","getPropertyDataENUM","array","arrayOffsetType","stringOffsetType","isArray","arrayCount","elementSize","componentType","elementCount","byteLength","valuesData","parseVariableLengthArrayNumeric","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","BigInt64Array","BigUint64Array","value","enumObject","getEnumByValue","enumValue"],"sources":["../../../../src/lib/extensions/EXT_structural_metadata.ts"],"sourcesContent":["/* 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,\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';\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// 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 | 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 - 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 * Find 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 (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 * 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\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\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 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 * Parse 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 typeof propertyTableProperty.arrayOffsetType !== 'undefined'\n ) {\n // Data are in a VARIABLE-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.arrayOffsets,\n propertyTableProperty.arrayOffsetType,\n numberOfElements\n );\n }\n return null;\n}\n\n/**\n * Parse 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 typeof propertyTableProperty.stringOffsetType !== 'undefined'\n ) {\n // Data are in a FIXED-length array\n return getOffsetsForProperty(\n scenegraph,\n propertyTableProperty.stringOffsets,\n propertyTableProperty.stringOffsetType,\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 * Parse 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 * Parse 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 * Parse 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 * Parse 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 * Parse 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 string 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":"AAgBA,SAAQA,cAAc,QAAO,wBAAwB;AACrD,SACEC,+BAA+B,EAC/BC,uBAAuB,EACvBC,iCAAiC,EACjCC,uBAAuB,EAEvBC,qBAAqB,QAChB,wBAAwB;AAE/B,MAAMC,4BAA4B,GAAG,yBAAyB;AAC9D,OAAO,MAAMC,IAAI,GAAGD,4BAA4B;AAEhD,OAAO,eAAeE,MAAMA,CAACC,QAAsB,EAAEC,OAA0B,EAAiB;EAC9F,MAAMC,UAAU,GAAG,IAAIX,cAAc,CAACS,QAAQ,CAAC;EAC/CG,2BAA2B,CAACD,UAAU,EAAED,OAAO,CAAC;AAClD;AAkEA,OAAO,SAASG,yBAAyBA,CACvCF,UAA0B,EAC1BG,kBAA0B,EACkB;EAAA,IAAAC,qBAAA;EAC5C,MAAMC,SAA8C,GAAGL,UAAU,CAACM,YAAY,CAC5EX,4BACF,CAAC;EACD,MAAMY,aAAa,GAAGF,SAAS,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IAAI,CAACiE,UAAU,CAACtH,IAAI,CAAC;MAC7B,CAAC,MAAM;QACL2E,KAAK,CAACtB,IAAI,CAAC,EAAE,CAAC;MAChB;IACF;EACF;EACA,OAAOsB,KAAK;AACd;AAQA,SAAS4C,cAAcA,CACrBb,SAA4C,EAC5CW,KAAa,EACkC;EAC/C,KAAK,MAAMG,SAAS,IAAId,SAAS,CAAC1C,MAAM,EAAE;IACxC,IAAIwD,SAAS,CAACH,KAAK,KAAKA,KAAK,EAAE;MAC7B,OAAOG,SAAS;IAClB;EACF;EAEA,OAAO,IAAI;AACb"}
|
|
@@ -2,6 +2,7 @@ import { GLTFScenegraph } from '../../api/gltf-scenegraph';
|
|
|
2
2
|
import { getImageData } from '@loaders.gl/images';
|
|
3
3
|
import { getComponentTypeFromArray } from '../../gltf-utils/gltf-utils';
|
|
4
4
|
import { emod } from '@loaders.gl/math';
|
|
5
|
+
import { convertRawBufferToMetadataArray, getOffsetsForProperty } from '../utils/3d-tiles-utils';
|
|
5
6
|
const EXT_FEATURE_METADATA_NAME = 'EXT_feature_metadata';
|
|
6
7
|
export const name = EXT_FEATURE_METADATA_NAME;
|
|
7
8
|
export async function decode(gltfData, options) {
|
|
@@ -64,17 +65,33 @@ function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass)
|
|
|
64
65
|
function getPropertyDataFromBinarySource(scenegraph, schemaProperty, numberOfFeatures, featureTableProperty) {
|
|
65
66
|
const bufferView = featureTableProperty.bufferView;
|
|
66
67
|
const dataArray = scenegraph.getTypedArrayForBufferView(bufferView);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
if (schemaProperty.type === 'STRING') {
|
|
69
|
+
const offsetsData = getStringOffsets(scenegraph, featureTableProperty, numberOfFeatures);
|
|
70
|
+
if (!offsetsData) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return getStringAttributes(dataArray, offsetsData, numberOfFeatures);
|
|
74
|
+
} else if (isNumericProperty(schemaProperty.type)) {
|
|
75
|
+
return getNumericAttributes(dataArray, schemaProperty.type, numberOfFeatures);
|
|
75
76
|
}
|
|
76
77
|
return dataArray;
|
|
77
78
|
}
|
|
79
|
+
function isNumericProperty(schemaPropertyType) {
|
|
80
|
+
return ['UINT8', 'INT16', 'UINT16', 'INT32', 'UINT32', 'INT64', 'UINT64', 'FLOAT32', 'FLOAT64'].includes(schemaPropertyType);
|
|
81
|
+
}
|
|
82
|
+
function getStringOffsets(scenegraph, featureTableProperty, numberOfElements) {
|
|
83
|
+
if (typeof featureTableProperty.stringOffsetBufferView !== 'undefined') {
|
|
84
|
+
return getOffsetsForProperty(scenegraph, featureTableProperty.stringOffsetBufferView, featureTableProperty.offsetType || 'UINT32', numberOfElements);
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
function getNumericAttributes(valuesDataBytes, propertyType, elementCount) {
|
|
89
|
+
let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, 'SCALAR', propertyType, elementCount);
|
|
90
|
+
if (!valuesData) {
|
|
91
|
+
valuesData = valuesDataBytes;
|
|
92
|
+
}
|
|
93
|
+
return valuesData;
|
|
94
|
+
}
|
|
78
95
|
function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) {
|
|
79
96
|
const json = scenegraph.gltf.json;
|
|
80
97
|
if (!json.meshes) {
|
|
@@ -206,14 +223,10 @@ function findFeatureTextureByName(featureTextures, schemaClassName) {
|
|
|
206
223
|
function getStringAttributes(data, offsetsData, stringsCount) {
|
|
207
224
|
const stringsArray = [];
|
|
208
225
|
const textDecoder = new TextDecoder('utf8');
|
|
209
|
-
let stringOffset = 0;
|
|
210
|
-
const bytesPerStringSize = 4;
|
|
211
226
|
for (let index = 0; index < stringsCount; index++) {
|
|
212
|
-
const
|
|
213
|
-
const stringData = data.subarray(stringOffset, stringByteSize + stringOffset);
|
|
227
|
+
const stringData = data.slice(offsetsData[index], offsetsData[index + 1]);
|
|
214
228
|
const stringAttribute = textDecoder.decode(stringData);
|
|
215
229
|
stringsArray.push(stringAttribute);
|
|
216
|
-
stringOffset += stringByteSize;
|
|
217
230
|
}
|
|
218
231
|
return stringsArray;
|
|
219
232
|
}
|