TGALoader.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <em>.tga</em> [page:DataTexture texture].</div>
  13. <h2>Constructor</h2>
  14. <h3>[name]( [page:LoadingManager manager] )</h3>
  15. <div>
  16. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  17. </div>
  18. <div>
  19. Creates a new [name].
  20. </div>
  21. <h2>Methods</h2>
  22. <h3>[method:DataTexture load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  23. <div>
  24. [page:String url] — required<br />
  25. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:DataTexture].<br />
  26. [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 />
  27. [page:Function onError] — Will be called when load errors.<br />
  28. </div>
  29. <div>
  30. 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).
  31. </div>
  32. <h2>Example</h2>
  33. <code>
  34. // instantiate a loader
  35. var loader = new THREE.TGALoader();
  36. // load a resource
  37. var texture = loader.load(
  38. // resource URL
  39. 'textures/crate_grey8.tga'
  40. // Function when resource is loaded
  41. function ( texture ) {
  42. console.log( 'Texture is loaded' );
  43. },
  44. // Function called when download progresses
  45. function ( xhr ) {
  46. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  47. },
  48. // Function called when download errors
  49. function ( xhr ) {
  50. console.log( 'An error happened' );
  51. }
  52. );
  53. var material = new THREE.MeshPhongMaterial( {
  54. color: 0xffffff,
  55. map: texture
  56. } );
  57. </code>
  58. [example:webgl_materials_texture_tga]
  59. <h2>Source</h2>
  60. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/TGALoader.js examples/js/loaders/TGALoader.js]
  61. </body>
  62. </html>