TextureLoader.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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">
  13. Class for loading a [page:Texture texture].
  14. This uses the [page:ImageLoader] internally for loading files.
  15. </div>
  16. <h2>Example</h2>
  17. <code>
  18. // instantiate a loader
  19. var loader = new THREE.TextureLoader();
  20. // load a resource
  21. loader.load(
  22. // resource URL
  23. 'textures/land_ocean_ice_cloud_2048.jpg',
  24. // Function when resource is loaded
  25. function ( texture ) {
  26. // do something with the texture
  27. var material = new THREE.MeshBasicMaterial( {
  28. map: texture
  29. } );
  30. },
  31. // Function called when download progresses
  32. function ( xhr ) {
  33. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  34. },
  35. // Function called when download errors
  36. function ( xhr ) {
  37. console.log( 'An error happened' );
  38. }
  39. );
  40. </code>
  41. [example:canvas_geometry_earth]
  42. <h2>Constructor</h2>
  43. <h3>[name]( [page:LoadingManager manager] )</h3>
  44. <div>
  45. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  46. Creates a new [name].
  47. </div>
  48. <h2>Properties</h2>
  49. <h3>[property:String crossOrigin]</h3>
  50. <div>
  51. If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
  52. attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *undefined*.
  53. </div>
  54. <h3>[property:LoadingManager manager]</h3>
  55. <div>
  56. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  57. </div>
  58. <h3>[property:String path]</h3>
  59. <div>The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.</div>
  60. <h3>[property:String withCredentials]</h3>
  61. <div>
  62. Whether the XMLHttpRequest uses credentials - see [page:.setWithCredentials].
  63. Default is *undefined*.
  64. </div>
  65. <h2>Methods</h2>
  66. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  67. <div>
  68. [page:String url] — required<br />
  69. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Texture texture].<br />
  70. [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 />
  71. [page:Function onError] — Will be called when load errors.<br /><br />
  72. Begin loading from url and pass the loaded [page:Texture texture] to onLoad.
  73. </div>
  74. <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
  75. <div>Set the [page:.crossOrigin] attribute.</div>
  76. <h3>[method:FileLoader setPath]( [page:String path] )</h3>
  77. <div>
  78. Set the base path or URL from which to load files. This can be useful if
  79. you are loading many models from the same directory.
  80. </div>
  81. <h3>[method:FileLoader setWithCredentials]( [page:Boolean value] )</h3>
  82. Whether the XMLHttpRequest uses credentials such as cookies, authorization headers or
  83. TLS client certificates. See
  84. [link:https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials XMLHttpRequest.withCredentials].<br />
  85. Note that this has no effect if you are loading files locally or from the same domain.
  86. <div>
  87. <h2>Source</h2>
  88. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  89. </body>
  90. </html>