tinygltf
tinygltf copied to clipboard
Implement BINARY_TYPE serialization
Describe the issue
At these locations, support for BINARY_TYPE is missing https://github.com/syoyo/tinygltf/blob/master/tiny_gltf.h#L6442 https://github.com/syoyo/tinygltf/blob/master/tiny_gltf.h#L6486
This case needs handling or tiny_gltf fails to output BINARY_TYPE values.
case BINARY_TYPE:
// TODO
// obj = json(value.Get<std::vector<unsigned char>>());
return false;
break;
A workaround exists by using base64
// Serialize
std::map<std::string, tinygltf::Value> extras;
extras["custom"] = tinygltf::Value(tinygltf::base64_encode(data, length);
gltf.extras = tinygltf::Value(extras);
// Deserialize
tinygltf::base64_decode(gltf.extras.Get("custom").Get<std::string>());
To Reproduce
- OS: Any
- Compiler, compiler version, compile options: Any
tinygltf::Model gltf;
std::map<std::string, tinygltf::Value> extras;
auto someData = std::vector<unsigned char>({'a', 'b'});
extras["custom"] = tinygltf::Value(someData);
gltf.extras = tinygltf::Value(extras);
Expected behaviour
Handle BINARY_TYPE so that manual base64 encoding does not need to be done
@raffclar I see. Having BINARY_TYPE
support through base64 encoding would be nice. PR is much appreciated!