Editor: Add support for importing OBJ/MTL assets with textures.
See original GitHub issueDescription of the problem
The obj format model is a very commonly used format. When importing obj and mtl, you need zip. . After importing, the geometry and material can be loaded normally, but the texture map has an error. After checking, I found that it is related to the following code. It is not useful to process the material-related pictures in the zip. . This is not necessarily a bug, but it affects the experience more.
//editor/js/Loader.js( function handleZip() )
// Poly
if ( zip.files[ 'model.obj' ] && zip.files[ 'materials.mtl' ] ) {
var materials = new MTLLoader().parse( zip.file( 'materials.mtl' ).asText() );
var object = new OBJLoader().setMaterials( materials ).parse( zip.file( 'model.obj' ).asText() );
editor.execute( new AddObjectCommand( editor, object ) );
}
Three.js version
- Dev
- r118
- …
Browser
- All of them
OS
- Windows
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Importing OBJ with MTL and Image not working properly
2 Answers 2 · 1. Check the obj file · 2. Apply the material · 3. Enable textures in the viewport.
Read more >How To Import And Export Free 3D OBJ File With Texture ...
How To Import And Export Free 3D OBJ File With Textures Using Blender 2.8 with Buildbox 3- ObjectLike and Subscribe!
Read more >Importing OBJ with MTL Texture doesn't work - Unity Forum
I'm trying to import an .obj file with the according .mtl texture ... .mtl into the Textures Folder and the .obj into the...
Read more >Importing .obj files with textures in SceneKit - Stack Overflow
OBJ and MTL files are text files so you can use a text editor to open them. ... Add your textures images files...
Read more >how to use MTL files? - NewTek Forums
you can simply open the MTL file in a code or text editor and if the object is not too complex, check if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Using a zip archive like described above makes it possible to load an OBJ with an accompanying MTL file. However, textures are not supported since
MTLLoader
is going to take the texture name and append it to the editor’s URL path (e.g.https://threejs.org/editor/
). This is not yet fixed.When I tried importing the .obj and .mtl files into the editor either separately or at the same time, the .mtl was not applied. When I created a zip file and imported the zip file, the .mtl was applied correctly.