ImageBitmapLoader.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ImageBitmapLoader - 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">ImageBitmapLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for loading images as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap">ImageBitmap</a>.
  17. An <code>ImageBitmap</code> provides an asynchronous and resource efficient pathway to prepare
  18. textures for rendering.</p>
  19. <p>Note that <a href="Texture.html#flipY">Texture#flipY</a> and <a href="Texture.html#premultiplyAlpha">Texture#premultiplyAlpha</a> are ignored with image bitmaps.
  20. They needs these configuration on bitmap creation unlike regular images need them on uploading to GPU.</p>
  21. <p>You need to set the equivalent options via <a href="ImageBitmapLoader.html#setOptions">ImageBitmapLoader#setOptions</a> instead.</p>
  22. <p>Also note that unlike <a href="FileLoader.html">FileLoader</a>, this loader avoids multiple concurrent requests to the same URL only if <code>Cache</code> is enabled.</p></div>
  23. <h2>Code Example</h2>
  24. <div translate="no"><pre><code class="language-js">const loader = new THREE.ImageBitmapLoader();
  25. loader.setOptions( { imageOrientation: 'flipY' } ); // set options if needed
  26. const imageBitmap = await loader.loadAsync( 'image.png' );
  27. const texture = new THREE.Texture( imageBitmap );
  28. texture.needsUpdate = true;
  29. </code></pre></div>
  30. </header>
  31. <article>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="ImageBitmapLoader" translate="no">new <a href="#ImageBitmapLoader">ImageBitmapLoader</a><span class="signature">( manager : <span class="param-type">LoadingManager</span> )</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new image bitmap loader.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name"><code>manager</code></td>
  43. <td class="description last"><p>The loading manager.</p></td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="isImageBitmapLoader" translate="no">.<a href="#isImageBitmapLoader">isImageBitmapLoader</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  52. <div class="description">
  53. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="options" translate="no">.<a href="#options">options</a><span class="type-signature"> : Object</span> </h3>
  58. <div class="description">
  59. <p>Represents the loader options.<br/>Default is <code>{premultiplyAlpha:'none'}</code>.</p>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Methods</h2>
  63. <h3 class="name name-method" id="abort" translate="no">.<a href="#abort">abort</a><span class="signature">()</span><span class="type-signature"> : <a href="ImageBitmapLoader.html">ImageBitmapLoader</a></span> </h3>
  64. <div class="method">
  65. <div class="description">
  66. <p>Aborts ongoing fetch requests.</p>
  67. </div>
  68. <dl class="details">
  69. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#abort">Loader#abort</a></dt>
  70. </dl>
  71. <dl class="details">
  72. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  73. </dl>
  74. </div>
  75. <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"> : ImageBitmap | undefined</span> </h3>
  76. <div class="method">
  77. <div class="description">
  78. <p>Starts loading from the given URL and pass the loaded image bitmap to the <code>onLoad()</code> callback.</p>
  79. </div>
  80. <table class="params">
  81. <tbody>
  82. <tr>
  83. <td class="name"><code>url</code></td>
  84. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  85. </tr>
  86. <tr>
  87. <td class="name"><code>onLoad</code></td>
  88. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  89. </tr>
  90. <tr>
  91. <td class="name"><code>onProgress</code></td>
  92. <td class="description last"><p>Unsupported in this loader.</p></td>
  93. </tr>
  94. <tr>
  95. <td class="name"><code>onError</code></td>
  96. <td class="description last"><p>Executed when errors occur.</p></td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <dl class="details">
  101. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  102. </dl>
  103. <dl class="details">
  104. <dt class="tag-returns"><strong>Returns:</strong> The image bitmap.</dt>
  105. </dl>
  106. </div>
  107. <h3 class="name name-method" id="setOptions" translate="no">.<a href="#setOptions">setOptions</a><span class="signature">( options : <span class="param-type">Object</span> )</span><span class="type-signature"> : <a href="ImageBitmapLoader.html">ImageBitmapLoader</a></span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Sets the given loader options. The structure of the object must match the <code>options</code> parameter of
  111. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap">createImageBitmap</a>.</p>
  112. </div>
  113. <table class="params">
  114. <tbody>
  115. <tr>
  116. <td class="name"><code>options</code></td>
  117. <td class="description last"><p>The loader options to set.</p></td>
  118. </tr>
  119. </tbody>
  120. </table>
  121. <dl class="details">
  122. <dt class="tag-returns"><strong>Returns:</strong> A reference to this image bitmap loader.</dt>
  123. </dl>
  124. </div>
  125. <h2 class="subsection-title">Source</h2>
  126. <p>
  127. <a href="https://github.com/mrdoob/three.js/blob/master/src/loaders/ImageBitmapLoader.js" target="_blank" rel="noopener" translate="no">src/loaders/ImageBitmapLoader.js</a>
  128. </p>
  129. </article>
  130. </section>
  131. <script src="../scripts/linenumber.js"></script>
  132. <script src="../scripts/page.js"></script>
  133. </body>
  134. </html>
粤ICP备19079148号