2
0

OBJMTLLoader.html 2.8 KB

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