A loader for loading a .obj resource.
The OBJ file format is a simple data-format
that represents 3D geometry in a human redeable 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.
// 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
[page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
[page:LoaderSupport.ConsoleLogger logger] - logger to be used
Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.
[[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].
[page:arraybuffer content] - OBJ data as Uint8Array
[page:Function onLoad] - Called after worker successfully completed loading
Parses OBJ content asynchronously from arraybuffer.
[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.
[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.
[page:Boolean enabled] True or false.
[page:Boolean debug] True or false.
Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
[page:String modelName]
Set the name of the model.
[page:String path] - URL
The URL of the base path.
[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.
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].
[page:Boolean useIndices]
Instructs loaders to create indexed [page:BufferGeometry].
[page:Boolean disregardNormals]
Tells whether normals should be completely disregarded and regenerated.
[page:boolean materialPerSmoothingGroup]
Tells whether a material shall be created per smoothing group.
[page:String type] - The type of event
[page:String text] - Textual description of the event
[page:Number numericalValue] - Numerical value describing the progress
Announce feedback which is give to the registered [page:LoaderSupport.Callbacks].
[page:String url] - URL to the file
[page:Object content] - The file content as arraybuffer or text
[page:Function onLoad] - Callback to be called after successful load
[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:String crossOrigin] - (optional) CORS value
[page:Function materialOptions] - (optional) Set material loading options for MTLLoader
Utility method for loading an mtl file according resource description. Provide url or content.