TGALoader.html 2.3 KB

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