Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BINARY_TYPE serialization #360

Open
raffclar opened this issue Jun 8, 2022 · 1 comment
Open

Implement BINARY_TYPE serialization #360

raffclar opened this issue Jun 8, 2022 · 1 comment

Comments

@raffclar
Copy link

raffclar commented Jun 8, 2022

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

@syoyo
Copy link
Owner

syoyo commented Jun 8, 2022

@raffclar I see. Having BINARY_TYPE support through base64 encoding would be nice. PR is much appreciated!

@syoyo syoyo closed this as completed Jul 18, 2022
@syoyo syoyo reopened this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants