BasisTextureLoader.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. Loader for Basis Universal GPU Texture Codec.<br><br>
  15. [link:https://github.com/BinomialLLC/basis_universal/ Basis Universal] is a
  16. "supercompressed" GPU texture and texture video compression system that
  17. outputs a highly compressed intermediate file format (.basis) that can be
  18. quickly transcoded to a wide variety of GPU texture compression formats.
  19. </p>
  20. <p>
  21. This loader parallelizes the transcoding process across a configurable number
  22. of web workers, before transferring the transcoded compressed texture back
  23. to the main thread. The required WASM transcoder and JS wrapper are available from the
  24. [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/basis examples/js/libs/basis]
  25. directory.
  26. </p>
  27. <h2>Example</h2>
  28. <code>
  29. var basisLoader = new THREE.BasisTextureLoader();
  30. basisLoader.setTranscoderPath( 'examples/js/libs/basis/' );
  31. basisLoader.detectSupport( renderer );
  32. basisLoader.load( 'diffuse.basis', function ( texture ) {
  33. var material = new THREE.MeshStandardMaterial( { map: texture } );
  34. }, function () {
  35. console.log( 'onProgress' );
  36. }, function ( e ) {
  37. console.error( e );
  38. } );
  39. </code>
  40. [example:webgl_loader_texture_basis]
  41. <h2>Browser compatibility</h2>
  42. <p>
  43. BasisTextureLoader transcodes input textures in '.basis' format to an
  44. appropriate compressed texture format for the target device, where
  45. possible. This allows the same source texture to be served across
  46. desktop, Android, and iOS devices, and transcoded into ASTC, DXT, ETC1,
  47. or PVRTC1. Other output formats may be supported in the future.
  48. </p>
  49. <p>
  50. Transcoding to PVRTC1 (for iOS) requires square power-of-two textures.
  51. </p>
  52. <p>
  53. This loader relies on ES6 Promises and Web Assembly, which are not
  54. supported in IE11.
  55. </p>
  56. <br>
  57. <hr>
  58. <h2>Constructor</h2>
  59. <h3>[name]( [param:LoadingManager manager] )</h3>
  60. <p>
  61. [page:LoadingManager manager] — The [page:LoadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  62. </p>
  63. <p>
  64. Creates a new [name].
  65. </p>
  66. <h2>Properties</h2>
  67. <p>See the base [page:Loader] class for common properties.</p>
  68. <h2>Methods</h2>
  69. <p>See the base [page:Loader] class for common methods.</p>
  70. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  71. <p>
  72. [page:String url] — A string containing the path/URL of the <em>.basis</em> file.<br />
  73. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  74. [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 />
  75. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  76. </p>
  77. <p>
  78. Load from url and call the <em>onLoad</em> function with the transcoded [page:CompressedTexture].
  79. </p>
  80. <h3>[method:this detectSupport]( [param:WebGLRenderer renderer] )</h3>
  81. <p>
  82. [page:WebGLRenderer renderer] — A renderer instance.
  83. </p>
  84. <p>
  85. Detects hardware support for available compressed texture formats, to determine
  86. the output format for the transcoder. Must be called before loading a texture.
  87. </p>
  88. <h3>[method:this setTranscoderPath]( [param:String path] )</h3>
  89. <p>
  90. [page:String path] — Path to folder containing the WASM transcoder and JS wrapper.
  91. </p>
  92. <p>
  93. The WASM transcoder and JS wrapper are available from the
  94. [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/basis examples/js/libs/basis]
  95. directory.
  96. </p>
  97. <h3>[method:this setWorkerLimit]( [param:Number limit] )</h3>
  98. <p>
  99. [page:Number limit] — Maximum number of workers. Default is '4'.
  100. </p>
  101. <p>
  102. Sets the maximum number of web workers to be allocated by this instance.
  103. </p>
  104. <h3>[method:this dispose]()</h3>
  105. <p>
  106. Disposes the loader object, de-allocating any Web Workers created.
  107. </p>
  108. <h2>Source</h2>
  109. <p>
  110. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/BasisTextureLoader.js examples/js/loaders/BasisTextureLoader.js]
  111. </p>
  112. </body>
  113. </html>