VoxelProvider is inconsistent with the rest of the repo in the way it handles metadata properties.
Metadata properties are specified in the tileset.json / schema.json as a list of objects:
"properties": {
"property1": {
"type": "SCALAR",
"componentType": "FLOAT32"
},
"property2": {
"type": "VEC2",
"componentType": "FLOAT32"
}
}
But in VoxelProvider these are flattened into arrays, as follows:
/**
* Gets the metadata names.
*
* @type {string[]}
* @readonly
* @constant
*/
names;
/**
* Gets the metadata types.
*
* @type {MetadataType[]}
* @readonly
* @constant
*/
types;
/**
* Gets the metadata component types.
*
* @type {MetadataComponentType[]}
* @readonly
* @constant
*/
componentTypes;
While this structure may initially have been chosen for performance reasons, in the current code we only loop over properties once when loading a VoxelProvider, so performance benefits (if any) are minimal. Meanwhile, the flattened array pattern adds complexity in a few places:
- Looping over properties: we have to look up the name, type, and componentType of each property separately, assuming/hoping that the indices are consistent
- TS/JSDoc documentation for internal functions: a helper function that loops over properties has an awkward return type. See
getAttributeInfo in Cesium3DTilesVoxelProvider:
return {
className,
names,
types,
componentTypes,
minimumValues: hasMinimumValues ? minimumValues : undefined,
maximumValues: hasMinimumValues ? maximumValues : undefined,
};
As part of #12297 we should simplify and improve documentation by using lists of property info objects, following the pattern of the metadata schema.
VoxelProvideris inconsistent with the rest of the repo in the way it handles metadata properties.Metadata properties are specified in the tileset.json / schema.json as a list of objects:
But in
VoxelProviderthese are flattened into arrays, as follows:While this structure may initially have been chosen for performance reasons, in the current code we only loop over properties once when loading a
VoxelProvider, so performance benefits (if any) are minimal. Meanwhile, the flattened array pattern adds complexity in a few places:getAttributeInfoinCesium3DTilesVoxelProvider:As part of #12297 we should simplify and improve documentation by using lists of property info objects, following the pattern of the metadata schema.