TGALoader.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">A loader for loading a <em>.tga</em> resource. <br />
  14. <a href="https://en.wikipedia.org/wiki/Truevision_TGA">TGA</a> is a raster graphics, image file format.
  15. </p>
  16. <h2>Example</h2>
  17. <code>
  18. // instantiate a loader
  19. var loader = new THREE.TGALoader();
  20. // load a resource
  21. var texture = loader.load(
  22. // resource URL
  23. 'textures/crate_grey8.tga'
  24. // called when loading is completed
  25. function ( texture ) {
  26. console.log( 'Texture is loaded' );
  27. },
  28. // called when the loading is in progresses
  29. function ( xhr ) {
  30. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  31. },
  32. // called when the loading failes
  33. function ( error ) {
  34. console.log( 'An error happened' );
  35. }
  36. );
  37. var material = new THREE.MeshPhongMaterial( {
  38. color: 0xffffff,
  39. map: texture
  40. } );
  41. </code>
  42. [example:webgl_loader_texture_tga]
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:LoadingManager manager] )</h3>
  45. <p>
  46. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  47. </p>
  48. <p>
  49. Creates a new [name].
  50. </p>
  51. <h2>Properties</h2>
  52. <p>See the base [page:Loader] class for common properties.</p>
  53. <h2>Methods</h2>
  54. <p>See the base [page:Loader] class for common methods.</p>
  55. <h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  56. <p>
  57. [page:String url] — A string containing the path/URL of the <em>.tga</em> file. <br />
  58. [page:Function onLoad] — (optional) A function to be called after loading is successfully completed. The function receives loaded [page:DataTexture] as an argument.<br />
  59. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  60. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br />
  61. </p>
  62. <p>
  63. Begin loading from url and pass the loaded [page:DataTexture texture] to onLoad. The [page:DataTexture texture] is also directly returned for immediate use (but may not be fully loaded).
  64. </p>
  65. <h2>Source</h2>
  66. <p>
  67. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/TGALoader.js examples/js/loaders/TGALoader.js]
  68. </p>
  69. </body>
  70. </html>