Capítulo 189 de 859

Chapter 189: MTLLoader

Core Idea

A loader for the MTL format.

The Material Template Library format (MTL) or .MTL File Format is a companion file format to OBJ that describes surface shading (material) properties of objects within one or more OBJ files.

Code Examples

const loader = new MTLLoader();
const materials = await loader.loadAsync( 'models/obj/male02/male02.mtl' );
const objLoader = new OBJLoader();
objLoader.setMaterials( materials );
  • What it demonstrates: Typical usage of MTLLoader.

Reference Tables

Constructor

Signature
new MTLLoader()

Methods

MethodDescription
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and passes the loaded MTL asset to the onLoad() callback.
.parse( text : string, path : string ) : MaterialCreatorParses the given MTL data and returns the resulting material creator.
.setMaterialOptions( value : MTLLoader~MaterialOptions ) : MTLLoaderSets the material options.

Key Takeaways

  1. MTLLoader extends: Loader
  2. Key methods: load, parse, setMaterialOptions.

Connects To