2
0

OBJLoader2.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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. <p 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 readable 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. </p>
  18. <h2>代码示例</h2>
  19. <code>
  20. // instantiate the loader
  21. let loader = new OBJLoader2();
  22. // function called on successful load
  23. function callbackOnLoad ( object3d ) {
  24. scene.add( object3d );
  25. }
  26. // load a resource from provided URL synchronously
  27. loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null );
  28. </code>
  29. <h2>例子</h2>
  30. <p>
  31. [example:webgl_loader_obj2] - Simple example<br />
  32. [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel]))
  33. </p>
  34. <h2>Constructor</h2>
  35. <h3>[name]( [param:LoadingManager manager] )</h3>
  36. <p>
  37. [page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br>
  38. </p>
  39. <p>
  40. Creates a new [name]. Use it to load OBJ data from files or to parse OBJ data from arraybuffer or text.
  41. </p>
  42. <h2>Properties</h2>
  43. <p>See the base [page:Loader] class for common properties.</p>
  44. <h2>Methods</h2>
  45. <p>See the base [page:Loader] class for common methods.</p>
  46. <h3>[method:Object3D parse]( [param:arraybuffer content]|[param:String content] )</h3>
  47. <p>
  48. [[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
  49. </p>
  50. <p>
  51. Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D baseObject3d].
  52. </p>
  53. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:Function onMeshAlter] )</h3>
  54. <p>
  55. [page:String url] - A string containing the path/URL of the file to be loaded.<br>
  56. [page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
  57. [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>
  58. [page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
  59. [page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
  60. </p>
  61. <p>
  62. Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.
  63. </p>
  64. <h3>[method:OBJLoader2 setLogging]( [param:Boolean enabled], [param:Boolean debug] )</h3>
  65. <p>
  66. [page:Boolean enabled] True or false.<br>
  67. [page:Boolean debug] True or false.
  68. </p>
  69. <p>
  70. Enable or disable logging in general (except warn and error), plus enable or disable debug logging.
  71. </p>
  72. <h3>[method:OBJLoader2 addMaterialPerSmoothingGroup] ( [param:boolean materialPerSmoothingGroup] )</h3>
  73. <p>
  74. [page:boolean materialPerSmoothingGroup]
  75. </p>
  76. <p>
  77. Tells whether a material shall be created per smoothing group.
  78. </p>
  79. <h3>[method:OBJLoader2 setUseOAsMesh] ( [param:boolean useOAsMesh] )</h3>
  80. <p>
  81. [page:boolean useOAsMesh]
  82. </p>
  83. <p>
  84. Usually 'o' is meta-information and does not result in creation of new meshes, but mesh creation on occurrence of "o" can be enforced.
  85. </p>
  86. <h3>[method:OBJLoader2 setUseIndices]( [param:Boolean useIndices] )</h3>
  87. <p>
  88. [page:Boolean useIndices]
  89. </p>
  90. <p>
  91. Instructs loaders to create indexed [page:BufferGeometry].
  92. </p>
  93. <h3>[method:OBJLoader2 setDisregardNormals]( [param:Boolean disregardNormals] )</h3>
  94. <p>
  95. [page:Boolean disregardNormals]
  96. </p>
  97. <p>
  98. Tells whether normals should be completely disregarded and regenerated.
  99. </p>
  100. <h3>[method:OBJLoader2 setModelName] ( [param:String modelName] )</h3>
  101. <p>
  102. [page:String modelName]
  103. </p>
  104. <p>
  105. Set the name of the model.
  106. </p>
  107. <h3>[method:OBJLoader2 setBaseObject3d] ( [param:Object3d baseObject3d] )</h3>
  108. <p>
  109. [page:Object3D baseObject3d - Object already attached to scenegraph where new meshes will be attached to
  110. </p>
  111. <p>
  112. Set the node where the loaded objects will be attached directly.
  113. </p>
  114. <h3>[method:OBJLoader2 setMaterials] ( [param:Object materials] )</h3>
  115. <p>
  116. [page:Object materials] - materials Object with named [page:Material Materials]
  117. </p>
  118. <p>
  119. Add materials as associated array.
  120. </p>
  121. <h3>[method:OBJLoader2 setCallbackOnLoad] ( [param:Function onLoad] )</h3>
  122. <p>
  123. [page:Function onLoad]
  124. </p>
  125. <p>
  126. Register a function that is called when parsing was completed.
  127. </p>
  128. <h3>[method:OBJLoader2 setCallbackOnAssetAvailable] ( [param:Function onAssetAvailable] )</h3>
  129. <p>
  130. [page:Function onAssetAvailable]
  131. </p>
  132. <p>
  133. Register a function that is called once an asset (mesh/material) becomes available.
  134. </p>
  135. <h3>[method:OBJLoader2 setCallbackOnProgress] ( [param:Function onProgress] )</h3>
  136. <p>
  137. [page:Function onProgress]
  138. </p>
  139. <p>
  140. Register a function that is used to report overall processing progress.
  141. </p>
  142. <h3>[method:OBJLoader2 setCallbackOnError] ( [param:Function onError] )</h3>
  143. <p>
  144. [page:Function onError]
  145. </p>
  146. <p>
  147. Register an error handler function that is called if errors occur. It can decide to just log or to throw an exception.
  148. </p>
  149. <h3>[method:OBJLoader2 setCallbackOnMeshAlter] ( [param:Function onMeshAlter] )</h3>
  150. <p>
  151. [page:Function onMeshAlter]
  152. </p>
  153. <p>
  154. Register a function that is called once a single mesh is available and it could be altered by the supplied function.
  155. </p>
  156. <h2>Source</h2>
  157. <p>
  158. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader2.js examples/jsm/loaders/OBJLoader2.js]
  159. </p>
  160. </body>
  161. </html>