[name]

A loader for loading a .obj and its .mtl together.

Constructor

[name]( [page:LoadingManager manager] )

[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
Creates a new [name].

Properties

Methods

[method:null load]( [page:String objUrl], [page:String mtlUrl], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )

[page:String objUrl] — required. URL to the .obj resource
[page:String mtlUrl] — required. URL to the .mtl resource
[page:Function onLoad] — Will be called when both resources load complete. The argument will be the loaded [page:Object3D].
[page:Function onProgress] — Will be called while both load progress. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.
[page:Function onError] — Will be called when load errors.
Begin loading from urls and call onLoad with the parsed response content.

[method:Object3D parse]( [page:String text], [page:Function mtllibCallback] )

[page:String text] — required. The textual obj structure to parse.
[page:Function mtllibCallback] — optional. Callback to handle mtllib declaration.
Parse an obj text structure and return an [page:Object3D].
Found objects are converted to a [page:Mesh] and materials are converted to [page:MeshLambertMaterial].

Example

// instantiate a loader var loader = new THREE.OBJMTLLoader(); // load an obj / mtl resource pair loader.load( // OBJ resource URL 'obj/male02/male02.obj', // MTL resource URL 'obj/male02/male02_dds.mtl', // Function when both resources are loaded function ( object ) { scene.add( object ); }, // Function called when downloads progress function ( xhr ) { console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); }, // Function called when downloads error function ( xhr ) { console.log( 'An error happened' ); } ); [example:webgl_loader_obj_mtl]

Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJMTLLoader.js examples/js/loaders/OBJMTLLoader.js]