ImageBitmapLoader.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. A loader for loading an [page:Image] as an [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap].
  15. An ImageBitmap provides an asynchronous and resource efficient pathway to prepare textures for rendering in WebGL.<br/>
  16. Unlike [page:FileLoader], [name] does not avoid multiple concurrent requests to the same URL.
  17. </p>
  18. <p>
  19. Note that [page:Texture.flipY] and [page:Texture.premultiplyAlpha] with [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap] are ignored.
  20. [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap] needs these configuration on bitmap creation
  21. unlike regular images need them on uploading to GPU. You need to set the equivalent options via [page:ImageBitmapLoader.setOptions]
  22. instead. Refer to [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.10 WebGL specification] for the detail.
  23. </p>
  24. <h2>Code Example</h2>
  25. <code>
  26. // instantiate a loader
  27. var loader = new THREE.ImageBitmapLoader();
  28. // set options if needed
  29. loader.setOptions( { imageOrientation: 'flipY' } );
  30. // load a image resource
  31. loader.load(
  32. // resource URL
  33. 'textures/skyboxsun25degtest.png',
  34. // onLoad callback
  35. function ( imageBitmap ) {
  36. var texture = new THREE.CanvasTexture( imageBitmap );
  37. var material = new THREE.MeshBasicMaterial( { map: texture } );
  38. },
  39. // onProgress callback currently not supported
  40. undefined,
  41. // onError callback
  42. function ( err ) {
  43. console.log( 'An error happened' );
  44. }
  45. );
  46. </code>
  47. <h2>Examples</h2>
  48. <p>
  49. [example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap]
  50. </p>
  51. <h2>Constructor</h2>
  52. <h3>[name]( [param:LoadingManager manager] )</h3>
  53. <p>
  54. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  55. Creates a new [name].
  56. </p>
  57. <h2>Properties</h2>
  58. <p>See the base [page:Loader] class for common properties.</p>
  59. <h3>[property:String options]</h3>
  60. <p>An optional object that sets options for the internally used [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap] factory method. Default is *undefined*.</p>
  61. <h2>Methods</h2>
  62. <p>See the base [page:Loader] class for common methods.</p>
  63. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  64. <p>
  65. [page:String url] — the path or URL to the file. This can also be a
  66. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  67. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
  68. [page:Function onProgress] — This callback function is currently not supported.<br />
  69. [page:Function onError] — Will be called when load errors.<br />
  70. </p>
  71. <p>
  72. Begin loading from url and return the [page:ImageBitmap image] object that will contain the data.
  73. </p>
  74. <h3>[method:ImageBitmapLoader setOptions]( [param:Object options] )</h3>
  75. <p>
  76. Sets the options object for [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap].
  77. </p>
  78. <h2>Source</h2>
  79. <p>
  80. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  81. </p>
  82. </body>
  83. </html>