in src/gltf/properties/NodeData.cpp [55:103]
json NodeData::serialize() const {
json result = {{"name", name}};
// if any of the T/R/S have NaN components, just leave them out of the glTF
auto maybeAdd = [&](std::string key, std::vector<float> vec) -> void {
if (std::none_of(vec.begin(), vec.end(), [&](float n) { return std::isnan(n); })) {
result[key] = vec;
}
};
maybeAdd("translation", toStdVec(translation));
maybeAdd("rotation", toStdVec(rotation));
maybeAdd("scale", toStdVec(scale));
if (!children.empty()) {
result["children"] = children;
}
if (isJoint) {
// sanity-check joint node
assert(mesh < 0 && skin < 0);
} else {
// non-joint node
if (mesh >= 0) {
result["mesh"] = mesh;
}
if (!skeletons.empty()) {
result["skeletons"] = skeletons;
}
if (skin >= 0) {
result["skin"] = skin;
}
if (camera >= 0) {
result["camera"] = camera;
}
if (light >= 0) {
result["extensions"][KHR_LIGHTS_PUNCTUAL]["light"] = light;
}
}
for (const auto& i : userProperties) {
auto& prop_map = result["extras"]["fromFBX"]["userProperties"];
json j = json::parse(i);
for (const auto& k : json::iterator_wrapper(j)) {
prop_map[k.key()] = k.value();
}
}
return result;
}