WWOBJLoader2.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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 an <em>.obj</em> resource within a web worker.</div>
  13. <h2>Sub-Classes</h2>
  14. [page:WWOBJLoader2.PrepDataArrayBuffer]<br>
  15. [page:WWOBJLoader2.PrepDataFile]<br>
  16. [page:WWOBJLoader2.WWOBJLoader2Director]
  17. <h2>Example</h2>
  18. <code>
  19. // instantiate the loader
  20. var loader = new THREE.OBJLoader2.WWOBJLoader2();
  21. // load an OBJ file by providing a name, the path and the file name
  22. var prepData = new THREE.OBJLoader2.WWOBJLoader2.PrepDataFile(
  23. 'female02',
  24. 'obj/female02/',
  25. 'female02.obj'
  26. );
  27. // set where to add the loaded data in the scene graph.
  28. prepData.setSceneGraphBaseNode( scene );
  29. // provide the preparation data to the loader and let it run.
  30. loader.prepareRun( prepData );
  31. loader.run();
  32. </code>
  33. [example:webgl_loader_obj2_ww] — Simple example that allows to load own models via file selection.<br>
  34. [example:webgl_loader_obj2_ww_parallels] — Advanced example using [page:WWOBJLoader2.WWOBJLoader2Director] for orchestration of multiple workers.
  35. <h2>Constructor</h2>
  36. <h3>[name]()</h3>
  37. <div>
  38. OBJ data will be loaded by dynamically created web worker.<br>
  39. First feed instructions with: [page:WWOBJLoader2.prepareRun prepareRun]<br>
  40. Then execute with: [page:WWOBJLoader2.run run]
  41. </div>
  42. <h2>Properties</h2>
  43. <h2>Methods</h2>
  44. <h3>[method:null prepareRun]( [page:Object params] )</h3>
  45. <div>
  46. [page:Object params] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
  47. </div>
  48. <div>
  49. Set all parameters for required for execution of [page:WWOBJLoader2.run run].
  50. </div>
  51. <h3>[method:null run]()</h3>
  52. <div>
  53. Run the loader according the preparation instruction provided in [page:WWOBJLoader2.prepareRun prepareRun].
  54. </div>
  55. <h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
  56. <div>
  57. [page:String crossOrigin] — CORS value
  58. </div>
  59. <div>
  60. Sets the CORS string to be used.
  61. </div>
  62. <h3>[method:null setDebug]( [page:Boolean enabled] )</h3>
  63. <div>
  64. [page:Boolean enabled] — True or false
  65. </div>
  66. <div>
  67. Enable or disable debug logging.
  68. </div>
  69. <h3>[method:null setRequestTerminate]( [page:Boolean requestTerminate] )</h3>
  70. <div>
  71. [page:Boolean requestTerminate] — True or false
  72. </div>
  73. <div>
  74. Call requestTerminate to terminate the web worker and free local resource after execution.
  75. </div>
  76. <h3>[method:null registerCallbackCompletedLoading]( [page:Function callbackCompletedLoading] )</h3>
  77. <div>
  78. [page:Function callbackCompletedLoading] — Callback function for described functionality
  79. </div>
  80. <div>
  81. Register callback function that is called once loading of the complete model is completed.
  82. </div>
  83. <h3>[method:null registerCallbackProgress]( [page:Function callbackProgress] )</h3>
  84. <div>
  85. [page:Function callbackProgress] — Callback function for described functionality
  86. </div>
  87. <div>
  88. Register callback function that is invoked by internal function "_announceProgress" to print feedback.
  89. </div>
  90. <h3>[method:null registerCallbackMaterialsLoaded]( [page:Function callbackMaterialsLoaded] )</h3>
  91. <div>
  92. [page:Function callbackMaterialsLoaded] — Callback function for described functionality
  93. </div>
  94. <div>
  95. Register callback function that is called once materials have been loaded. It allows to alter and return materials.
  96. </div>
  97. <h3>[method:null registerCallbackMeshLoaded]( [page:Function callbackMeshLoaded] )</h3>
  98. <div>
  99. [page:Function callbackMeshLoaded] — Callback function for described functionality
  100. </div>
  101. <div>
  102. Register callback function that is called every time a mesh was loaded. Return altered [page:Material] or null from callback.
  103. </div>
  104. <h3>[method:null registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )</h3>
  105. <div>
  106. [page:Function callbackErrorWhileLoading] — Callback function for described functionality
  107. </div>
  108. <div>
  109. Register callback function that is called to report an error that prevented loading.
  110. </div>
  111. <h2>Sub-Classes</h2>
  112. <br>
  113. <a name="PrepDataArrayBuffer"></a><h1>PrepDataArrayBuffer</h1>
  114. <h2>Constructor</h2>
  115. <h3>PrepDataArrayBuffer( [page:String modelName], [page:Uint8Array objAsArrayBuffer], [page:String pathTexture], [page:String mtlAsString] )</h3>
  116. <div>
  117. [page:String modelName] — Overall name of the model<br>
  118. [page:Uint8Array objAsArrayBuffer] — OBJ file content as ArrayBuffer<br>
  119. [page:String pathTexture] — Path to texture files<br>
  120. [page:String mtlAsString] — MTL file content as string
  121. [page:Object3D sceneGraphBaseNode] [page:Object3D] where meshes will be attached
  122. [page:Boolean streamMeshes] Singles meshes are directly integrated into scene when loaded or later
  123. [page:Boolean requestTerminate] Request termination of web worker and free local resources after execution
  124. </div>
  125. <div>
  126. Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ from given ArrayBuffer and MTL from given String.
  127. </div>
  128. <br>
  129. <br>
  130. <a name="PrepDataFile"></a><h1>PrepDataFile</h1>
  131. <h2>Constructor</h2>
  132. <h3>PrepDataFile( [page:String modelName], [page:String pathObj], [page:String fileObj], [page:String pathTexture], [page:String fileMtl] )</h3>
  133. <div>
  134. [page:String modelName] — Overall name of the model<br>
  135. [page:String pathObj] — Path to OBJ file<br>
  136. [page:String fileObj] — OBJ file name<br>
  137. [page:String pathTexture] — Path to texture files<br>
  138. [page:String fileMtl] — MTL file name
  139. [page:Object3D sceneGraphBaseNode] [page:Object3D] where meshes will be attached
  140. [page:Boolean streamMeshes] Singles meshes are directly integrated into scene when loaded or later
  141. [page:Boolean requestTerminate] Request termination of web worker and free local resources after execution
  142. </div>
  143. <div>
  144. Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ and MTL from files.
  145. </div>
  146. <br>
  147. <br>
  148. <a name="WWOBJLoader2Director"></a><h1>WWOBJLoader2Director</h1>
  149. <h2>Constructor</h2>
  150. <h3>WWOBJLoader2Director()</h3>
  151. <div>
  152. Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).<br>
  153. Workflow:<br>
  154. prepareWorkers<br>
  155. enqueueForRun<br>
  156. processQueue<br>
  157. deregister
  158. </div>
  159. <h3>[method:null prepareWorkers]( Array of [page:Function callbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )</h3>
  160. <div>
  161. Array of [page:Function callbacks] — Register callbacks for all web workers: progress, completedLoading, errorWhileLoading, materialsLoaded, meshLoaded<br>
  162. [page:Number maxQueueSize] — Set the maximum size of the instruction queue (1-1024)<br>
  163. [page:Number maxWebWorkers] — Set the maximum amount of workers (1-16)
  164. </div>
  165. <div>
  166. Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
  167. </div>
  168. <h3>[method:null enqueueForRun]( [page:Object runParams] )</h3>
  169. <div>
  170. [page:Object runParams] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
  171. </div>
  172. <div>
  173. Store run instructions in internal instructionQueue.
  174. </div>
  175. <h3>[method:null processQueue]()</h3>
  176. <div>
  177. Process the instructionQueue until it is depleted.
  178. </div>
  179. <h3>[method:null deregister]()</h3>
  180. <div>
  181. Terminate all workers
  182. </div>
  183. <h3>[method:null getMaxQueueSize]()</h3>
  184. <div>
  185. Returns the maximum length of the instruction queue.
  186. </div>
  187. <h3>[method:null getMaxWebWorkers]()</h3>
  188. <div>
  189. Returns the maximum number of workers.
  190. </div>
  191. <h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
  192. <div>
  193. [page:String crossOrigin] — CORS value
  194. </div>
  195. <div>
  196. Sets the CORS string to be used.
  197. </div>
  198. <h2>Source</h2>
  199. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
  200. </body>
  201. </html>