2
0

ImageLoader.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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">A loader for loading an [page:Image].</div>
  13. <h2>Example</h2>
  14. <code>
  15. // instantiate a loader
  16. var loader = new THREE.ImageLoader();
  17. // load a image resource
  18. loader.load(
  19. // resource URL
  20. 'textures/skyboxsun25degtest.png',
  21. // Function when resource is loaded
  22. function ( image ) {
  23. // do something with it
  24. // like drawing a part of it on a canvas
  25. var canvas = document.createElement( 'canvas' );
  26. var context = canvas.getContext( '2d' );
  27. context.drawImage( image, 100, 100 );
  28. },
  29. // Function called when download progresses
  30. function ( xhr ) {
  31. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  32. },
  33. // Function called when download errors
  34. function ( xhr ) {
  35. console.log( 'An error happened' );
  36. }
  37. );
  38. </code>
  39. [example:webgl_shaders_ocean]
  40. <h2>Constructor</h2>
  41. <h3>[name]( [page:LoadingManager manager] )</h3>
  42. <div>
  43. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  44. </div>
  45. <div>
  46. Creates a new [name].
  47. </div>
  48. <h2>Properties</h2>
  49. <h3>[property:String crossOrigin]</h3>
  50. <div>
  51. The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
  52. </div>
  53. <h2>Methods</h2>
  54. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  55. <div>
  56. [page:String url] — required<br />
  57. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].<br />
  58. [page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
  59. [page:Function onError] — Will be called when load errors.<br />
  60. </div>
  61. <div>
  62. Begin loading from url and return the [page:Image image] object that will contain the data.
  63. </div>
  64. <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
  65. <div>
  66. [page:String value] — The crossOrigin string.
  67. </div>
  68. <div>
  69. The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
  70. </div>
  71. <h2>Source</h2>
  72. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  73. </body>
  74. </html>