TextureLoader.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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>Example</h2>
  14. <code>
  15. // instantiate a loader
  16. var loader = new THREE.TextureLoader();
  17. // load a resource
  18. loader.load(
  19. // resource URL
  20. 'textures/land_ocean_ice_cloud_2048.jpg',
  21. // Function when resource is loaded
  22. function ( texture ) {
  23. // do something with the texture
  24. var material = new THREE.MeshBasicMaterial( {
  25. map: texture
  26. } );
  27. },
  28. // Function called when download progresses
  29. function ( xhr ) {
  30. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  31. },
  32. // Function called when download errors
  33. function ( xhr ) {
  34. console.log( 'An error happened' );
  35. }
  36. );
  37. </code>
  38. [example:canvas_geometry_earth]
  39. <h2>Constructor</h2>
  40. <h3>[name]( [page:LoadingManager manager] )</h3>
  41. <div>
  42. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  43. </div>
  44. <div>
  45. Creates a new [name].
  46. </div>
  47. <h2>Properties</h2>
  48. <h3>[property:String crossOrigin]</h3>
  49. <div>
  50. default — *null*.<br />
  51. If set, assigns the *crossOrigin* attribute of the image to the value of *crossOrigin*, prior to starting the load.
  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:Texture texture].<br />
  58. [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 />
  59. [page:Function onError] — Will be called when load errors.<br />
  60. </div>
  61. <div>
  62. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  63. </div>
  64. <h2>Source</h2>
  65. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  66. </body>
  67. </html>