babylon.digitalRainPostProcess.d.ts 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. declare module BABYLON {
  2. /**
  3. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  4. *
  5. * It basically takes care rendering the font front the given font size to a texture.
  6. * This is used later on in the postprocess.
  7. */
  8. class DigitalRainFontTexture extends BaseTexture {
  9. private _font;
  10. private _text;
  11. private _charSize;
  12. /**
  13. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  14. */
  15. readonly charSize: number;
  16. /**
  17. * Create a new instance of the Digital Rain FontTexture class
  18. * @param name the name of the texture
  19. * @param font the font to use, use the W3C CSS notation
  20. * @param text the caracter set to use in the rendering.
  21. * @param scene the scene that owns the texture
  22. */
  23. constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
  24. /**
  25. * Gets the max char width of a font.
  26. * @param font the font to use, use the W3C CSS notation
  27. * @return the max char width
  28. */
  29. private getFontWidth(font);
  30. /**
  31. * Gets the max char height of a font.
  32. * @param font the font to use, use the W3C CSS notation
  33. * @return the max char height
  34. */
  35. private getFontHeight(font);
  36. /**
  37. * Clones the current DigitalRainFontTexture.
  38. * @return the clone of the texture.
  39. */
  40. clone(): DigitalRainFontTexture;
  41. /**
  42. * Parses a json object representing the texture and returns an instance of it.
  43. * @param source the source JSON representation
  44. * @param scene the scene to create the texture for
  45. * @return the parsed texture
  46. */
  47. static Parse(source: any, scene: Scene): DigitalRainFontTexture;
  48. }
  49. /**
  50. * Option available in the Digital Rain Post Process.
  51. */
  52. interface IDigitalRainPostProcessOptions {
  53. /**
  54. * The font to use following the w3c font definition.
  55. */
  56. font?: string;
  57. /**
  58. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  59. * This number is defined between 0 and 1;
  60. */
  61. mixToTile?: number;
  62. /**
  63. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64. * This number is defined between 0 and 1;
  65. */
  66. mixToNormal?: number;
  67. }
  68. /**
  69. * DigitalRainPostProcess helps rendering everithing in digital rain.
  70. *
  71. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73. */
  74. class DigitalRainPostProcess extends PostProcess {
  75. /**
  76. * The font texture used to render the char in the post process.
  77. */
  78. private _digitalRainFontTexture;
  79. /**
  80. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  81. * This number is defined between 0 and 1;
  82. */
  83. mixToTile: number;
  84. /**
  85. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86. * This number is defined between 0 and 1;
  87. */
  88. mixToNormal: number;
  89. /**
  90. * Instantiates a new Digital Rain Post Process.
  91. * @param name the name to give to the postprocess
  92. * @camera the camera to apply the post process to.
  93. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  94. */
  95. constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions);
  96. }
  97. }