Vertex attributes added using emscripten path hard codes normalized flag to false
See https://github.com/KhronosGroup/glTF-Blender-IO/issues/2013 for some context.
It appears from the code here that there is no way to add a vertex attribute that has the normalized flag set to true through the emscripten code path. This causes issues when trying to decode normalized vertex attributes since the decode APIs will return an attribute with normalized as false when it should be true.
int PointCloudBuilder::AddAttribute(GeometryAttribute::Type attribute_type,
int8_t num_components, DataType data_type) {
GeometryAttribute ga;
ga.Init(attribute_type, nullptr, num_components, data_type, false /* !!THIS IS HARDCODED!! */,
DataTypeLength(data_type) * num_components, 0);
return point_cloud_->AddAttribute(ga, true, point_cloud_->num_points());
}
To repro:
- Download the
test.zipfrom this issue and extractno_draco_ushort_uvs.glb. - Use Don's glTF-Transform tool to encode Draco with the following command line:
gltf-transform draco no_draco_ushort_uvs.glb test.glb - Open test.glb with the Babylon.js sandbox
Result: The console will output:
Normalized flag from Draco data (false) does not match normalized flag from glTF accessor (true). Using flag from glTF accessor.
Expected: The console does not show this warning.
Support for normalized attributes in encoder emscripten will be added in the next release.