babylon.brickProceduralTexture.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class BrickProceduralTexture extends ProceduralTexture {
  4. private _numberOfBricksHeight: number = 15;
  5. private _numberOfBricksWidth: number = 5;
  6. private _jointColor = new Color3(0.72, 0.72, 0.72);
  7. private _brickColor = new Color3(0.77, 0.47, 0.40);
  8. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
  9. super(name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps);
  10. this.updateShaderUniforms();
  11. this.refreshRate = 0;
  12. }
  13. public updateShaderUniforms() {
  14. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  15. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  16. this.setColor3("brickColor", this._brickColor);
  17. this.setColor3("jointColor", this._jointColor);
  18. }
  19. public get numberOfBricksHeight(): number {
  20. return this._numberOfBricksHeight;
  21. }
  22. public set numberOfBricksHeight(value: number) {
  23. this._numberOfBricksHeight = value;
  24. this.updateShaderUniforms();
  25. }
  26. public get numberOfBricksWidth(): number {
  27. return this._numberOfBricksWidth;
  28. }
  29. public set numberOfBricksWidth(value: number) {
  30. this._numberOfBricksWidth = value;
  31. this.updateShaderUniforms();
  32. }
  33. public get jointColor(): Color3 {
  34. return this._jointColor;
  35. }
  36. public set jointColor(value: Color3) {
  37. this._jointColor = value;
  38. this.updateShaderUniforms();
  39. }
  40. public get brickColor(): Color3 {
  41. return this._brickColor;
  42. }
  43. public set brickColor(value: Color3) {
  44. this._brickColor = value;
  45. this.updateShaderUniforms();
  46. }
  47. }
  48. }