mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 08:05:58 +08:00
asset.version
is a required field so write "2.0" when asset.version
is empty. Fixes #308
This commit is contained in:
parent
58ceed1d89
commit
b702de755f
@ -432,7 +432,6 @@ TEST_CASE("serialize-empty-material", "[issue-294]") {
|
||||
nlohmann::json j = nlohmann::json::parse(os.str());
|
||||
|
||||
REQUIRE(1 == j["materials"].size());
|
||||
REQUIRE(j["asset"].is_null());
|
||||
REQUIRE(j["materials"][0].is_object());
|
||||
|
||||
}
|
||||
|
13
tiny_gltf.h
13
tiny_gltf.h
@ -4,7 +4,7 @@
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 - 2020 Syoyo Fujita, Aurélien Chatelain and many
|
||||
// Copyright (c) 2015 - Present Syoyo Fujita, Aurélien Chatelain and many
|
||||
// contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -1071,7 +1071,7 @@ struct Buffer {
|
||||
};
|
||||
|
||||
struct Asset {
|
||||
std::string version; // required
|
||||
std::string version = "2.0"; // required
|
||||
std::string generator;
|
||||
std::string minVersion;
|
||||
std::string copyright;
|
||||
@ -6760,10 +6760,15 @@ static void SerializeGltfAsset(Asset &asset, json &o) {
|
||||
SerializeStringProperty("copyright", asset.copyright, o);
|
||||
}
|
||||
|
||||
if (!asset.version.empty()) {
|
||||
SerializeStringProperty("version", asset.version, o);
|
||||
if (asset.version.empty()) {
|
||||
// Just in case
|
||||
// `version` must be defined
|
||||
asset.version = "2.0";
|
||||
}
|
||||
|
||||
// TODO(syoyo): Do we need to check if `version` is greater or equal to 2.0?
|
||||
SerializeStringProperty("version", asset.version, o);
|
||||
|
||||
if (asset.extras.Keys().size()) {
|
||||
SerializeValue("extras", asset.extras, o);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user