TGALoader.html 2.3 KB

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