OBJLoader2Parallel.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. <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>Examples</h2>
  19. <code>
  20. // instantiate the loader
  21. let objLoader2Parallel = new OBJLoader2Parallel();
  22. // define where to attach the data
  23. let local = new THREE.Object3D();
  24. // function called on successful completion of parsing
  25. function callbackOnLoad( object3d, message ) {
  26. local.add( object3d );
  27. }
  28. // load a resource from provided URL in parallel to Main
  29. objLoader2Parallel.load( 'models/obj/walt/WaltHead.obj', callbackOnLoad, null, null, null );
  30. </code>
  31. [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main)<br>
  32. <h2>Constructor</h2>
  33. <h3>[name]( [param:LoadingManager manager] )</h3>
  34. <p>
  35. [page:LoadingManager manager] - The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br>
  36. </p>
  37. <p>
  38. Creates a new [name]. Use it to load OBJ data from files or to parse OBJ data from arraybuffer or text.
  39. </p>
  40. <h2>Methods</h2>
  41. <h3>[method:Object3D parse]( [param:arraybuffer content]|[param:String content] )</h3>
  42. <p>
  43. [[page:arraybuffer content]|[page:String content]] OBJ data as Uint8Array or String
  44. </p>
  45. <p>
  46. Parses OBJ data synchronously from arraybuffer or string and returns the [page:Object3D loaderRoorNode].
  47. </p>
  48. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError], [param:Function onMeshAlter], [param:boolean useAsync] )</h3>
  49. <p>
  50. [page:String url] - A string containing the path/URL of the file to be loaded.<br>
  51. [page:Function onLoad] - A function to be called after loading is successfully completed. The function receives loaded [page:Object3D] as an argument.<br>
  52. [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>
  53. [page:Function onError] - (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br>
  54. [page:Function onMeshAlter] - (optional) A function to be called after a new mesh raw data becomes available for alteration.<br>
  55. [page:boolean useAsync] - (optional) If true, uses async loading with worker, if false loads data synchronously.
  56. </p>
  57. <p>
  58. Use this convenient method to load a file at the given URL. By default the fileLoader uses an ArrayBuffer.
  59. </p>
  60. <h2>Source</h2>
  61. <p>
  62. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader2Parallel.js examples/jsm/loaders/OBJLoader2.js]
  63. </p>
  64. </body>
  65. </html>