[name]

A loader for loading a .obj resource.
The OBJ file format is a simple data-format that represents 3D geometry in a human readable format as, the position of each vertex, the UV position of each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of vertices, and texture vertices.

Examples

// instantiate the loader let objLoader2Parallel = new OBJLoader2Parallel(); // define where to attach the data let local = new THREE.Object3D(); // function called on successful completion of parsing function callbackOnLoad( object3d, message ) { local.add( object3d ); } // load a resource from provided URL in parallel to Main objLoader2Parallel.load( 'models/obj/walt/WaltHead.obj', callbackOnLoad, null, null, null ); [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main)

Constructor

[name]( [param:LoadingManager manager] )

[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].

Creates a new [name]. Use it to load OBJ data from files or to parse OBJ data from arraybuffer or text.

Methods

[method:Object3D parse]( [param:arraybuffer content]|[param:String content] )

[[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String

Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D loaderRoorNode].

[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:Function onMeshAlter], [param:boolean useAsync] )

[page:String url] - A string containing the path/URL of the file to be loaded.
[page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.
[page:Function onProgress] - (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.
[page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.
[page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.
[page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.

Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.

Source

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