123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>[name]</h1>
- <div class="desc">A loader for loading a <em>.obj</em> resource. <br />
- The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> 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.
- </div>
- <h2>Examples</h2>
- <code>
- // 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 );
- </code>
- [example:webgl_loader_obj2] - Simple example <br>
- [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse, load and run with instructions (sync and async)<br>
- [example:webgl_loader_obj2_run_director] - Advanced example using [page:LoaderSupport.LoaderWorkerDirector] for orchestration of multiple workers.
- <h2>Constructor</h2>
- <h3>[name]( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )</h3>
- <div>
- [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
- </div>
- <div>
- Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.
- </div>
- <h2>Methods</h2>
- <h3>[method:Object3D parse]( {[page:arraybuffer content]|[page:String content]] )</h3>
- <div>
- [[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
- </div>
- <div>
- Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D loaderRoorNode].
- </div>
- <h3>[method:Object3D parseAsync]( [page:arraybuffer content], [page:Function onLoad] )</h3>
- <div>
- [page:arraybuffer content] - OBJ data as Uint8Array<br>
- [page:Function onLoad] - Called after worker successfully completed loading<br>
- </div>
- <div>
- Parses OBJ content asynchronously from arraybuffer.
- </div>
- <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
- <div>
- [page:String url] - A string containing the path/URL of the <em>.obj</em> file.<br>
- [page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
- [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.<br>
- [page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
- [page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
- [page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
- </div>
- <div>
- Use this convenient method to load an OBJ file at the given URL. By default the fileLoader uses an arraybuffer.
- </div>
- <h3>[method:null run]( [page:LoaderSupport.PrepData params], [page:LoaderSupport.WorkerSupport workerSupportExternal] )</h3>
- <div>
- [page:LoaderSupport.PrepData params] - prepData All parameters and resources required for execution<br>
- [page:LoaderSupport.WorkerSupport workerSupportExternal] - Use pre-existing WorkerSupport
- </div>
- <div>
- Run the loader according the provided instructions.
- </div>
- <h3>[method:null setMaterialPerSmoothingGroup] ( [page:boolean materialPerSmoothingGroup] )</h3>
- <div>
- [page:boolean materialPerSmoothingGroup]
- </div>
- <div>
- Tells whether a material shall be created per smoothing group.
- </div>
- <h2>The following methods are inherited from [page:LoaderSupport.Commons]</h2>
- <h3>[method:ConsoleLogger getLogger] ()</h3>
- <div>
- Returns [page:LoaderSupport.ConsoleLogger].
- </div>
- <h3>[method:null setModelName] ( [page:String modelName] )</h3>
- <div>
- [page:String modelName]
- </div>
- <div>
- Set the name of the model.
- </div>
- <h3>[method:null setPath] ( [page:String path] )</h3>
- <div>
- [page:String path] - URL
- </div>
- <div>
- The URL of the base path.
- </div>
- <h3>[method:null setStreamMeshesTo] ( [page:Object3D streamMeshesTo] )</h3>
- <div>
- [page:Object3D streamMeshesTo] - Object already attached to scenegraph where new meshes will be attached to
- </div>
- <div>
- Set the node where the loaded objects will be attached directly.
- </div>
- <h3>[method:null setMaterials] ( Array of [page:Material materials] )</h3>
- <div>
- Array of [page:Material materials] - Array of [page:Material Materials]
- </div>
- <div>
- Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].
- </div>
- <h3>[method:null setUseIndices]( [page:Boolean useIndices] )</h3>
- <div>
- [page:Boolean useIndices]
- </div>
- <div>
- Instructs loaders to create indexed [page:BufferGeometry].
- </div>
- <h3>[method:null setDisregardNormals]( [page:Boolean disregardNormals] )</h3>
- <div>
- [page:Boolean disregardNormals]
- </div>
- <div>
- Tells whether normals should be completely disregarded and regenerated.
- </div>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
- </body>
- </html>
|