question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Editor: Add support for importing OBJ/MTL assets with textures.

See original GitHub issue
Description 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, …)

image

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Nov 21, 2022

Just checking because I seemed to have the same experience as the original poster.

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.

1reaction
kylemcdonaldcommented, Nov 28, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found