TGALoader.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Loader] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">A loader for loading a `.tga` resource. <br />
  13. [link:https://en.wikipedia.org/wiki/Truevision_TGA TGA] is a raster graphics, image file format.
  14. </p>
  15. <h2>Import</h2>
  16. <p>
  17. [name] is an add-on, and must be imported explicitly.
  18. See [link:#manual/introduction/Installation Installation / Addons].
  19. </p>
  20. <code>
  21. import { TGALoader } from 'three/addons/loaders/TGALoader.js';
  22. </code>
  23. <h2>Code Example</h2>
  24. <code>
  25. // instantiate a loader
  26. const loader = new TGALoader();
  27. // load a resource
  28. const texture = loader.load(
  29. // resource URL
  30. 'textures/crate_grey8.tga'
  31. // called when loading is completed
  32. function ( texture ) {
  33. console.log( 'Texture is loaded' );
  34. },
  35. // called when the loading is in progresses
  36. function ( xhr ) {
  37. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  38. },
  39. // called when the loading fails
  40. function ( error ) {
  41. console.log( 'An error happened' );
  42. }
  43. );
  44. const material = new THREE.MeshPhongMaterial( {
  45. color: 0xffffff,
  46. map: texture
  47. } );
  48. </code>
  49. <h2>Examples</h2>
  50. <p>
  51. [example:webgl_loader_texture_tga]
  52. </p>
  53. <h2>Constructor</h2>
  54. <h3>[name]( [param:LoadingManager manager] )</h3>
  55. <p>
  56. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  57. </p>
  58. <p>
  59. Creates a new [name].
  60. </p>
  61. <h2>Properties</h2>
  62. <p>See the base [page:Loader] class for common properties.</p>
  63. <h2>Methods</h2>
  64. <p>See the base [page:Loader] class for common methods.</p>
  65. <h3>[method:DataTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  66. <p>
  67. [page:String url] — A string containing the path/URL of the `.tga` file. <br />
  68. [page:Function onLoad] — (optional) A function to be called after loading is successfully completed. The function receives loaded [page:DataTexture] as an argument.<br />
  69. [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. If the server does not set the Content-Length header; .[page:Integer total] will be 0.<br />
  70. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br />
  71. </p>
  72. <p>
  73. 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).
  74. </p>
  75. <h2>Source</h2>
  76. <p>
  77. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/TGALoader.js examples/jsm/loaders/TGALoader.js]
  78. </p>
  79. </body>
  80. </html>