KTX2Loader.html 4.2 KB

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