KTX2Loader.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. This loader relies on Web Assembly which is not supported in older browsers.
  45. </p>
  46. <br>
  47. <hr>
  48. <h2>Constructor</h2>
  49. <h3>[name]( [param:LoadingManager manager] )</h3>
  50. <p>
  51. [page:LoadingManager manager] — The [page:LoadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  52. </p>
  53. <p>
  54. Creates a new [name].
  55. </p>
  56. <h2>Properties</h2>
  57. <p>See the base [page:Loader] class for common properties.</p>
  58. <h2>Methods</h2>
  59. <p>See the base [page:Loader] class for common methods.</p>
  60. <h3>[method:CompressedTexture load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  61. <p>
  62. [page:String url] — A string containing the path/URL of the `.basis` file.<br />
  63. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  64. [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 />
  65. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  66. </p>
  67. <p>
  68. Load from url and call the `onLoad` function with the transcoded [page:CompressedTexture].
  69. </p>
  70. <h3>[method:this detectSupport]( [param:WebGLRenderer renderer] )</h3>
  71. <p>
  72. [page:WebGLRenderer renderer] — A renderer instance.
  73. </p>
  74. <p>
  75. Detects hardware support for available compressed texture formats, to determine
  76. the output format for the transcoder. Must be called before loading a texture.
  77. </p>
  78. <h3>[method:this setTranscoderPath]( [param:String path] )</h3>
  79. <p>
  80. [page:String path] — Path to folder containing the WASM transcoder and JS wrapper.
  81. </p>
  82. <p>
  83. The WASM transcoder and JS wrapper are available from the
  84. [link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/libs/basis examples/jsm/libs/basis]
  85. directory.
  86. </p>
  87. <h3>[method:this setWorkerLimit]( [param:Number limit] )</h3>
  88. <p>
  89. [page:Number limit] — Maximum number of workers. Default is '4'.
  90. </p>
  91. <p>
  92. Sets the maximum number of web workers to be allocated by this instance.
  93. </p>
  94. <h3>[method:this dispose]()</h3>
  95. <p>
  96. Disposes the loader object, de-allocating any Web Workers created.
  97. </p>
  98. <h2>Source</h2>
  99. <p>
  100. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/KTX2Loader.js examples/jsm/loaders/KTX2Loader.js]
  101. </p>
  102. </body>
  103. </html>