[name]
A loader for loading an .obj resource.
Examples
// instantiate the loader
var loader = new THREE.OBJLoader2();
// function called on successful load
var callbackOnLoad = function ( event ) {
scene.add( event.detail.loaderRootNode );
};
// load a resource from provided URL synchronously
loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null, false );
[example:webgl_loader_obj2] - Simple example
[example:webgl_loader_obj2_options] - Example for multiple use-cases (parse, load and run with instructions (sync and async)
[example:webgl_loader_obj2_run_director] - Advanced example using [page:LoaderSupport.LoaderWorkerDirector] for orchestration of multiple workers.
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.
Methods
[method:Object3D parse]( {[page:arraybuffer content]|[page: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:Object3D parseAsync]( [page:arraybuffer content], [page:Function onLoad] )
[page:arraybuffer content] - OBJ data as Uint8Array
[page:Function onLoad] - Called after worker successfully completed loading
Parses OBJ content asynchronously from arraybuffer.
[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )
[page:String url] - URL of the file to load
[page:Function onLoad] - Called after loading was successfully completed
[page:Function onProgress] - Called to report progress of loading. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes.
[page:Function onError] - Called after an error occurred during loading.
[page:Function onMeshAlter] - Called after a new mesh raw data becomes available to allow alteration
[page:boolean useAsync] - If true uses async loading with worker, if false loads data synchronously
Use this convenient method to load an OBJ file at the given URL. Per default the fileLoader uses an arraybuffer.
[method:null run]( [page:LoaderSupport.PrepData params], [page:LoaderSupport.WorkerSupport workerSupportExternal] )
[page:LoaderSupport.PrepData params] - prepData All parameters and resources required for execution
[page:LoaderSupport.WorkerSupport workerSupportExternal] - Use pre-existing WorkerSupport
Run the loader according the provided instructions.
[method:null setMaterialPerSmoothingGroup] ( [page:boolean materialPerSmoothingGroup] )
[page:boolean materialPerSmoothingGroup]
Tells whether a material shall be created per smoothing group.
The following methods are inherited from [page:LoaderSupport.Commons]
[method:ConsoleLogger getLogger] ()
Returns [page:LoaderSupport.ConsoleLogger].
[method:null setModelName] ( [page:String modelName] )
[page:String modelName]
Set the name of the model.
[method:null setPath] ( [page:String path] )
[page:String path] - URL
The URL of the base path.
[method:null setStreamMeshesTo] ( [page:Object3D streamMeshesTo] )
[page:Object3D streamMeshesTo] - Object already attached to scenegraph where new meshes will be attached to
Set the node where the loaded objects will be attached directly.
[method:null setMaterials] ( Array of [page:Material materials] )
Array of [page:Material materials] - Array of [page:Material Materials]
Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].
[method:null setUseIndices]( [page:Boolean useIndices] )
[page:Boolean useIndices]
Instructs loaders to create indexed [page:BufferGeometry].
[method:null setDisregardNormals]( [page:Boolean disregardNormals] )
[page:Boolean disregardNormals]
Tells whether normals should be completely disregarded and regenerated.
Source
[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]