ImageLoader.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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].
  15. This is used internally by the
  16. [page:CubeTextureLoader], [page:ObjectLoader] and [page:TextureLoader].
  17. </p>
  18. <h2>Example</h2>
  19. <p>
  20. [example:webgl_loader_obj WebGL / loader / obj]<br />
  21. [example:webgl_shaders_ocean WebGL / shaders / ocean]
  22. </p>
  23. <code>
  24. // instantiate a loader
  25. var loader = new THREE.ImageLoader();
  26. // load a image resource
  27. loader.load(
  28. // resource URL
  29. 'textures/skyboxsun25degtest.png',
  30. // onLoad callback
  31. function ( image ) {
  32. // use the image, e.g. draw part of it on a canvas
  33. var canvas = document.createElement( 'canvas' );
  34. var context = canvas.getContext( '2d' );
  35. context.drawImage( image, 100, 100 );
  36. },
  37. // onProgress callback currently not supported
  38. undefined,
  39. // onError callback
  40. function () {
  41. console.error( 'An error happened.' );
  42. }
  43. );
  44. </code>
  45. <p>
  46. Please note three.js r84 dropped support for ImageLoader progress events. For an ImageLoader
  47. that supports progress events, see [link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-275785639 this thread].
  48. </p>
  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. <p>See the base [page:Loader] class for common properties.</p>
  57. <h2>Methods</h2>
  58. <p>See the base [page:Loader] class for common methods.</p>
  59. <h3>[method:HTMLImageElement load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  60. <p>
  61. [page:String url] — the path or URL to the file. This can also be a
  62. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  63. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
  64. [page:Function onProgress] — This callback function is currently not supported.<br />
  65. [page:Function onError] — Will be called when load errors.<br />
  66. </p>
  67. <p>
  68. Begin loading from url and return the [page:Image image] object that will contain the data.
  69. </p>
  70. <h2>Source</h2>
  71. <p>
  72. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  73. </p>
  74. </body>
  75. </html>