TextureLoader.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <script src="../../list.js"></script>
  6. <script src="../../page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="../../page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <div class="desc">Class for loading a [page:Texture texture].</div>
  12. <h2>Constructor</h2>
  13. <h3>[name]( [page:LoadingManager manager] )</h3>
  14. <div>
  15. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  16. </div>
  17. <div>
  18. Creates a new [name].
  19. </div>
  20. <h2>Properties</h2>
  21. <h3>[property:String crossOrigin]</h3>
  22. <div>
  23. default — *null*.<br />
  24. If set, assigns the *crossOrigin* attribute of the image to the value of *crossOrigin*, prior to starting the load.
  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 text response.<br />
  31. [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 />
  32. [page:Function onError] — Will be called when load errors.<br />
  33. </div>
  34. <div>
  35. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  36. </div>
  37. <h2>Example</h2>
  38. <code>
  39. // instantiate a loader
  40. var loader = new THREE.TextureLoader();
  41. // load a resource
  42. loader.load(
  43. // resource URL
  44. 'textures/land_ocean_ice_cloud_2048.jpg',
  45. // Function when resource is loaded
  46. function ( texture ) {
  47. // do something with the texture
  48. var material = new THREE.MeshBasicMaterial( {
  49. map: texture
  50. } );
  51. },
  52. // Function called when download progresses
  53. function ( xhr ) {
  54. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  55. },
  56. // Function called when download errors
  57. function ( xhr ) {
  58. console.log( 'An error happened' );
  59. }
  60. );
  61. </code>
  62. [example:canvas_geometry_earth]
  63. <h2>Source</h2>
  64. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  65. </body>
  66. </html>