glTF-SDK icon indicating copy to clipboard operation
glTF-SDK copied to clipboard

Support for base64 encoded buffers

Open tulvanchristian opened this issue 4 years ago • 5 comments

Hello,

Currently, the buffers are referenced by URI (path to bin file) I propose adding a function to set the URI as a base64 encoded string. The encoding itself could be done outside of the library.

As a work-around a base64 buffer can be set by using the URI variable with the appropriate length. Update on GLTFSDK/Source/BufferBuilder.cpp to add setCurrentBufferURI function 280: + bool BufferBuilder::setCurrentBufferURI ( const std::string &data ) 281: + { 282: + assert ( m_buffers.size() > 0 ); 283: + size_t index = m_buffers.size() - 1;
284: + m_buffers [ index ].uri = data; 285: + m_buffers [ index ].length = data.length(); 286: + return true; 287: + } 288: +

Please let me know if I should create a pull request.

Thank you !

tulvanchristian avatar Sep 22 '20 15:09 tulvanchristian

Please let me know if I should create a pull request.

Yes, please do. It will be easier to comment then pasting code in an issue :-)

bghgary avatar Sep 22 '20 17:09 bghgary

Thank you for the reply. I updated the code but when i try to create a new branch and create a new pull request, i get permission denied. Are the permissions on my account enough for these actions ? Or is there a different procedure ? Best regards, Christian

tulvanchristian avatar Sep 30 '20 15:09 tulvanchristian

Typically you want to create a fork and then create a PR from the fork. Try this.

bghgary avatar Sep 30 '20 17:09 bghgary

Thanks a lot for the help. I just created a fork and pushed the code here: https://github.com/tulvanchristian/glTF-SDK

The commit includes fixes for:

  • Support for base64 encoded buffers #59
  • Set child name (rootProperty) #60
  • Direct access to buffers and accessors #61

Please let me know if this is ok and if you need more information, do not hesitate to contact me.

Best regards, Christian

tulvanchristian avatar Oct 05 '20 11:10 tulvanchristian

Please create a pull request from the branch in your fork. Thanks!

bghgary avatar Oct 05 '20 18:10 bghgary