-
Notifications
You must be signed in to change notification settings - Fork 46
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
Export 3D models or scenes #214
Comments
So you want to basically write a scene editor in with three? That sounds like an interesting project! Writing the GLTF export would be quite a heavy undertaking, so it requires a dedicated volunteer ;) |
Since we already import GLTF, is there a way to "reverse" that code and get GLTF out. I don't know all the details of how this works, so I thought I would ask. :) |
Well, neither do I :) Summining @alteous and @randomPoison in case they are interested to answer. |
As far as I know it should be possible, though it may require some functionality be added to three-rs. three-rs already has functionality for walking the contents of the scene, which means you can construct the graph of nodes for the glTF document. I imagine the harder part would be to get the mesh and texture data from three-rs so that you can export it again, but it should be possible to add that functionality (assuming it hasn't already been added since I last worked on this project). That said, I think @kvark is right to note that the glTF exporter is the harder part here. A cursory glance at crates.io doesn't turn up any crates for writing glTF files (only reading them). If someone could put together a crate for constructing glTF data in memory and writing it out, that would be a big first step towards being able to generate a glTF file from a three-rs scene! |
This is a sensible suggestion and it should not be difficult to implement; however, it would require a fair amount of work. You could leverage the gltf-json crate to build the metadata. Writing the buffer and image data would be a custom implementation. The reason why the gltf crate doesn't support export is because coming up with a generic export API is a non-trivial task. It is however a known issue, see gltf-rs/gltf#187. |
Here's an initial attempt with a minimal export example (triangle): gltf-rs/gltf#193 I haven't improved on that code since, so we could re-open the PR or pick the good parts and create something different. |
Thanks for such an excellent library!
Since three provides a way to load gltf files (among other formats), could it also be possible to save/export objects/scenes to those formats as well? I want to use three to make a program that can load models, make specific types of edits, and then save the entire scene as a gltf file.
The text was updated successfully, but these errors were encountered: