I am trying to create a scene with OBJ-MTL models in it. Now, I want to export the built scene with texture. For this, I am going with OBJExporter.js. The issue with OBJExporter.js is that it generates only the OBJ file having only the grayscale. To reload the whole scene with texture, I have to apply texture by iterating over the mesh. I suspect that there might be a better way of saving and loading the scene. Is it possible with OBJExporter to generate OBJ + MTL + Textures? I have tried to use other exporters like GLTF but the quality of the scene itself degrades significantly because of OBJ models in it. So, I want to stick to OBJExporter. If there is no such feature available then is there any smarter way of reloading the scene with texture rather than iterating over the mesh and apply texture on every model of the scene?
The issue with OBJExporter.js is that it generates only the OBJ file having only the grayscale.
Yes, THREE.OBJExporter
can only export OBJ
but no MTL files.
What do you mean by that? GLTFExporter
should be an ideal alternative to OBJExporter
.
What I mean is, when I am using GLTFExporter texture is being applied to it but there are so many areas in the scene where things aren’t aligned with the actual object before saving – for example, if there are trees in the model then some at the edges of the tree I see black color in place of green and then there are different colors altogether being applied in the scene. Sorry, I don’t have the screenshot of it but this is what we have.
And what you are saying is that for OBJ files, the best exporter in the market would be GLTFExporter?
Please feel free to ask me if something is not clear here.
This is an old conversation but just for the sake of those who might ever be looking for this kind of functionality here is a modification that allows exporting MTL alongside OBJ:
Those who would want to use it would also need to use the modified MTL Loader from the same repository (I would suggest using the OBJ Loader from that repository as well).
This might not be perfect but can be possibly improved upon.
My viewers would have this exporter included so just check their code for the imports and the function titled async function export_obj()
which shows how to handle the exported OBJ, MTL and textures (everything is zipped up with JSZip in the end). MMD and GLTF viewers are also y-flipping the textures in that particular function.