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

Export 3D models or scenes #214

Open
sunjay opened this issue Dec 15, 2018 · 6 comments
Open

Export 3D models or scenes #214

sunjay opened this issue Dec 15, 2018 · 6 comments

Comments

@sunjay
Copy link
Contributor

sunjay commented Dec 15, 2018

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.

@kvark
Copy link
Collaborator

kvark commented Dec 17, 2018

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 ;)

@sunjay
Copy link
Contributor Author

sunjay commented Dec 17, 2018

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. :)

@kvark
Copy link
Collaborator

kvark commented Dec 17, 2018

Well, neither do I :) Summining @alteous and @randomPoison in case they are interested to answer.

@randomPoison
Copy link
Contributor

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!

@alteous
Copy link
Member

alteous commented Dec 18, 2018

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.

@anderejd
Copy link

anderejd commented Jan 8, 2019

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.

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

5 participants