Maps attribute names from older versions of the extension to the names from the current version of the extension.
| 364 | // Maps attribute names from older versions of the extension to the names from |
| 365 | // the current version of the extension. |
| 366 | void fixAttributeNames(CesiumGltf::MeshPrimitive& primitive) { |
| 367 | std::vector<std::string> attributesToConvert; |
| 368 | attributesToConvert.reserve(primitive.attributes.size()); |
| 369 | for (const std::pair<const std::string, int32_t>& attribute : |
| 370 | primitive.attributes) { |
| 371 | if (attribute.first == "_SCALE" || attribute.first == "_ROTATION" || |
| 372 | attribute.first.starts_with("_SH_DEGREE_")) { |
| 373 | attributesToConvert.push_back(attribute.first); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | for (const std::string& oldName : attributesToConvert) { |
| 378 | const int32_t accessorIndex = primitive.attributes[oldName]; |
| 379 | primitive.attributes.erase(oldName); |
| 380 | primitive.attributes.emplace( |
| 381 | "KHR_gaussian_splatting:" + oldName.substr(1), |
| 382 | accessorIndex); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | CesiumGltf::ExtensionKhrGaussianSplattingCompressionSpz2* |
| 387 | getAndMaybeConvertSpzExtension( |