-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
save a file of .glb with .bin buffer embed after json? #181
Comments
Not yet. Currently tinygltf save .bin to a separated file or serialize it to BASE64 string when saving a model as .glb.
Awesome! PR is always welcome. |
Have you worked on this? If not I might take a look. My first target use for tinygltf is model writer for some existing model handling code of mine. Couple of questions / opinion-requests? API-wise it looks like that we could either add an extra parameter to WriteGltfSceneToStream/File which would create the embedded buffer to .glb save or we could just change the behavior so that the BIN buffer is always added to binary saves. I guess data for the .bin buffer should come from what ever is the data in the first buffer of the Scene After some consideration, for maximum backwards compatibility, I would add an extra parameter flag, which would create the BIN block for binary writes from the first buffer, if it is not bound to an external URI. comments? Eero |
@epajarre Awesome! No one is not working on this yet, so your help is appreciated.
WriteGltfSceneToStream/File now has many default arguments. It would be better to introduce
Currently, bin data is saved as separate |
I forked the repo for testing purposes, and I will see how it works out. I think that at least first, I will not be concatenating the buffers, while doing the save, just save the first buffer as the binary blob. The concatenation also involves adjusting the related bufferviews so maybe it could be a separate operation? Also existing .glb files are already adjusted to use only one "internal buffer". So rewriting then out will need no fixup. |
I have a work in progress version in https://github.com/epajarre/tinygltf/tree/glb-bin-blob The branch contains two non related commits, which I did while working on my test case, I am not too fluent with the github flow, in any case it is possible to separate the directly bin-blob related code, |
Awesome!
I see. so no fixup required(no |
@epajarre I have glimpsed the code and it looks perfect, so could you please send it as Pull Req? |
I can send a pull request, but if I wait till tomorrow, I might be able to add/do some more testing OK? |
@epajarre Absolutely yes. adding/doing more tests is appreciated. |
Unfortunately it looks like that testing is more difficult than I had hoped. Going a round trip from from .glb file into memory and then back does not work as I expected. At least one problem is that tinygltf will unpack the texture images into memory, even in case they were in bufferViews originally. As my current .glb writer does not recreate the bin buffer on output, the textures will end into different implementation, either as external files or as data URI The gltf-validator does not really like data URI with the GLB container, it also notices that the original images in the BIN data block become unused. Neither of these are actual errors, I think but certainly problems. I will open the pull-request in any case, use it if you want. I will probably try some other cases with my original workflow which creates the GLtf model inside a program directly. |
For https://github.com/syoyo/tinygltf/blob/master/tiny_gltf.h#L648
Thanks. it has been merged > #226 https://github.com/syoyo/tinygltf/blob/master/tiny_gltf.h#L648 |
Does this project support?I could not find yet.
If not, I consider implement it.
The text was updated successfully, but these errors were encountered: