Textures and 3MFLoader - Bug?

Hi All,

I recently needed to use Three.js for a project involving .3mf files. I seemed to be having a hard time getting .3mf files that had textures in them to load, so I started digging through the source code and found what looks like a bug:

In the file 3MFLoader.js, there’s a point where it looks through the .3mf file (which is actually a zip file) to load resources from various locations. When it tries to load texture files, at line 143, it tries to match them using a regular expression that only checks for folders named Textures + one character. However, all the .3mf files that I have store their textures in a folder called Textures2D, so a pattern that looks for Textures + one character doesn’t end up finding the files. I changed the regular expression to look for any number of characters after the the word Texture and now everything works fine.

Anyway, I don’t know if I’m getting out-of-spec .3mf files or if this is a bug in 3MFLoader, but I thought I’d document it here in case it helps anyone else.



You are referring to the following line, right?

The spec says about name spaces:

  • 3D Texture part names SHOULD contain three segments, using “/3D/Textures/” as the first two segments, for example “/3D/Textures/coloring.png”. 3D Texture parts MUST be associated with the 3D Model part via relationship.

Can you please show how your updated regex looks like?

Hi, thanks for the information about the file specification - that’s interesting. I’m trying to find out what software generated the .3mf files that I have, because they do not follow that specification.

I just changed “Textures?” to “Textures.*” and that worked for my situation.


PS: I followed the link you provided to the specification - and I see what’s going on now, the requirements say people SHOULD not MUST follow that naming convention.

TBH, I’ve never encountered a 3MF file that did not follow the mentioned specification. Even it is declared as a pure recommendation (SHOULD), I would prefer to fix this issue at the exporter instead of updating 3MFLoader.

Is it possible for you to do this? Do you have any access to the exporter or any contacts to the respective dev team? It would be interesting to know why they did not follow the recommendation in the first place…

Okay, so I talked with the person who originated the file(s). They use SolidWorks, then add textures and color with a tool called NTopology. I don’t know anything about either of those tools.

I agree with you - since .3mf is just a zip file, the solution is to normalize the file before loading it into Three.js with ThreeMFLoader. I’ll take that approach and just unzip the file when it gets uploaded to the server, rename the folder “TexturesBlahBlah” to “Textures” and that should be it.

Thanks for helping me understand this, appreciate the help.



1 Like