cubeTexture.d.ts 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import type { Nullable } from "../../types";
  2. import type { Scene } from "../../scene";
  3. import { Matrix, Vector3 } from "../../Maths/math.vector";
  4. import { BaseTexture } from "../../Materials/Textures/baseTexture";
  5. import type { AbstractEngine } from "../../Engines/abstractEngine";
  6. import "../../Engines/AbstractEngine/abstractEngine.cubeTexture";
  7. import "../../Engines/Extensions/engine.cubeTexture";
  8. import { Observable } from "../../Misc/observable";
  9. /**
  10. * Class for creating a cube texture
  11. */
  12. export declare class CubeTexture extends BaseTexture {
  13. private _delayedOnLoad;
  14. private _delayedOnError;
  15. private _lodScale;
  16. private _lodOffset;
  17. /**
  18. * Observable triggered once the texture has been loaded.
  19. */
  20. onLoadObservable: Observable<CubeTexture>;
  21. /**
  22. * The url of the texture
  23. */
  24. url: string;
  25. /**
  26. * Gets or sets the center of the bounding box associated with the cube texture.
  27. * It must define where the camera used to render the texture was set
  28. * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode
  29. */
  30. boundingBoxPosition: Vector3;
  31. private _boundingBoxSize;
  32. /**
  33. * Gets or sets the size of the bounding box associated with the cube texture
  34. * When defined, the cubemap will switch to local mode
  35. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  36. * @example https://www.babylonjs-playground.com/#RNASML
  37. */
  38. set boundingBoxSize(value: Vector3);
  39. /**
  40. * Returns the bounding box size
  41. * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode
  42. */
  43. get boundingBoxSize(): Vector3;
  44. protected _rotationY: number;
  45. /**
  46. * Sets texture matrix rotation angle around Y axis in radians.
  47. */
  48. set rotationY(value: number);
  49. /**
  50. * Gets texture matrix rotation angle around Y axis radians.
  51. */
  52. get rotationY(): number;
  53. /**
  54. * Are mip maps generated for this texture or not.
  55. */
  56. get noMipmap(): boolean;
  57. private _noMipmap;
  58. /** @internal */
  59. _files: Nullable<string[]>;
  60. protected _forcedExtension: Nullable<string>;
  61. /**
  62. * Gets the forced extension (if any)
  63. */
  64. get forcedExtension(): Nullable<string>;
  65. private _extensions;
  66. private _textureMatrix;
  67. private _textureMatrixRefraction;
  68. private _format;
  69. private _createPolynomials;
  70. private _loaderOptions;
  71. private _useSRGBBuffer?;
  72. /**
  73. * Creates a cube texture from an array of image urls
  74. * @param files defines an array of image urls
  75. * @param scene defines the hosting scene
  76. * @param noMipmap specifies if mip maps are not used
  77. * @returns a cube texture
  78. */
  79. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80. /**
  81. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82. * @param url defines the url of the prefiltered texture
  83. * @param scene defines the scene the texture is attached to
  84. * @param forcedExtension defines the extension of the file if different from the url
  85. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86. * @returns the prefiltered texture
  87. */
  88. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  89. /**
  90. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  91. * as prefiltered data.
  92. * @param rootUrl defines the url of the texture or the root name of the six images
  93. * @param sceneOrEngine defines the scene or engine the texture is attached to
  94. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  95. * @param noMipmap defines if mipmaps should be created or not
  96. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  97. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  98. * @param onError defines a callback triggered in case of error during load
  99. * @param format defines the internal format to use for the texture once loaded
  100. * @param prefiltered defines whether or not the texture is created from prefiltered data
  101. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  102. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  103. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  104. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105. * @param loaderOptions options to be passed to the loader
  106. * @param useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false)
  107. * @returns the cube texture
  108. */
  109. constructor(rootUrl: string, sceneOrEngine: Scene | AbstractEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any, useSRGBBuffer?: boolean);
  110. /**
  111. * Get the current class name of the texture useful for serialization or dynamic coding.
  112. * @returns "CubeTexture"
  113. */
  114. getClassName(): string;
  115. /**
  116. * Update the url (and optional buffer) of this texture if url was null during construction.
  117. * @param url the url of the texture
  118. * @param forcedExtension defines the extension to use
  119. * @param onLoad callback called when the texture is loaded (defaults to null)
  120. * @param prefiltered Defines whether the updated texture is prefiltered or not
  121. * @param onError callback called if there was an error during the loading process (defaults to null)
  122. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  123. * @param delayLoad defines if the texture should be loaded now (false by default)
  124. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  125. */
  126. updateURL(url: string, forcedExtension?: string, onLoad?: Nullable<() => void>, prefiltered?: boolean, onError?: Nullable<(message?: string, exception?: any) => void>, extensions?: Nullable<string[]>, delayLoad?: boolean, files?: Nullable<string[]>): void;
  127. /**
  128. * Delays loading of the cube texture
  129. * @param forcedExtension defines the extension to use
  130. */
  131. delayLoad(forcedExtension?: string): void;
  132. /**
  133. * Returns the reflection texture matrix
  134. * @returns the reflection texture matrix
  135. */
  136. getReflectionTextureMatrix(): Matrix;
  137. /**
  138. * Sets the reflection texture matrix
  139. * @param value Reflection texture matrix
  140. */
  141. setReflectionTextureMatrix(value: Matrix): void;
  142. /**
  143. * Gets a suitable rotate/transform matrix when the texture is used for refraction.
  144. * There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.
  145. * @returns The refraction matrix
  146. */
  147. getRefractionTextureMatrix(): Matrix;
  148. private _loadTexture;
  149. /**
  150. * Parses text to create a cube texture
  151. * @param parsedTexture define the serialized text to read from
  152. * @param scene defines the hosting scene
  153. * @param rootUrl defines the root url of the cube texture
  154. * @returns a cube texture
  155. */
  156. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  157. /**
  158. * Makes a clone, or deep copy, of the cube texture
  159. * @returns a new cube texture
  160. */
  161. clone(): CubeTexture;
  162. }