internalTexture.d.ts 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import { Observable } from "../../Misc/observable";
  2. import type { ImageSource, Nullable, int } from "../../types";
  3. import type { ICanvas, ICanvasRenderingContext } from "../../Engines/ICanvas";
  4. import type { HardwareTextureWrapper } from "./hardwareTextureWrapper";
  5. import { TextureSampler } from "./textureSampler";
  6. import type { AbstractEngine } from "../../Engines/abstractEngine";
  7. import type { BaseTexture } from "../../Materials/Textures/baseTexture";
  8. import type { SphericalPolynomial } from "../../Maths/sphericalPolynomial";
  9. /**
  10. * Defines the source of the internal texture
  11. */
  12. export declare enum InternalTextureSource {
  13. /**
  14. * The source of the texture data is unknown
  15. */
  16. Unknown = 0,
  17. /**
  18. * Texture data comes from an URL
  19. */
  20. Url = 1,
  21. /**
  22. * Texture data is only used for temporary storage
  23. */
  24. Temp = 2,
  25. /**
  26. * Texture data comes from raw data (ArrayBuffer)
  27. */
  28. Raw = 3,
  29. /**
  30. * Texture content is dynamic (video or dynamic texture)
  31. */
  32. Dynamic = 4,
  33. /**
  34. * Texture content is generated by rendering to it
  35. */
  36. RenderTarget = 5,
  37. /**
  38. * Texture content is part of a multi render target process
  39. */
  40. MultiRenderTarget = 6,
  41. /**
  42. * Texture data comes from a cube data file
  43. */
  44. Cube = 7,
  45. /**
  46. * Texture data comes from a raw cube data
  47. */
  48. CubeRaw = 8,
  49. /**
  50. * Texture data come from a prefiltered cube data file
  51. */
  52. CubePrefiltered = 9,
  53. /**
  54. * Texture content is raw 3D data
  55. */
  56. Raw3D = 10,
  57. /**
  58. * Texture content is raw 2D array data
  59. */
  60. Raw2DArray = 11,
  61. /**
  62. * Texture content is a depth/stencil texture
  63. */
  64. DepthStencil = 12,
  65. /**
  66. * Texture data comes from a raw cube data encoded with RGBD
  67. */
  68. CubeRawRGBD = 13,
  69. /**
  70. * Texture content is a depth texture
  71. */
  72. Depth = 14
  73. }
  74. /**
  75. * Class used to store data associated with WebGL texture data for the engine
  76. * This class should not be used directly
  77. */
  78. export declare class InternalTexture extends TextureSampler {
  79. /**
  80. * Defines if the texture is ready
  81. */
  82. isReady: boolean;
  83. /**
  84. * Defines if the texture is a cube texture
  85. */
  86. isCube: boolean;
  87. /**
  88. * Defines if the texture contains 3D data
  89. */
  90. is3D: boolean;
  91. /**
  92. * Defines if the texture contains 2D array data
  93. */
  94. is2DArray: boolean;
  95. /**
  96. * Defines if the texture contains multiview data
  97. */
  98. isMultiview: boolean;
  99. /**
  100. * Gets the URL used to load this texture
  101. */
  102. url: string;
  103. /** @internal */
  104. _originalUrl: string;
  105. /**
  106. * Gets a boolean indicating if the texture needs mipmaps generation
  107. */
  108. generateMipMaps: boolean;
  109. /**
  110. * Gets a boolean indicating if the texture uses mipmaps
  111. * TODO implements useMipMaps as a separate setting from generateMipMaps
  112. */
  113. get useMipMaps(): boolean;
  114. set useMipMaps(value: boolean);
  115. /**
  116. * Gets the number of samples used by the texture (WebGL2+ only)
  117. */
  118. samples: number;
  119. /**
  120. * Gets the type of the texture (int, float...)
  121. */
  122. type: number;
  123. /**
  124. * Gets the format of the texture (RGB, RGBA...)
  125. */
  126. format: number;
  127. /**
  128. * Observable called when the texture is loaded
  129. */
  130. onLoadedObservable: Observable<InternalTexture>;
  131. /**
  132. * Observable called when the texture load is raising an error
  133. */
  134. onErrorObservable: Observable<Partial<{
  135. message: string;
  136. exception: any;
  137. }>>;
  138. /**
  139. * If this callback is defined it will be called instead of the default _rebuild function
  140. */
  141. onRebuildCallback: Nullable<(internalTexture: InternalTexture) => {
  142. proxy: Nullable<InternalTexture | Promise<InternalTexture>>;
  143. isReady: boolean;
  144. isAsync: boolean;
  145. }>;
  146. /**
  147. * Gets the width of the texture
  148. */
  149. width: number;
  150. /**
  151. * Gets the height of the texture
  152. */
  153. height: number;
  154. /**
  155. * Gets the depth of the texture
  156. */
  157. depth: number;
  158. /**
  159. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  160. */
  161. baseWidth: number;
  162. /**
  163. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  164. */
  165. baseHeight: number;
  166. /**
  167. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  168. */
  169. baseDepth: number;
  170. /**
  171. * Gets a boolean indicating if the texture is inverted on Y axis
  172. */
  173. invertY: boolean;
  174. /** @internal */
  175. _invertVScale: boolean;
  176. /** @internal */
  177. _associatedChannel: number;
  178. /** @internal */
  179. _source: InternalTextureSource;
  180. /** @internal */
  181. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  182. /** @internal */
  183. _bufferView: Nullable<ArrayBufferView>;
  184. /** @internal */
  185. _bufferViewArray: Nullable<ArrayBufferView[]>;
  186. /** @internal */
  187. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  188. /** @internal */
  189. _size: number;
  190. /** @internal */
  191. _extension: string;
  192. /** @internal */
  193. _files: Nullable<string[]>;
  194. /** @internal */
  195. _workingCanvas: Nullable<ICanvas>;
  196. /** @internal */
  197. _workingContext: Nullable<ICanvasRenderingContext>;
  198. /** @internal */
  199. _cachedCoordinatesMode: Nullable<number>;
  200. /** @internal */
  201. _isDisabled: boolean;
  202. /** @internal */
  203. _compression: Nullable<string>;
  204. /** @internal */
  205. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  206. /** @internal */
  207. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  208. /** @internal */
  209. _sphericalPolynomialComputed: boolean;
  210. /** @internal */
  211. _lodGenerationScale: number;
  212. /** @internal */
  213. _lodGenerationOffset: number;
  214. /** @internal */
  215. _useSRGBBuffer: boolean;
  216. /** @internal */
  217. _creationFlags: number;
  218. /** @internal */
  219. _originalFormat?: number;
  220. /** @internal */
  221. _lodTextureHigh: Nullable<BaseTexture>;
  222. /** @internal */
  223. _lodTextureMid: Nullable<BaseTexture>;
  224. /** @internal */
  225. _lodTextureLow: Nullable<BaseTexture>;
  226. /** @internal */
  227. _isRGBD: boolean;
  228. /** @internal */
  229. _linearSpecularLOD: boolean;
  230. /** @internal */
  231. _irradianceTexture: Nullable<BaseTexture>;
  232. /** @internal */
  233. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  234. /** @internal */
  235. _maxLodLevel: Nullable<number>;
  236. /** @internal */
  237. _references: number;
  238. /** @internal */
  239. _gammaSpace: Nullable<boolean>;
  240. /** @internal */
  241. _premulAlpha: boolean;
  242. /** @internal */
  243. _dynamicTextureSource: Nullable<ImageSource>;
  244. private _engine;
  245. private _uniqueId;
  246. /** @internal */
  247. static _Counter: number;
  248. /** Gets the unique id of the internal texture */
  249. get uniqueId(): number;
  250. /** @internal */
  251. _setUniqueId(id: number): void;
  252. /**
  253. * Gets the Engine the texture belongs to.
  254. * @returns The babylon engine
  255. */
  256. getEngine(): AbstractEngine;
  257. /**
  258. * Gets the data source type of the texture
  259. */
  260. get source(): InternalTextureSource;
  261. /**
  262. * Creates a new InternalTexture
  263. * @param engine defines the engine to use
  264. * @param source defines the type of data that will be used
  265. * @param delayAllocation if the texture allocation should be delayed (default: false)
  266. */
  267. constructor(engine: AbstractEngine, source: InternalTextureSource, delayAllocation?: boolean);
  268. /**
  269. * Increments the number of references (ie. the number of Texture that point to it)
  270. */
  271. incrementReferences(): void;
  272. /**
  273. * Change the size of the texture (not the size of the content)
  274. * @param width defines the new width
  275. * @param height defines the new height
  276. * @param depth defines the new depth (1 by default)
  277. */
  278. updateSize(width: int, height: int, depth?: int): void;
  279. /** @internal */
  280. _rebuild(): void;
  281. /**
  282. * @internal
  283. */
  284. _swapAndDie(target: InternalTexture, swapAll?: boolean): void;
  285. /**
  286. * Dispose the current allocated resources
  287. */
  288. dispose(): void;
  289. }