[name]

A loader for loading an .obj resource.

Example

// instantiate the loader var loader = new THREE.OBJLoader2(); // function called on successful load var intergrateIntoScene = function ( object ) { scene.add( object ); }; // load a resource from provided URL loader.load( 'obj/female02/female02.obj', intergrateIntoScene ); [example:webgl_loader_obj2]

Constructor

[name]( [page:LoadingManager manager] )

[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.

Properties

Methods

[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Boolean useArrayBuffer] )

[page:String url] — URL of the file to load
[page:Function onLoad] — Called after loading was successfully completed. The argument will be the loaded [page:Object3D].
[page:Function onProgress] — Called to report progress of loading. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.
[page:Function onError] Called after an error occurred during loading.
[page:boolean useArrayBuffer] — Set this to false to force string based parsing
Use this convenient method to load an OBJ file at the given URL. Per default the fileLoader uses an arraybuffer

[method:Object3D parse]( [page:ArrayBuffer arrayBuffer] )

[page:ArrayBuffer arrayBuffer] — OBJ data as Uint8Array
Default parse function: Parses OBJ file content stored in arrayBuffer and returns the [page:Object3D sceneGraphBaseNode].

[method:Object3D parseText]( [page:String test] )

[page:String text] — OBJ data as string
Legacy parse function: Parses OBJ file content stored in string and returns the [page:Object3D sceneGraphBaseNode].

[method:null setMaterials] ( Array of [page:Material materials] )

Array of [page:Material materials] — Array of [page:Material Materials] from MTLLoader
Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].

[method:null setPath] ( [page:String path] )

[page:String path] — The basePath
Base path to use.

[method:null setSceneGraphBaseNode] ( [page:Object3D sceneGraphBaseNode] )

[page:Object3D sceneGraphBaseNode] — Scenegraph object where meshes will be attached
Set the node where the loaded objects will be attached.

[method:null setDebug]( [page:Boolean parserDebug], [page:Boolean meshCreatorDebug] )

[page:Boolean parserDebug] — Internal Parser will produce debug output
[page:Boolean meshCreatorDebug] — Internal MeshCreator will produce debug output
Allows to set debug mode for the parser and the meshCreator.

Source

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