OBJLoader2.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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> resource. <br />
  13. The <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ file format</a> is a simple data-format
  14. that represents 3D geometry in a human redeable format as, the position of each vertex, the UV position of
  15. each texture coordinate vertex, vertex normals, and the faces that make each polygon defined as a list of
  16. vertices, and texture vertices.
  17. </div>
  18. <h2>Examples</h2>
  19. <code>
  20. // instantiate the loader
  21. var loader = new THREE.OBJLoader2();
  22. // function called on successful load
  23. var callbackOnLoad = function ( event ) {
  24. scene.add( event.detail.loaderRootNode );
  25. };
  26. // load a resource from provided URL synchronously
  27. loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null, false );
  28. </code>
  29. [example:webgl_loader_obj2] - Simple example <br>
  30. [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse, load and run with instructions (sync and async)<br>
  31. [example:webgl_loader_obj2_run_director] - Advanced example using [page:LoaderSupport.LoaderWorkerDirector] for orchestration of multiple workers.
  32. <h2>Constructor</h2>
  33. <h3>[name]( [page:LoadingManager manager], [page:LoaderSupport.ConsoleLogger logger] )</h3>
  34. <div>
  35. [page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  36. [page:LoaderSupport.ConsoleLogger logger] - logger to be used
  37. </div>
  38. <div>
  39. Use [name] to load OBJ data from files or to parse OBJ data from arraybuffer or text.
  40. </div>
  41. <h2>Methods</h2>
  42. <h3>[method:Object3D parse]( {[page:arraybuffer content]|[page:String content]] )</h3>
  43. <div>
  44. [[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
  45. </div>
  46. <div>
  47. Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D loaderRoorNode].
  48. </div>
  49. <h3>[method:Object3D parseAsync]( [page:arraybuffer content], [page:Function onLoad] )</h3>
  50. <div>
  51. [page:arraybuffer content] - OBJ data as Uint8Array<br>
  52. [page:Function onLoad] - Called after worker successfully completed loading<br>
  53. </div>
  54. <div>
  55. Parses OBJ content asynchronously from arraybuffer.
  56. </div>
  57. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError], [page:Function onMeshAlter], [page:boolean useAsync] )</h3>
  58. <div>
  59. [page:String url] - A string containing the path/URL of the <em>.obj</em> file.<br>
  60. [page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
  61. [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>
  62. [page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
  63. [page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
  64. [page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
  65. </div>
  66. <div>
  67. Use this convenient method to load an OBJ file at the given URL. By default the fileLoader uses an arraybuffer.
  68. </div>
  69. <h3>[method:null run]( [page:LoaderSupport.PrepData params], [page:LoaderSupport.WorkerSupport workerSupportExternal] )</h3>
  70. <div>
  71. [page:LoaderSupport.PrepData params] - prepData All parameters and resources required for execution<br>
  72. [page:LoaderSupport.WorkerSupport workerSupportExternal] - Use pre-existing WorkerSupport
  73. </div>
  74. <div>
  75. Run the loader according the provided instructions.
  76. </div>
  77. <h3>[method:null setMaterialPerSmoothingGroup] ( [page:boolean materialPerSmoothingGroup] )</h3>
  78. <div>
  79. [page:boolean materialPerSmoothingGroup]
  80. </div>
  81. <div>
  82. Tells whether a material shall be created per smoothing group.
  83. </div>
  84. <h2>The following methods are inherited from [page:LoaderSupport.Commons]</h2>
  85. <h3>[method:ConsoleLogger getLogger] ()</h3>
  86. <div>
  87. Returns [page:LoaderSupport.ConsoleLogger].
  88. </div>
  89. <h3>[method:null setModelName] ( [page:String modelName] )</h3>
  90. <div>
  91. [page:String modelName]
  92. </div>
  93. <div>
  94. Set the name of the model.
  95. </div>
  96. <h3>[method:null setPath] ( [page:String path] )</h3>
  97. <div>
  98. [page:String path] - URL
  99. </div>
  100. <div>
  101. The URL of the base path.
  102. </div>
  103. <h3>[method:null setStreamMeshesTo] ( [page:Object3D streamMeshesTo] )</h3>
  104. <div>
  105. [page:Object3D streamMeshesTo] - Object already attached to scenegraph where new meshes will be attached to
  106. </div>
  107. <div>
  108. Set the node where the loaded objects will be attached directly.
  109. </div>
  110. <h3>[method:null setMaterials] ( Array of [page:Material materials] )</h3>
  111. <div>
  112. Array of [page:Material materials] - Array of [page:Material Materials]
  113. </div>
  114. <div>
  115. Set materials loaded by MTLLoader or any other supplier of an Array of [page:Material Materials].
  116. </div>
  117. <h3>[method:null setUseIndices]( [page:Boolean useIndices] )</h3>
  118. <div>
  119. [page:Boolean useIndices]
  120. </div>
  121. <div>
  122. Instructs loaders to create indexed [page:BufferGeometry].
  123. </div>
  124. <h3>[method:null setDisregardNormals]( [page:Boolean disregardNormals] )</h3>
  125. <div>
  126. [page:Boolean disregardNormals]
  127. </div>
  128. <div>
  129. Tells whether normals should be completely disregarded and regenerated.
  130. </div>
  131. <h2>Source</h2>
  132. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
  133. </body>
  134. </html>