Export to 3MF Format

Hi. I’ve been using threejs to generate meshes dynamically (based on user inputs). These meshes will then be exported and 3d printed. The STL format is ok, however, it is not the greatest for 3d printing. 3MF seem to be a lot better.

I noticed there is no 3MF Exporter. Therefore, I went ahead and started to create my own.
My question is: would it be something that anyone else would benefit from? If yes, I’m considering forking the repository and trying to submit a PR with my exporter.

If this is something being handled by someone else, I might not waste time with that.

Just wanted to know what is your opinion about that.

Related:

Thank you for pointing me to the GitHub issue. From what I understood, exporting to 3MF is not something that seems to be in need by the community at the moment.

I will finish the code for my project and, if at any point in time a 3MF Exporter becomes useful for more people in the community, I will be happy to submit a PR with what I did.

Once again, thank you.

1 Like

I wouldn’t mind to include your 3MF Exporter in my viewers, for as long as you make it public and hopefully with MIT license.

There are already 2 unofficial exporters that I have, for BIM and 3DM formats, which might not be perfect but are functional.

2 Likes

Sure thing, I will be happy to do it (public with an MIT license). Once I have it finished, do I just put the repository link here, or you prefer me to contact you by email ?

1 Like

It would be surely great to have a 3MFExporter but in its own repository. We want to limit what we support in the main repository and a exporter for 3MF is just too specific.

1 Like

Just post a reply here with the link to your repository. The forum system will automatically send an e-mail to let me know.

Once I manage to integrate your 3MF Exporter into my viewers then I will reply here as well.

1 Like

Perfect, @Mugen87, I appreciate your response. I will do it in an external repository and share here in the forum so anyone who ends up needing it can use it. Just like @GitHubDragonFly suggested, it will be a public repository with an MIT license.

2 Likes

Hi! Have you succeeded in creating a 3MF Exporter? I’d love to have a chat!

There is now a partially implemented three.js based 3MF Exporter available in my repository.

Here is an example of how it could be used, just try to focus on parts that matter:

      async function export_3mf() {
        if (gltf_obj) {
          // Use whatever path might be applicable for the location
          const { ThreeMFExporter } = await import( "../static/jsm/exporters/3MFExporter.js" );

          let tmf_exporter = new ThreeMFExporter( manager );

          let options = { upAxis: 'Y_UP', maxTextureSize: tex_res, map_flip_required: tex_flip };

          tmf_exporter.parse( gltf_obj.clone(), async function( arrayBuffer ) {
            let blob = new Blob( [ arrayBuffer ], { type: 'application/octet-stream' } );

            zip.file( filename + '.3mf', blob );

            let str = '_3MF';
            if (tex_flip === true) str += '_Y';
            if (tex_res !== Infinity) str += ' (' + tex_res + ')';
            await process_zip( str );
          }, function( error ) { handle_export_error( error ); }, options );
        }
      }

If any of you can make it any better then don’t hesitate to grab a copy of it and do it (and hopefully re-post it here or somewhere else).

It might eventually get some more updates and bug fixes from me.

UV issues I was having appear to be resolved but the exporter currently only supports the main material.map texture exporting.

1 Like

I will try implementing it this week. What I mainly need right now is a 3MF export with material.color support. I’ll post an update on how it goes. Thank you very much!

You’re amazing! I took a look at your online converter toolkit. Would love to connect if you are on any other social platform!

Aren’t you just made of sugar. You can continue this sweet talking in this forum.

Resolving 3MF exporting is like a black hole information paradox - it has a price tag attached to it:

Just kidding of course but keep in mind that this 3MF Exporter I created was actually done with assistance from Microsoft Copilot, so don’t hesitate to use AI if you can.

The exporter currently does not support material arrays or PBR but single material color should be supported.

It has been included as an export option in multiple viewers on my webpage.

1 Like

My 3MF Exporter is currently pretty much at par with 3MF Loader.

It can additionally take a snapshot of the model within 512 x 512 area centered on the screen and add it as a thumbnail image to the exported .3mf file. This is optional feature but a functional code of implementing it can be seen in my viewers.

Since this exporter is included in most of my viewers then it can export multiple formats to 3MF.

It might have bugs and is missing the printTicket feature, which I still need to figure out and eventually include.

2 Likes

There is now also AMF Exporter available in my repository, which is currently pretty much at par with AMF Loader but the available features are somewhat limited to meshes + materials with their colors (so no textures or vertex colors).

It was created with assistance from Microsoft Copilot and by using the current logic from 3MF Exporter.

The best looking exports seem to be achieved when going from 3MF to AMF format - my 3MF viewer is currently supporting this export.

2 Likes