OBJMTLLoader.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <div class="desc">A loader for loading a <em>.obj</em> and its <em>.mtl</em> together.</div>
  12. <h2>Constructor</h2>
  13. <h3>[name]( [page:LoadingManager manager] )</h3>
  14. <div>
  15. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  16. </div>
  17. <div>
  18. Creates a new [name].
  19. </div>
  20. <h2>Properties</h2>
  21. <h2>Methods</h2>
  22. <h3>[method:null load]( [page:String objUrl], [page:String mtlUrl], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  23. <div>
  24. [page:String objUrl] — required. URL to the <em>.obj</em> resource<br />
  25. [page:String mtlUrl] — required. URL to the <em>.mtl</em> resource<br />
  26. [page:Function onLoad] — Will be called when both resources load complete. The argument will be the loaded [page:Object3D].<br />
  27. [page:Function onProgress] — Will be called while both load progress. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  28. [page:Function onError] — Will be called when load errors.<br />
  29. </div>
  30. <div>
  31. Begin loading from urls and call onLoad with the parsed response content.
  32. </div>
  33. <h3>[method:Object3D parse]( [page:String text], [page:Function mtllibCallback] )</h3>
  34. <div>
  35. [page:String text] — required. The textual <em>obj</em> structure to parse.<br/>
  36. [page:Function mtllibCallback] — optional. Callback to handle <em>mtllib</em> declaration.<br/>
  37. </div>
  38. <div>
  39. Parse an <em>obj</em> text structure and return an [page:Object3D].<br />
  40. Found objects are converted to [page:Mesh] with a [page:BufferGeometry] and materials are converted to [page:MeshLambertMaterial].
  41. </div>
  42. <h2>Example</h2>
  43. <code>
  44. // instantiate a loader
  45. var loader = new THREE.OBJMTLLoader();
  46. // load an obj / mtl resource pair
  47. loader.load(
  48. // OBJ resource URL
  49. 'obj/male02/male02.obj',
  50. // MTL resource URL
  51. 'obj/male02/male02_dds.mtl',
  52. // Function when both resources are loaded
  53. function ( object ) {
  54. scene.add( object );
  55. },
  56. // Function called when downloads progress
  57. function ( xhr ) {
  58. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  59. },
  60. // Function called when downloads error
  61. function ( xhr ) {
  62. console.log( 'An error happened' );
  63. }
  64. );
  65. </code>
  66. [example:webgl_loader_obj_mtl]
  67. <h2>Source</h2>
  68. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJMTLLoader.js examples/js/loaders/OBJMTLLoader.js]
  69. </body>
  70. </html>