TextureLoader.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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">Class for loading a [page:Texture texture].</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. default — *null*.<br />
  25. If set, assigns the *crossOrigin* attribute of the image to the value of *crossOrigin*, prior to starting the load.
  26. </div>
  27. <h2>Methods</h2>
  28. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  29. <div>
  30. [page:String url] — required<br />
  31. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<br />
  32. [page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  33. [page:Function onError] — Will be called when load errors.<br />
  34. </div>
  35. <div>
  36. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  37. </div>
  38. <h2>Example</h2>
  39. <code>
  40. // instantiate a loader
  41. var loader = new THREE.TextureLoader();
  42. // load a resource
  43. loader.load(
  44. // resource URL
  45. 'textures/land_ocean_ice_cloud_2048.jpg',
  46. // Function when resource is loaded
  47. function ( texture ) {
  48. // do something with the texture
  49. var material = new THREE.MeshBasicMaterial( {
  50. map: texture
  51. } );
  52. },
  53. // Function called when download progresses
  54. function ( xhr ) {
  55. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  56. },
  57. // Function called when download errors
  58. function ( xhr ) {
  59. console.log( 'An error happened' );
  60. }
  61. );
  62. </code>
  63. [example:canvas_geometry_earth]
  64. <h2>Source</h2>
  65. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  66. </body>
  67. </html>