diff --git a/src/gltf/properties/MeshData.cpp b/src/gltf/properties/MeshData.cpp index 0ec3cdd5..36c06dcb 100644 --- a/src/gltf/properties/MeshData.cpp +++ b/src/gltf/properties/MeshData.cpp @@ -14,12 +14,21 @@ MeshData::MeshData(const std::string& name, const std::vector& weights) json MeshData::serialize() const { json jsonPrimitivesArray = json::array(); + json jsonTargetNamesArray = json::array(); for (const auto& primitive : primitives) { jsonPrimitivesArray.push_back(*primitive); + if (!primitive->targetNames.empty()) { + for (auto targetName : primitive->targetNames) { + jsonTargetNamesArray.push_back(targetName); + } + } } json result = {{"name", name}, {"primitives", jsonPrimitivesArray}}; if (!weights.empty()) { result["weights"] = weights; } + if (!jsonTargetNamesArray.empty()) { + result["extras"]["targetNames"] = jsonTargetNamesArray; + } return result; } diff --git a/src/gltf/properties/PrimitiveData.cpp b/src/gltf/properties/PrimitiveData.cpp index 9ee0bccb..14d3a295 100644 --- a/src/gltf/properties/PrimitiveData.cpp +++ b/src/gltf/properties/PrimitiveData.cpp @@ -45,6 +45,7 @@ void PrimitiveData::AddTarget( positions->ix, normals != nullptr ? normals->ix : -1, tangents != nullptr ? tangents->ix : -1)); + targetNames.push_back(positions->name); } void to_json(json& j, const PrimitiveData& d) { diff --git a/src/gltf/properties/PrimitiveData.hpp b/src/gltf/properties/PrimitiveData.hpp index 6e87e533..1ff401b2 100644 --- a/src/gltf/properties/PrimitiveData.hpp +++ b/src/gltf/properties/PrimitiveData.hpp @@ -68,6 +68,7 @@ struct PrimitiveData { const MeshMode mode; std::vector> targetAccessors{}; + std::vector targetNames{}; std::map attributes; std::map dracoAttributes;