Support gltf-buffer mime.

Make `min` and `max` parameters in `Accessor` optional.
This commit is contained in:
Syoyo Fujita 2018-06-04 18:26:05 +09:00
parent 57f8e7ca3b
commit 0067a9e43a

View File

@ -1010,6 +1010,14 @@ static bool IsDataURI(const std::string &in) {
return true;
}
// NOTE(syoyo) `gltf-buffer` is still in draft as of Jun 4, 2018,
// but some glTF sample model uses `gltf-buffer` so we deal with it.
// https://github.com/KhronosGroup/glTF/pull/1180
header = "data:application/gltf-buffer;base64,";
if (in.find(header) == 0) {
return true;
}
header = "data:image/png;base64,";
if (in.find(header) == 0) {
return true;
@ -1037,6 +1045,13 @@ static bool DecodeDataURI(std::vector<unsigned char> *out,
data = base64_decode(in.substr(header.size())); // cut mime string.
}
if (data.empty()) {
header = "data:application/gltf-buffer;base64,";
if (in.find(header) == 0) {
data = base64_decode(in.substr(header.size())); // cut mime string.
}
}
if (data.empty()) {
header = "data:image/jpeg;base64,";
if (in.find(header) == 0) {
@ -1662,11 +1677,11 @@ static bool ParseAccessor(Accessor *accessor, std::string *err,
accessor->minValues.clear();
accessor->maxValues.clear();
if(!ParseNumberArrayProperty(&accessor->minValues, err, o, "min", true, "Accessor")) {
if(!ParseNumberArrayProperty(&accessor->minValues, err, o, "min", false, "Accessor")) {
return false;
}
if(!ParseNumberArrayProperty(&accessor->maxValues, err, o, "max", true, "Accessor")) {
if(!ParseNumberArrayProperty(&accessor->maxValues, err, o, "max", false, "Accessor")) {
return false;
}