WWOBJLoader2.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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.PrepDataCallbacks]<br>
  17. [page:WWOBJLoader2.LoadedMeshUserOverride]<br>
  18. [page:WWOBJLoader2.WWOBJLoader2Director]
  19. <h2>Example</h2>
  20. <code>
  21. // instantiate the loader
  22. var loader = new THREE.OBJLoader2.WWOBJLoader2();
  23. // load an OBJ file by providing a name, the path and the file name
  24. var prepData = new THREE.OBJLoader2.WWOBJLoader2.PrepDataFile(
  25. 'female02',
  26. 'obj/female02/',
  27. 'female02.obj'
  28. );
  29. // set where to add the loaded data in the scene graph.
  30. prepData.setSceneGraphBaseNode( scene );
  31. // provide the preparation data to the loader and let it run.
  32. loader.prepareRun( prepData );
  33. loader.run();
  34. </code>
  35. [example:webgl_loader_obj2_ww] — Simple example that allows to load own models via file selection.<br>
  36. [example:webgl_loader_obj2_ww_parallels] — Advanced example using [page:WWOBJLoader2.WWOBJLoader2Director] for orchestration of multiple workers.
  37. <h2>Constructor</h2>
  38. <h3>[name]()</h3>
  39. <div>
  40. OBJ data will be loaded by dynamically created web worker.<br>
  41. First feed instructions with: [page:WWOBJLoader2.prepareRun prepareRun]<br>
  42. Then execute with: [page:WWOBJLoader2.run run]
  43. </div>
  44. <h2>Properties</h2>
  45. <h2>Methods</h2>
  46. <h3>[method:null prepareRun]( [page:Object params] )</h3>
  47. <div>
  48. [page:Object params] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
  49. </div>
  50. <div>
  51. Set all parameters for required for execution of [page:WWOBJLoader2.run run].
  52. </div>
  53. <h3>[method:null run]()</h3>
  54. <div>
  55. Run the loader according the preparation instruction provided in [page:WWOBJLoader2.prepareRun prepareRun].
  56. </div>
  57. <h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
  58. <div>
  59. [page:String crossOrigin] — CORS value
  60. </div>
  61. <div>
  62. Sets the CORS string to be used.
  63. </div>
  64. <h3>[method:null setDebug]( [page:Boolean enabled] )</h3>
  65. <div>
  66. [page:Boolean enabled] — True or false
  67. </div>
  68. <div>
  69. Enable or disable debug logging.
  70. </div>
  71. <h3>[method:null setRequestTerminate]( [page:Boolean requestTerminate] )</h3>
  72. <div>
  73. [page:Boolean requestTerminate] — True or false
  74. </div>
  75. <div>
  76. Call requestTerminate to terminate the web worker and free local resource after execution.
  77. </div>
  78. <h3>[method:null registerCallbackCompletedLoading]( [page:Function callbackCompletedLoading] )</h3>
  79. <div>
  80. [page:Function callbackCompletedLoading] — Callback function for described functionality
  81. </div>
  82. <div>
  83. Register callback function that is called once loading of the complete model is completed.
  84. </div>
  85. <h3>[method:null registerCallbackProgress]( [page:Function callbackProgress] )</h3>
  86. <div>
  87. [page:Function callbackProgress] — Callback function for described functionality
  88. </div>
  89. <div>
  90. Register callback function that is invoked by internal function "_announceProgress" to print feedback.
  91. </div>
  92. <h3>[method:null registerCallbackMaterialsLoaded]( [page:Function callbackMaterialsLoaded] )</h3>
  93. <div>
  94. [page:Function callbackMaterialsLoaded] — Callback function for described functionality
  95. </div>
  96. <div>
  97. Register callback function that is called once materials have been loaded. It allows to alter and return materials.
  98. </div>
  99. <h3>[method:null registerCallbackMeshLoaded]( [page:Function callbackMeshLoaded] )</h3>
  100. <div>
  101. [page:Function callbackMeshLoaded] — Callback function for described functionality
  102. </div>
  103. <div>
  104. Register callback function that is called every time a mesh was loaded. Use [page:WWOBJLoader2.LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).
  105. </div>
  106. <h3>[method:null registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )</h3>
  107. <div>
  108. [page:Function callbackErrorWhileLoading] — Callback function for described functionality
  109. </div>
  110. <div>
  111. Register callback function that is called to report an error that prevented loading.
  112. </div>
  113. <h3>[method:null clearAllCallbacks]()</h3>
  114. <div>
  115. Clears all registered callbacks.
  116. </div>
  117. <h2>Sub-Classes</h2>
  118. <br>
  119. <a name="PrepDataArrayBuffer"></a><h1>PrepDataArrayBuffer</h1>
  120. <h2>Constructor</h2>
  121. <h3>PrepDataArrayBuffer( [page:String modelName], [page:Uint8Array objAsArrayBuffer], [page:String pathTexture], [page:String mtlAsString] )</h3>
  122. <div>
  123. [page:String modelName] — Overall name of the model<br>
  124. [page:Uint8Array objAsArrayBuffer] — OBJ file content as ArrayBuffer<br>
  125. [page:String pathTexture] — Path to texture files<br>
  126. [page:String mtlAsString] — MTL file content as string
  127. </div>
  128. <div>
  129. Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ from given ArrayBuffer and MTL from given String.
  130. </div>
  131. <h2>Methods</h2>
  132. <h3>[method:PrepDataCallbacks getCallbacks]()</h3>
  133. <div>
  134. Returns all callbacks as [page:WWOBJLoader2.PrepDataCallbacks].
  135. </div>
  136. <h3>[method:null setRequestTerminate]( [page:Boolean requestTerminate] )</h3>
  137. <div>
  138. [page:Boolean requestTerminate] — Default is false
  139. </div>
  140. <div>
  141. Request termination of web worker and free local resources after execution.
  142. </div>
  143. <h3>[method:null setSceneGraphBaseNode]( [page:THREE.Object3D sceneGraphBaseNode] )</h3>
  144. <div>
  145. [page:Object3D sceneGraphBaseNode] — Scene graph object
  146. </div>
  147. <div>
  148. [page:Object3D] where meshes will be attached.
  149. </div>
  150. <h3>[method:null setStreamMeshes]( [page:Boolean streamMeshes] )</h3>
  151. <div>
  152. [page:Boolean streamMeshes] — Default is true
  153. </div>
  154. <div>
  155. Singles meshes are directly integrated into scene when loaded or later.
  156. </div>
  157. <br>
  158. <br>
  159. <a name="PrepDataFile"></a><h1>PrepDataFile</h1>
  160. <h2>Constructor</h2>
  161. <h3>PrepDataFile( [page:String modelName], [page:String pathObj], [page:String fileObj], [page:String pathTexture], [page:String fileMtl] )</h3>
  162. <div>
  163. [page:String modelName] — Overall name of the model<br>
  164. [page:String pathObj] — Path to OBJ file<br>
  165. [page:String fileObj] — OBJ file name<br>
  166. [page:String pathTexture] — Path to texture files<br>
  167. [page:String fileMtl] — MTL file name
  168. </div>
  169. <div>
  170. Instruction to configure [page:WWOBJLoader2.prepareRun] to load OBJ and MTL from files.
  171. </div>
  172. <h2>Methods</h2>
  173. <h3>[method:PrepDataCallbacks getCallbacks]()</h3>
  174. <div>
  175. Returns all callbacks as [page:WWOBJLoader2.PrepDataCallbacks].
  176. </div>
  177. <h3>[method:null setRequestTerminate]( [page:Boolean requestTerminate] )</h3>
  178. <div>
  179. [page:Boolean requestTerminate] — Default is false
  180. </div>
  181. <div>
  182. Request termination of web worker and free local resources after execution.
  183. </div>
  184. <h3>[method:null setSceneGraphBaseNode]( [page:THREE.Object3D sceneGraphBaseNode] )</h3>
  185. <div>
  186. [page:Object3D sceneGraphBaseNode] — Scene graph object
  187. </div>
  188. <div>
  189. [page:Object3D] where meshes will be attached.
  190. </div>
  191. <h3>[method:null setStreamMeshes]( [page:Boolean streamMeshes] )</h3>
  192. <div>
  193. [page:Boolean streamMeshes] — Default is true
  194. </div>
  195. <div>
  196. Singles meshes are directly integrated into scene when loaded or later.
  197. </div>
  198. <br>
  199. <br>
  200. <a name="PrepDataCallbacks"></a><h1>PrepDataCallbacks</h1>
  201. <h2>Constructor</h2>
  202. <h3>PrepDataCallbacks()</h3>
  203. <div>
  204. Callbacks utilized by functions working with [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile].
  205. </div>
  206. <h2>Methods</h2>
  207. <h3>[method:null registerCallbackCompletedLoading]( [page:Function callbackCompletedLoading] )</h3>
  208. <div>
  209. [page:Function callbackCompletedLoading] — Callback function for described functionality
  210. </div>
  211. <div>
  212. Register callback function that is called once loading of the complete model is completed.
  213. </div>
  214. <h3>[method:null registerCallbackProgress]( [page:Function callbackProgress] )</h3>
  215. <div>
  216. [page:Function callbackProgress] — Callback function for described functionality
  217. </div>
  218. <div>
  219. Register callback function that is invoked by internal function "_announceProgress" to print feedback.
  220. </div>
  221. <h3>[method:null registerCallbackErrorWhileLoading]( [page:Function callbackErrorWhileLoading] )</h3>
  222. <div>
  223. [page:Function callbackErrorWhileLoading] — Callback function for described functionality
  224. </div>
  225. <div>
  226. Report if an error prevented loading.
  227. </div>
  228. <h3>[method:null registerCallbackMaterialsLoaded]( [page:Function callbackMaterialsLoaded] )</h3>
  229. <div>
  230. [page:Function callbackMaterialsLoaded] — Callback function for described functionality
  231. </div>
  232. <div>
  233. Register callback function that is called once materials have been loaded. It allows to alter and return materials.
  234. </div>
  235. <h3>[method:null registerCallbackMeshLoaded]( [page:Function callbackMeshLoaded] )</h3>
  236. <div>
  237. [page:Function callbackMeshLoaded] — Callback function for described functionality
  238. </div>
  239. <div>
  240. Register callback function that is called every time a mesh was loaded. Use [page:WWOBJLoader2.LoadedMeshUserOverride] for alteration instructions (geometry, material or disregard mesh).
  241. </div>
  242. <br>
  243. <br>
  244. <a name="LoadedMeshUserOverride"></a><h1>LoadedMeshUserOverride</h1>
  245. <h2>Constructor</h2>
  246. <h3>LoadedMeshUserOverride( [page:Boolean disregardMesh], [page:THREE.BufferGeometry bufferGeometry], [page:THREE.Material material] )</h3>
  247. <div>
  248. [page:Boolean disregardMesh] — Tell [page:WWOBJLoader2] to completely disregard this mesh<br>
  249. [page:BufferGeometry bufferGeometry] — The [page:BufferGeometry] to be used<br>
  250. [page:Material material] — The [page:Material] to be used
  251. </div>
  252. <div>
  253. Object to return by THREE.OBJLoader2.WWOBJLoader2.callbacks.meshLoaded. Used to adjust bufferGeometry or material or prevent complete loading of mesh.
  254. </div>
  255. <br>
  256. <br>
  257. <a name="WWOBJLoader2Director"></a><h1>WWOBJLoader2Director</h1>
  258. <h2>Constructor</h2>
  259. <h3>WWOBJLoader2Director()</h3>
  260. <div>
  261. Orchestrate loading of multiple OBJ files/data from an instruction queue with a configurable amount of workers (1-16).<br>
  262. Workflow:<br>
  263. prepareWorkers<br>
  264. enqueueForRun<br>
  265. processQueue<br>
  266. deregister
  267. </div>
  268. <h3>[method:null prepareWorkers]( [page:WWOBJLoader2.PrepDataCallbacks globalCallbacks], [page:Number maxQueueSize], [page:Number maxWebWorkers] )</h3>
  269. <div>
  270. [page:WWOBJLoader2.PrepDataCallbacks globalCallbacks] — Register global callbacks used by all web workers<br>
  271. [page:Number maxQueueSize] — Set the maximum size of the instruction queue (1-1024)<br>
  272. [page:Number maxWebWorkers] — Set the maximum amount of workers (1-16)
  273. </div>
  274. <div>
  275. Create or destroy workers according limits. Set the name and register callbacks for dynamically created web workers.
  276. </div>
  277. <h3>[method:null enqueueForRun]( [page:Object runParams] )</h3>
  278. <div>
  279. [page:Object runParams] — Either [page:WWOBJLoader2.PrepDataArrayBuffer] or [page:WWOBJLoader2.PrepDataFile]
  280. </div>
  281. <div>
  282. Store run instructions in internal instructionQueue.
  283. </div>
  284. <h3>[method:null processQueue]()</h3>
  285. <div>
  286. Process the instructionQueue until it is depleted.
  287. </div>
  288. <h3>[method:null deregister]()</h3>
  289. <div>
  290. Terminate all workers
  291. </div>
  292. <h3>[method:null getMaxQueueSize]()</h3>
  293. <div>
  294. Returns the maximum length of the instruction queue.
  295. </div>
  296. <h3>[method:null getMaxWebWorkers]()</h3>
  297. <div>
  298. Returns the maximum number of workers.
  299. </div>
  300. <h3>[method:null setCrossOrigin]( [page:String crossOrigin] )</h3>
  301. <div>
  302. [page:String crossOrigin] — CORS value
  303. </div>
  304. <div>
  305. Sets the CORS string to be used.
  306. </div>
  307. <h2>Source</h2>
  308. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader2.js examples/js/loaders/OBJLoader2.js]
  309. </body>
  310. </html>