OBJLoader.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">A loader for loading a <em>.obj</em> resource.<br />
  14. The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format
  15. that represents 3D geometry in a human readable format as the position of each vertex, the UV position of
  16. each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of
  17. vertices, and texture vertices.
  18. </p>
  19. <h2>Example</h2>
  20. <code>
  21. // instantiate a loader
  22. var loader = new THREE.OBJLoader();
  23. // load a resource
  24. loader.load(
  25. // resource URL
  26. 'models/monster.obj',
  27. // called when resource is loaded
  28. function ( object ) {
  29. scene.add( object );
  30. },
  31. // called when loading is in progresses
  32. function ( xhr ) {
  33. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  34. },
  35. // called when loading has errors
  36. function ( error ) {
  37. console.log( 'An error happened' );
  38. }
  39. );
  40. </code>
  41. [example:webgl_loader_obj]
  42. <h2>Constructor</h2>
  43. <h3>[name]( [param:LoadingManager manager] )</h3>
  44. <p>
  45. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  46. </p>
  47. <p>
  48. Creates a new [name].
  49. </p>
  50. <h2>Properties</h2>
  51. <p>See the base [page:Loader] class for common properties.</p>
  52. <h2>Methods</h2>
  53. <p>See the base [page:Loader] class for common methods.</p>
  54. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  55. <p>
  56. [page:String url] — A string containing the path/URL of the <em>.obj</em> file.<br />
  57. [page:Function onLoad] — (optional) A function to be called after the loading is successfully completed. The function receives the loaded [page:Object3D] as an argument.<br />
  58. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The function receives a XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br />
  59. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  60. </p>
  61. <p>
  62. Begin loading from url and call onLoad with the parsed response content.
  63. </p>
  64. <h3>[method:Object3D parse]( [param:String text] )</h3>
  65. <p>
  66. [page:String text] — The textual <em>obj</em> structure to parse.
  67. </p>
  68. <p>
  69. Returns an [page:Object3D]. It contains the parsed meshes as [page:Mesh] and lines as [page:LineSegments].<br />
  70. All geometry is created as [page:BufferGeometry]. Default materials are created as [page:MeshPhongMaterial].<br />
  71. If an <em>obj</em> object or group uses multiple materials while declaring faces, geometry groups and an array of materials are used.
  72. </p>
  73. <h3>[method:OBJLoader setMaterials]( [param:MTLLoader.MaterialCreator materials] )</h3>
  74. <p>
  75. [page:MTLLoaderMaterialCreator MTLLoader.MaterialCreator materials] - A MaterialCreator instance.
  76. </p>
  77. <p>
  78. Sets materials loaded by MTLLoader or any other supplier of a [page:MTLLoaderMaterialCreator MTLLoader.MaterialCreator].
  79. </p>
  80. <h2>Source</h2>
  81. <p>
  82. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js examples/js/loaders/OBJLoader.js]
  83. </p>
  84. </body>
  85. </html>