Skip to content

Commit 1d73569

Browse files
vfxgordonPär Winzell
authored and
Pär Winzell
committed
Morph target names output to mesh.extras.targetNames (facebookincubator#231)
1 parent 5c3229d commit 1d73569

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/gltf/properties/MeshData.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@ MeshData::MeshData(const std::string& name, const std::vector<float>& weights)
1414

1515
json MeshData::serialize() const {
1616
json jsonPrimitivesArray = json::array();
17+
json jsonTargetNamesArray = json::array();
1718
for (const auto& primitive : primitives) {
1819
jsonPrimitivesArray.push_back(*primitive);
20+
if (!primitive->targetNames.empty()) {
21+
for (auto targetName : primitive->targetNames) {
22+
jsonTargetNamesArray.push_back(targetName);
23+
}
24+
}
1925
}
2026
json result = {{"name", name}, {"primitives", jsonPrimitivesArray}};
2127
if (!weights.empty()) {
2228
result["weights"] = weights;
2329
}
30+
if (!jsonTargetNamesArray.empty()) {
31+
result["extras"]["targetNames"] = jsonTargetNamesArray;
32+
}
2433
return result;
2534
}

src/gltf/properties/PrimitiveData.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void PrimitiveData::AddTarget(
4545
positions->ix,
4646
normals != nullptr ? normals->ix : -1,
4747
tangents != nullptr ? tangents->ix : -1));
48+
targetNames.push_back(positions->name);
4849
}
4950

5051
void to_json(json& j, const PrimitiveData& d) {

src/gltf/properties/PrimitiveData.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ struct PrimitiveData {
6868
const MeshMode mode;
6969

7070
std::vector<std::tuple<int, int, int>> targetAccessors{};
71+
std::vector<std::string> targetNames{};
7172

7273
std::map<std::string, int> attributes;
7374
std::map<std::string, int> dracoAttributes;

0 commit comments

Comments
 (0)