Skip to content

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

@hopepdm

Description

@hopepdm
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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions