OBJLoader2.html 5.2 KB

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