babylon.asciiArtPostProcess.d.ts 3.9 KB

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