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

Buffer data embedding option #76

Open
NoOverflow opened this issue Oct 8, 2020 · 6 comments
Open

Buffer data embedding option #76

NoOverflow opened this issue Oct 8, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@NoOverflow
Copy link

Hi, after some research I can't find any option to embed the buffer data into the .gltf file (and not in a separate .bin file)

Following the glTF reference guide this is fully possible :
https://www.khronos.org/files/gltf20-reference-guide.pdf

I even tried it by modifying the "url" property of the buffer in the JSON from "*.bin" to "data:application/gltf-buffer;base64,..." and it worked perfectly.

I was expecting Schema2.WriteSettings to contain such an option (Something like .BufferWriting = SharpGLTF.Schema2.ResourceWriteMode.Embedded) but maybe it is somewhere else. If it is indeed missing I'll gladly add it with a pull request.

Thanks

@vpenades
Copy link
Owner

vpenades commented Oct 8, 2020

The library does not support embedding the buffers into the json when writing.

Given you can also write files in GLB format, I didn't consider it useful, because embedded buffers are encoded in base64 and are very inefficient.

Is there a particular reason why you need embedding the buffers into the json?

@NoOverflow
Copy link
Author

I'm sending small 3D objects to a local web interface (then displayed using google model viewer), so size doesn't matter and I may need to access glTF json data at some point, that's why I wanted to use embedded buffers (I could also use binary format and then parse it but as size and efficiency are not really critical factors I just didn't bother).

@vpenades
Copy link
Owner

vpenades commented Oct 8, 2020

I understand... well, writing embedded buffers support is a non trivial change, I'll look into it, but don't expect a solution soon... it will probably be added for the next release

@NoOverflow
Copy link
Author

I'll take a look at it to see if I can help. Don't worry about it too much though, I'll stick to binary for now and figure another way. Anyway thanks for your time !

@vpenades
Copy link
Owner

vpenades commented Oct 8, 2020

As you guessed, it needs another buffer write settings mode in the writer function, and this flag to be dealt with in the appropiate places, without interfering with all other features... it's this last issue what makes it non trivial.

@NoOverflow
Copy link
Author

NoOverflow commented Oct 8, 2020

Yes I'm taking a look at the code. I made a fork to try some things and see how that works out, I've got a bit of time on my hands so I might as well try something out. And even if I don't manage to get something working I'll be more familiar with the library so win-win anyway

@vpenades vpenades added the enhancement New feature or request label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants