ImageBitmapLoader.html 4.2 KB

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