diff --git a/src/gltf/GltfModel.hpp b/src/gltf/GltfModel.hpp index 0c4f40e..726e010 100644 --- a/src/gltf/GltfModel.hpp +++ b/src/gltf/GltfModel.hpp @@ -191,9 +191,14 @@ class GltfModel { if (!holder.ptrs.empty()) { std::vector bits; for (const auto& ptr : holder.ptrs) { - bits.push_back(ptr->serialize()); + json bit = ptr->serialize(); + if (!bit.empty()) { + bits.push_back(ptr->serialize()); + } + } + if (!bits.empty()) { + glTFJson[key] = bits; } - glTFJson[key] = bits; } } diff --git a/src/gltf/properties/BufferData.cpp b/src/gltf/properties/BufferData.cpp index b4394e9..317c119 100644 --- a/src/gltf/properties/BufferData.cpp +++ b/src/gltf/properties/BufferData.cpp @@ -20,6 +20,10 @@ BufferData::BufferData( : Holdable(), isGlb(false), uri(isEmbedded ? "" : std::move(uri)), binData(binData) {} json BufferData::serialize() const { + if (binData->empty()) { + return json{}; + } + json result{{"byteLength", binData->size()}}; if (!isGlb) { if (!uri.empty()) {