void to_json()

in src/gltf/properties/PrimitiveData.cpp [51:79]


void to_json(json& j, const PrimitiveData& d) {
  j = {{"material", d.material}, {"mode", d.mode}, {"attributes", d.attributes}};
  if (d.indices >= 0) {
    j["indices"] = d.indices;
  }
  if (!d.targetAccessors.empty()) {
    json targets{};
    int pIx, nIx, tIx;
    for (auto accessor : d.targetAccessors) {
      std::tie(pIx, nIx, tIx) = accessor;
      json target{};
      if (pIx >= 0) {
        target["POSITION"] = pIx;
      }
      if (nIx >= 0) {
        target["NORMAL"] = nIx;
      }
      if (tIx >= 0) {
        target["TANGENT"] = tIx;
      }
      targets.push_back(target);
    }
    j["targets"] = targets;
  }
  if (!d.dracoAttributes.empty()) {
    j["extensions"] = {{KHR_DRACO_MESH_COMPRESSION,
                        {{"bufferView", d.dracoBufferView}, {"attributes", d.dracoAttributes}}}};
  }
}