1
0

TextureLoader.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TextureLoader - 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. <p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">TextureLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Class for loading textures. Images are internally
  17. loaded via <a href="ImageLoader.html">ImageLoader</a>.</p>
  18. <p>Please note that <code>TextureLoader</code> has dropped support for progress
  19. events in <code>r84</code>. For a <code>TextureLoader</code> that supports progress events, see
  20. <a href="https://github.com/mrdoob/three.js/issues/10439#issuecomment-293260145" target="_blank" rel="noopener">this thread</a>.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">const loader = new THREE.TextureLoader();
  23. const texture = await loader.loadAsync( 'textures/land_ocean_ice_cloud_2048.jpg' );
  24. const material = new THREE.MeshBasicMaterial( { map:texture } );
  25. </code></pre></div>
  26. </header>
  27. <article>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="TextureLoader" translate="no">new <a href="#TextureLoader">TextureLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new texture loader.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name">
  39. <strong>manager</strong>
  40. </td>
  41. <td class="description last">
  42. <p>The loading manager.</p>
  43. </td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Methods</h2>
  50. <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"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  51. <div class="method">
  52. <div class="description">
  53. <p>Starts loading from the given URL and pass the fully loaded texture
  54. to the <code>onLoad()</code> callback. The method also returns a new texture object which can
  55. directly be used for material creation. If you do it this way, the texture
  56. may pop up in your scene once the respective loading process is finished.</p>
  57. </div>
  58. <table class="params">
  59. <tbody>
  60. <tr>
  61. <td class="name">
  62. <strong>url</strong>
  63. </td>
  64. <td class="description last">
  65. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td class="name">
  70. <strong>onLoad</strong>
  71. </td>
  72. <td class="description last">
  73. <p>Executed when the loading process has been finished.</p>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td class="name">
  78. <strong>onProgress</strong>
  79. </td>
  80. <td class="description last">
  81. <p>Unsupported in this loader.</p>
  82. </td>
  83. </tr>
  84. <tr>
  85. <td class="name">
  86. <strong>onError</strong>
  87. </td>
  88. <td class="description last">
  89. <p>Executed when errors occur.</p>
  90. </td>
  91. </tr>
  92. </tbody>
  93. </table>
  94. <dl class="details">
  95. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  96. </dl>
  97. <dl class="details">
  98. <dt class="tag-returns"><strong>Returns:</strong> The texture.</dt>
  99. </dl>
  100. </div>
  101. <h2 class="subsection-title">Source</h2>
  102. <p>
  103. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/TextureLoader.js" translate="no" target="_blank" rel="noopener">src/loaders/TextureLoader.js</a>
  104. </p>
  105. </article>
  106. </section>
  107. <script src="../scripts/linenumber.js"></script>
  108. <script src="../scripts/page.js"></script>
  109. </body>
  110. </html>
粤ICP备19079148号