Loader.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Loader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Loader</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Abstract base class for loaders.</p></div>
  16. </header>
  17. <article>
  18. <div class="container-overview">
  19. <h2>Constructor</h2>
  20. <h3 class="name name-method" id="Loader" translate="no">new <a href="#Loader">Loader</a><span class="signature">( manager : <span class="param-type">LoadingManager</span> )</span> <span class="type-signature">(abstract) </span></h3>
  21. <div class="method">
  22. <div class="description">
  23. <p>Constructs a new loader.</p>
  24. </div>
  25. <table class="params">
  26. <tbody>
  27. <tr>
  28. <td class="name"><code>manager</code></td>
  29. <td class="description last"><p>The loading manager.</p></td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. </div>
  34. </div>
  35. <h2 class="subsection-title">Properties</h2>
  36. <div class="member">
  37. <h3 class="name" id="crossOrigin" translate="no">.<a href="#crossOrigin">crossOrigin</a><span class="type-signature"> : string</span> </h3>
  38. <div class="description">
  39. <p>The crossOrigin string to implement CORS for loading the url from a
  40. different domain that allows CORS.<br/>Default is <code>'anonymous'</code>.</p>
  41. </div>
  42. </div>
  43. <div class="member">
  44. <h3 class="name" id="manager" translate="no">.<a href="#manager">manager</a><span class="type-signature"> : <a href="LoadingManager.html">LoadingManager</a></span> </h3>
  45. <div class="description">
  46. <p>The loading manager.<br/>Default is <code>DefaultLoadingManager</code>.</p>
  47. </div>
  48. </div>
  49. <div class="member">
  50. <h3 class="name" id="path" translate="no">.<a href="#path">path</a><span class="type-signature"> : string</span> </h3>
  51. <div class="description">
  52. <p>The base path from which the asset will be loaded.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="requestHeader" translate="no">.<a href="#requestHeader">requestHeader</a><span class="type-signature"> : Object.&lt;string, <a href="global.html#any">any</a>></span> </h3>
  57. <div class="description">
  58. <p>The <a href="https://developer.mozilla.org/en-US/docs/Glossary/Request_header">request header</a>
  59. used in HTTP request.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="resourcePath" translate="no">.<a href="#resourcePath">resourcePath</a><span class="type-signature"> : string</span> </h3>
  64. <div class="description">
  65. <p>The base path from which additional resources like textures will be loaded.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="withCredentials" translate="no">.<a href="#withCredentials">withCredentials</a><span class="type-signature"> : boolean</span> </h3>
  70. <div class="description">
  71. <p>Whether the XMLHttpRequest uses credentials.<br/>Default is <code>false</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id=".DEFAULT_MATERIAL_NAME" translate="no">.<a href="#.DEFAULT_MATERIAL_NAME">DEFAULT_MATERIAL_NAME</a><span class="type-signature"> : string</span> </h3>
  76. <div class="description">
  77. <p>The default material name that is used by loaders
  78. when creating materials for loaded 3D objects.</p>
  79. <p>Note: Not all loaders might honor this setting.<br/>Default is <code>'__DEFAULT'</code>.</p>
  80. </div>
  81. </div>
  82. <h2 class="subsection-title">Methods</h2>
  83. <h3 class="name name-method" id="abort" translate="no">.<a href="#abort">abort</a><span class="signature">()</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> <span class="type-signature">(abstract) </span></h3>
  84. <div class="method">
  85. <div class="description">
  86. <p>This method can be implemented in loaders for aborting ongoing requests.</p>
  87. </div>
  88. <dl class="details">
  89. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  90. </dl>
  91. </div>
  92. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span> <span class="type-signature">(abstract) </span></h3>
  93. <div class="method">
  94. <div class="description">
  95. <p>This method needs to be implemented by all concrete loaders. It holds the
  96. logic for loading assets from the backend.</p>
  97. </div>
  98. <table class="params">
  99. <tbody>
  100. <tr>
  101. <td class="name"><code>url</code></td>
  102. <td class="description last"><p>The path/URL of the file to be loaded.</p></td>
  103. </tr>
  104. <tr>
  105. <td class="name"><code>onLoad</code></td>
  106. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  107. </tr>
  108. <tr>
  109. <td class="name"><code>onProgress</code></td>
  110. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  111. </tr>
  112. <tr>
  113. <td class="name"><code>onError</code></td>
  114. <td class="description last"><p>Executed when errors occur.</p></td>
  115. </tr>
  116. </tbody>
  117. </table>
  118. </div>
  119. <h3 class="name name-method" id="loadAsync" translate="no">.<a href="#loadAsync">loadAsync</a><span class="signature">( url : <span class="param-type">string</span>, onProgress : <span class="param-type">onProgressCallback</span> )</span><span class="type-signature"> : Promise</span> </h3>
  120. <div class="method">
  121. <div class="description">
  122. <p>A async version of <a href="Loader.html#load">Loader#load</a>.</p>
  123. </div>
  124. <table class="params">
  125. <tbody>
  126. <tr>
  127. <td class="name"><code>url</code></td>
  128. <td class="description last"><p>The path/URL of the file to be loaded.</p></td>
  129. </tr>
  130. <tr>
  131. <td class="name"><code>onProgress</code></td>
  132. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  133. </tr>
  134. </tbody>
  135. </table>
  136. <dl class="details">
  137. <dt class="tag-returns"><strong>Returns:</strong> A Promise that resolves when the asset has been loaded.</dt>
  138. </dl>
  139. </div>
  140. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( data : <span class="param-type">any</span> )</span> <span class="type-signature">(abstract) </span></h3>
  141. <div class="method">
  142. <div class="description">
  143. <p>This method needs to be implemented by all concrete loaders. It holds the
  144. logic for parsing the asset into three.js entities.</p>
  145. </div>
  146. <table class="params">
  147. <tbody>
  148. <tr>
  149. <td class="name"><code>data</code></td>
  150. <td class="description last"><p>The data to parse.</p></td>
  151. </tr>
  152. </tbody>
  153. </table>
  154. </div>
  155. <h3 class="name name-method" id="setCrossOrigin" translate="no">.<a href="#setCrossOrigin">setCrossOrigin</a><span class="signature">( crossOrigin : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> </h3>
  156. <div class="method">
  157. <div class="description">
  158. <p>Sets the <code>crossOrigin</code> String to implement CORS for loading the URL
  159. from a different domain that allows CORS.</p>
  160. </div>
  161. <table class="params">
  162. <tbody>
  163. <tr>
  164. <td class="name"><code>crossOrigin</code></td>
  165. <td class="description last"><p>The <code>crossOrigin</code> value.</p></td>
  166. </tr>
  167. </tbody>
  168. </table>
  169. <dl class="details">
  170. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  171. </dl>
  172. </div>
  173. <h3 class="name name-method" id="setPath" translate="no">.<a href="#setPath">setPath</a><span class="signature">( path : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> </h3>
  174. <div class="method">
  175. <div class="description">
  176. <p>Sets the base path for the asset.</p>
  177. </div>
  178. <table class="params">
  179. <tbody>
  180. <tr>
  181. <td class="name"><code>path</code></td>
  182. <td class="description last"><p>The base path.</p></td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <dl class="details">
  187. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  188. </dl>
  189. </div>
  190. <h3 class="name name-method" id="setRequestHeader" translate="no">.<a href="#setRequestHeader">setRequestHeader</a><span class="signature">( requestHeader : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> </h3>
  191. <div class="method">
  192. <div class="description">
  193. <p>Sets the given request header.</p>
  194. </div>
  195. <table class="params">
  196. <tbody>
  197. <tr>
  198. <td class="name"><code>requestHeader</code></td>
  199. <td class="description last"><p>A <a href="https://developer.mozilla.org/en-US/docs/Glossary/Request_header">request header</a>
  200. for configuring the HTTP request.</p></td>
  201. </tr>
  202. </tbody>
  203. </table>
  204. <dl class="details">
  205. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  206. </dl>
  207. </div>
  208. <h3 class="name name-method" id="setResourcePath" translate="no">.<a href="#setResourcePath">setResourcePath</a><span class="signature">( resourcePath : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> </h3>
  209. <div class="method">
  210. <div class="description">
  211. <p>Sets the base path for dependent resources like textures.</p>
  212. </div>
  213. <table class="params">
  214. <tbody>
  215. <tr>
  216. <td class="name"><code>resourcePath</code></td>
  217. <td class="description last"><p>The resource path.</p></td>
  218. </tr>
  219. </tbody>
  220. </table>
  221. <dl class="details">
  222. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  223. </dl>
  224. </div>
  225. <h3 class="name name-method" id="setWithCredentials" translate="no">.<a href="#setWithCredentials">setWithCredentials</a><span class="signature">( value : <span class="param-type">boolean</span> )</span><span class="type-signature"> : <a href="Loader.html">Loader</a></span> </h3>
  226. <div class="method">
  227. <div class="description">
  228. <p>Whether the XMLHttpRequest uses credentials such as cookies, authorization
  229. headers or TLS client certificates, see <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials">XMLHttpRequest.withCredentials</a>.</p>
  230. <p>Note: This setting has no effect if you are loading files locally or from the same domain.</p>
  231. </div>
  232. <table class="params">
  233. <tbody>
  234. <tr>
  235. <td class="name"><code>value</code></td>
  236. <td class="description last"><p>The <code>withCredentials</code> value.</p></td>
  237. </tr>
  238. </tbody>
  239. </table>
  240. <dl class="details">
  241. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  242. </dl>
  243. </div>
  244. <h2 class="subsection-title">Source</h2>
  245. <p>
  246. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/Loader.js" target="_blank" rel="noopener" translate="no">src/loaders/Loader.js</a>
  247. </p>
  248. </article>
  249. </section>
  250. <script src="../scripts/linenumber.js"></script>
  251. <script src="../scripts/page.js"></script>
  252. </body>
  253. </html>
粤ICP备19079148号