BasisTextureLoader.html 4.5 KB

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