textureTools.d.ts 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import type { BaseTexture } from "../Materials/Textures/baseTexture.js";
  2. import type { InternalTexture } from "../Materials/Textures/internalTexture";
  3. import { Texture } from "../Materials/Textures/texture";
  4. import type { Scene } from "../scene";
  5. /**
  6. * Uses the GPU to create a copy texture rescaled at a given size
  7. * @param texture Texture to copy from
  8. * @param width defines the desired width
  9. * @param height defines the desired height
  10. * @param useBilinearMode defines if bilinear mode has to be used
  11. * @returns the generated texture
  12. */
  13. export declare function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  14. /**
  15. * Apply a post process to a texture
  16. * @param postProcessName name of the fragment post process
  17. * @param internalTexture the texture to encode
  18. * @param scene the scene hosting the texture
  19. * @param type type of the output texture. If not provided, use the one from internalTexture
  20. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  21. * @param format format of the output texture. If not provided, use the one from internalTexture
  22. * @param width width of the output texture. If not provided, use the one from internalTexture
  23. * @param height height of the output texture. If not provided, use the one from internalTexture
  24. * @returns a promise with the internalTexture having its texture replaced by the result of the processing
  25. */
  26. export declare function ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number, width?: number, height?: number): Promise<InternalTexture>;
  27. /**
  28. * Converts a number to half float
  29. * @param value number to convert
  30. * @returns converted number
  31. */
  32. export declare function ToHalfFloat(value: number): number;
  33. /**
  34. * Converts a half float to a number
  35. * @param value half float to convert
  36. * @returns converted half float
  37. */
  38. export declare function FromHalfFloat(value: number): number;
  39. /**
  40. * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.
  41. * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.
  42. * @param texture the source texture
  43. * @param width the width of the result, which does not have to match the source texture width
  44. * @param height the height of the result, which does not have to match the source texture height
  45. * @param face if the texture has multiple faces, the face index to use for the source
  46. * @param lod if the texture has multiple LODs, the lod index to use for the source
  47. * @returns the 8-bit texture data
  48. */
  49. export declare function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face?: number, lod?: number): Promise<Uint8Array>;
  50. /**
  51. * Class used to host texture specific utilities
  52. */
  53. export declare const TextureTools: {
  54. /**
  55. * Uses the GPU to create a copy texture rescaled at a given size
  56. * @param texture Texture to copy from
  57. * @param width defines the desired width
  58. * @param height defines the desired height
  59. * @param useBilinearMode defines if bilinear mode has to be used
  60. * @returns the generated texture
  61. */
  62. CreateResizedCopy: typeof CreateResizedCopy;
  63. /**
  64. * Apply a post process to a texture
  65. * @param postProcessName name of the fragment post process
  66. * @param internalTexture the texture to encode
  67. * @param scene the scene hosting the texture
  68. * @param type type of the output texture. If not provided, use the one from internalTexture
  69. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  70. * @param format format of the output texture. If not provided, use the one from internalTexture
  71. * @returns a promise with the internalTexture having its texture replaced by the result of the processing
  72. */
  73. ApplyPostProcess: typeof ApplyPostProcess;
  74. /**
  75. * Converts a number to half float
  76. * @param value number to convert
  77. * @returns converted number
  78. */
  79. ToHalfFloat: typeof ToHalfFloat;
  80. /**
  81. * Converts a half float to a number
  82. * @param value half float to convert
  83. * @returns converted half float
  84. */
  85. FromHalfFloat: typeof FromHalfFloat;
  86. /**
  87. * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.
  88. * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.
  89. * @param texture the source texture
  90. * @param width the width of the result, which does not have to match the source texture width
  91. * @param height the height of the result, which does not have to match the source texture height
  92. * @param face if the texture has multiple faces, the face index to use for the source
  93. * @param channels a filter for which of the RGBA channels to return in the result
  94. * @param lod if the texture has multiple LODs, the lod index to use for the source
  95. * @returns the 8-bit texture data
  96. */
  97. GetTextureDataAsync: typeof GetTextureDataAsync;
  98. };