KTX2Loader.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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">
  13. Loader for KTX 2.0 GPU Texture containers.<br><br>
  14. [link:http://github.khronos.org/KTX-Specification/ KTX 2.0] is a container format for various GPU texture formats. The loader
  15. supports Basis Universal GPU textures, which can be quickly transcoded to
  16. a wide variety of GPU texture compression formats. While KTX 2.0 also allows
  17. other hardware-specific formats, this loader does not yet parse them.
  18. </p>
  19. <p>
  20. This loader parses the KTX 2.0 container and then relies on
  21. [page:BasisTextureLoader] to complete the transcoding process.
  22. The required WASM transcoder and JS wrapper are available from the
  23. [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/basis examples/js/libs/basis]
  24. directory.
  25. </p>
  26. <h2>Code Example</h2>
  27. <code>
  28. var ktx2Loader = new THREE.KTX2Loader();
  29. ktx2Loader.setTranscoderPath( 'examples/js/libs/basis/' );
  30. ktx2Loader.detectSupport( renderer );
  31. ktx2Loader.load( 'diffuse.ktx2', function ( texture ) {
  32. var material = new THREE.MeshStandardMaterial( { map: texture } );
  33. }, function () {
  34. console.log( 'onProgress' );
  35. }, function ( e ) {
  36. console.error( e );
  37. } );
  38. </code>
  39. <h2>Examples</h2>
  40. <p>
  41. [example:webgl_loader_texture_ktx2]
  42. </p>
  43. <h2>Browser compatibility</h2>
  44. <p>
  45. See notes for [page:BasisTextureLoader]. This loader relies on ES6 Promises and Web Assembly, which are not
  46. supported in IE11.
  47. </p>
  48. <br>
  49. <hr>
  50. <h2>Constructor</h2>
  51. <h3>[name]( [param:LoadingManager manager] )</h3>
  52. <p>
  53. [page:LoadingManager manager] — The [page:LoadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  54. </p>
  55. <p>
  56. Creates a new [name].
  57. </p>
  58. <h2>Properties</h2>
  59. <p>See the base [page:Loader] class for common properties.</p>
  60. <h2>Methods</h2>
  61. <p>See the base [page:Loader] class for common methods.</p>
  62. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  63. <p>
  64. [page:String url] — A string containing the path/URL of the <em>.basis</em> file.<br />
  65. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  66. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  67. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  68. </p>
  69. <p>
  70. Load from url and call the <em>onLoad</em> function with the transcoded [page:CompressedTexture].
  71. </p>
  72. <h3>[method:this detectSupport]( [param:WebGLRenderer renderer] )</h3>
  73. <p>
  74. [page:WebGLRenderer renderer] — A renderer instance.
  75. </p>
  76. <p>
  77. Detects hardware support for available compressed texture formats, to determine
  78. the output format for the transcoder. Must be called before loading a texture.
  79. </p>
  80. <h3>[method:this setTranscoderPath]( [param:String path] )</h3>
  81. <p>
  82. [page:String path] — Path to folder containing the WASM transcoder and JS wrapper.
  83. </p>
  84. <p>
  85. The WASM transcoder and JS wrapper are available from the
  86. [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/basis examples/js/libs/basis]
  87. directory.
  88. </p>
  89. <h3>[method:this setWorkerLimit]( [param:Number limit] )</h3>
  90. <p>
  91. [page:Number limit] — Maximum number of workers. Default is '4'.
  92. </p>
  93. <p>
  94. Sets the maximum number of web workers to be allocated by this instance.
  95. </p>
  96. <h3>[method:this dispose]()</h3>
  97. <p>
  98. Disposes the loader object, de-allocating any Web Workers created.
  99. </p>
  100. <h2>Source</h2>
  101. <p>
  102. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/KTX2Loader.js examples/jsm/loaders/KTX2Loader.js]
  103. </p>
  104. </body>
  105. </html>