2
0

ImageLoader.html 2.5 KB

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