kenny-designs / voxel-edit

A web based voxel art program.
https://kenny-designs.github.io/voxel-edit/
5 stars 3 forks source link

Export Obj #39

Closed kenny-designs closed 3 years ago

kenny-designs commented 3 years ago

Allow users to export their models to .obj files in addition to other 3D file formats so that they can be exported to other software such as Blender, Unity, Unreal, etc.

kenny-designs commented 3 years ago

Starting to work on this now. It appears that threejs already has some code that I can use to export models to various 3D file formats here.

Hopefully they won't be too difficult to implement.

kenny-designs commented 3 years ago

Quick note, there are many exporters available. Once the obj one is working, might as well implement the rest for completeness.

kenny-designs commented 3 years ago

Exporting to obj now works. However, I forgot one little detail about obj files. You need an mtl file to go with it or else you only have the geometry and no color.

Also, the actual geometry that gets exported is very dense since we color each voxel via vertices. This is something that might be worth improving upon at a later time.

Lastly, users should be able to name their exported files. I shall work on that now and even include the other exporters since they all work the same way as the obj export does.

kenny-designs commented 3 years ago

I added the exports for dae, stl, and ply. stl and ply both export the geometry but not the colors. dae seems to have an issue exporting altogether.

The example code for how to use these exporters seem to perform some extra actions to grab color data and whatnot. Follow these examples and see if you can get the color working. In the very least, get the obj exporter to work.

kenny-designs commented 3 years ago

I have some bad news. It appears that I'm going to have to write the code to produce an mtl file to go with the obj exporter code from scratch. There doesn't appear to be any sort of plug and play solutions out there.

kenny-designs commented 3 years ago

Since exporting does work, I will go ahead and merge export-obj into dev and main. A separate issue will be created to address the lack of color.