ImageLoader.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. <div class="desc">
  13. A loader for loading an [page:Image].
  14. This uses the [page:FileLoader] internally for loading files, and is used internally by the
  15. [page:CubeTextureLoader], [page:ObjectLoader] and [page:TextureLoader].
  16. </div>
  17. <h2>Example</h2>
  18. <div>
  19. [example:webgl_loader_obj WebGL / loader / obj]<br />
  20. [example:webgl_shaders_ocean WebGL / shaders / ocean]
  21. </div>
  22. <code>
  23. // instantiate a loader
  24. var loader = new THREE.ImageLoader();
  25. // load a image resource
  26. loader.load(
  27. // resource URL
  28. 'textures/skyboxsun25degtest.png',
  29. // Function when resource is loaded
  30. function ( image ) {
  31. // do something with it
  32. // like drawing a 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. // Function called when download progresses
  38. function ( xhr ) {
  39. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  40. },
  41. // Function called when download errors
  42. function ( xhr ) {
  43. console.log( 'An error happened' );
  44. }
  45. );
  46. </code>
  47. <h2>Constructor</h2>
  48. <h3>[name]( [page:LoadingManager manager] )</h3>
  49. <div>
  50. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  51. Creates a new [name].
  52. </div>
  53. <h2>Properties</h2>
  54. <h3>[property:String crossOrigin]</h3>
  55. <div>
  56. If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
  57. attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *undefined*.
  58. </div>
  59. <h3>[property:LoadingManager manager]</h3>
  60. <div>
  61. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  62. </div>
  63. <h3>[property:String path]</h3>
  64. <div>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</div>
  65. <h3>[property:String withCredentials]</h3>
  66. <div>
  67. Whether the XMLHttpRequest uses credentials - see [page:.setWithCredentials].
  68. Default is *undefined*.
  69. </div>
  70. <h2>Methods</h2>
  71. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  72. <div>
  73. [page:String url] — the path or URL to the file. This can also be a
  74. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  75. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
  76. [page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
  77. [page:Function onError] — Will be called when load errors.<br />
  78. </div>
  79. <div>
  80. Begin loading from url and return the [page:Image image] object that will contain the data.
  81. </div>
  82. <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
  83. <div>Set the [page:.crossOrigin] attribute.</div>
  84. <h3>[method:FileLoader setPath]( [page:String path] )</h3>
  85. <div>
  86. Set the base path or URL from which to load files. This can be useful if
  87. you are loading many models from the same directory.
  88. </div>
  89. <h3>[method:FileLoader setWithCredentials]( [page:Boolean value] )</h3>
  90. Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or
  91. TLS client certificates. See
  92. [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br />
  93. Note that this has no effect if you are loading files locally or from the same domain.
  94. <div>
  95. <h2>Source</h2>
  96. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  97. </body>
  98. </html>