Morph target names output to mesh.extras.targetNames (#231)
This commit is contained in:
parent
5c3229d6cf
commit
1d735698ba
|
@ -14,12 +14,21 @@ MeshData::MeshData(const std::string& name, const std::vector<float>& weights)
|
||||||
|
|
||||||
json MeshData::serialize() const {
|
json MeshData::serialize() const {
|
||||||
json jsonPrimitivesArray = json::array();
|
json jsonPrimitivesArray = json::array();
|
||||||
|
json jsonTargetNamesArray = json::array();
|
||||||
for (const auto& primitive : primitives) {
|
for (const auto& primitive : primitives) {
|
||||||
jsonPrimitivesArray.push_back(*primitive);
|
jsonPrimitivesArray.push_back(*primitive);
|
||||||
|
if (!primitive->targetNames.empty()) {
|
||||||
|
for (auto targetName : primitive->targetNames) {
|
||||||
|
jsonTargetNamesArray.push_back(targetName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
json result = {{"name", name}, {"primitives", jsonPrimitivesArray}};
|
json result = {{"name", name}, {"primitives", jsonPrimitivesArray}};
|
||||||
if (!weights.empty()) {
|
if (!weights.empty()) {
|
||||||
result["weights"] = weights;
|
result["weights"] = weights;
|
||||||
}
|
}
|
||||||
|
if (!jsonTargetNamesArray.empty()) {
|
||||||
|
result["extras"]["targetNames"] = jsonTargetNamesArray;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ void PrimitiveData::AddTarget(
|
||||||
positions->ix,
|
positions->ix,
|
||||||
normals != nullptr ? normals->ix : -1,
|
normals != nullptr ? normals->ix : -1,
|
||||||
tangents != nullptr ? tangents->ix : -1));
|
tangents != nullptr ? tangents->ix : -1));
|
||||||
|
targetNames.push_back(positions->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void to_json(json& j, const PrimitiveData& d) {
|
void to_json(json& j, const PrimitiveData& d) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct PrimitiveData {
|
||||||
const MeshMode mode;
|
const MeshMode mode;
|
||||||
|
|
||||||
std::vector<std::tuple<int, int, int>> targetAccessors{};
|
std::vector<std::tuple<int, int, int>> targetAccessors{};
|
||||||
|
std::vector<std::string> targetNames{};
|
||||||
|
|
||||||
std::map<std::string, int> attributes;
|
std::map<std::string, int> attributes;
|
||||||
std::map<std::string, int> dracoAttributes;
|
std::map<std::string, int> dracoAttributes;
|
||||||
|
|
Loading…
Reference in New Issue