basis.d.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { InternalTexture } from "../Materials/Textures/internalTexture";
  2. import type { Engine } from "../Engines/engine";
  3. /**
  4. * Info about the .basis files
  5. */
  6. export declare class BasisFileInfo {
  7. /**
  8. * If the file has alpha
  9. */
  10. hasAlpha: boolean;
  11. /**
  12. * Info about each image of the basis file
  13. */
  14. images: Array<{
  15. levels: Array<{
  16. width: number;
  17. height: number;
  18. transcodedPixels: ArrayBufferView;
  19. }>;
  20. }>;
  21. }
  22. /**
  23. * Result of transcoding a basis file
  24. */
  25. declare class TranscodeResult {
  26. /**
  27. * Info about the .basis file
  28. */
  29. fileInfo: BasisFileInfo;
  30. /**
  31. * Format to use when loading the file
  32. */
  33. format: number;
  34. }
  35. /**
  36. * Configuration options for the Basis transcoder
  37. */
  38. export declare class BasisTranscodeConfiguration {
  39. /**
  40. * Supported compression formats used to determine the supported output format of the transcoder
  41. */
  42. supportedCompressionFormats?: {
  43. /**
  44. * etc1 compression format
  45. */
  46. etc1?: boolean;
  47. /**
  48. * s3tc compression format
  49. */
  50. s3tc?: boolean;
  51. /**
  52. * pvrtc compression format
  53. */
  54. pvrtc?: boolean;
  55. /**
  56. * etc2 compression format
  57. */
  58. etc2?: boolean;
  59. /**
  60. * astc compression format
  61. */
  62. astc?: boolean;
  63. /**
  64. * bc7 compression format
  65. */
  66. bc7?: boolean;
  67. };
  68. /**
  69. * If mipmap levels should be loaded for transcoded images (Default: true)
  70. */
  71. loadMipmapLevels?: boolean;
  72. /**
  73. * Index of a single image to load (Default: all images)
  74. */
  75. loadSingleImage?: number;
  76. }
  77. /**
  78. * Used to load .Basis files
  79. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  80. */
  81. export declare const BasisToolsOptions: {
  82. /**
  83. * URL to use when loading the basis transcoder
  84. */
  85. JSModuleURL: string;
  86. /**
  87. * URL to use when loading the wasm module for the transcoder
  88. */
  89. WasmModuleURL: string;
  90. };
  91. /**
  92. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  93. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  94. * @param engine
  95. * @returns internal format corresponding to the Basis format
  96. */
  97. export declare const GetInternalFormatFromBasisFormat: (basisFormat: number, engine: Engine) => number;
  98. /**
  99. * Set the worker to use for transcoding
  100. * @param worker The worker that will be used for transcoding
  101. */
  102. export declare const SetBasisTranscoderWorker: (worker: Worker) => void;
  103. /**
  104. * Transcodes a loaded image file to compressed pixel data
  105. * @param data image data to transcode
  106. * @param config configuration options for the transcoding
  107. * @returns a promise resulting in the transcoded image
  108. */
  109. export declare const TranscodeAsync: (data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration) => Promise<TranscodeResult>;
  110. /**
  111. * Loads a texture from the transcode result
  112. * @param texture texture load to
  113. * @param transcodeResult the result of transcoding the basis file to load from
  114. */
  115. export declare const LoadTextureFromTranscodeResult: (texture: InternalTexture, transcodeResult: TranscodeResult) => void;
  116. /**
  117. * Used to load .Basis files
  118. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119. */
  120. export declare const BasisTools: {
  121. /**
  122. * URL to use when loading the basis transcoder
  123. */
  124. JSModuleURL: string;
  125. /**
  126. * URL to use when loading the wasm module for the transcoder
  127. */
  128. WasmModuleURL: string;
  129. /**
  130. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  131. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  132. * @returns internal format corresponding to the Basis format
  133. */
  134. GetInternalFormatFromBasisFormat: (basisFormat: number, engine: Engine) => number;
  135. /**
  136. * Transcodes a loaded image file to compressed pixel data
  137. * @param data image data to transcode
  138. * @param config configuration options for the transcoding
  139. * @returns a promise resulting in the transcoded image
  140. */
  141. TranscodeAsync: (data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration) => Promise<TranscodeResult>;
  142. /**
  143. * Loads a texture from the transcode result
  144. * @param texture texture load to
  145. * @param transcodeResult the result of transcoding the basis file to load from
  146. */
  147. LoadTextureFromTranscodeResult: (texture: InternalTexture, transcodeResult: TranscodeResult) => void;
  148. };
  149. export {};