babylon.marbleProceduralTexture.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class MarbleProceduralTexture extends ProceduralTexture {
  4. private _numberOfTilesHeight: number = 3;
  5. private _numberOfTilesWidth: number = 3;
  6. private _amplitude: number = 9.0;
  7. private _marbleColor = new Color3(0.77, 0.47, 0.40);
  8. private _jointColor = new Color3(0.72, 0.72, 0.72);
  9. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
  10. super(name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps);
  11. this.updateShaderUniforms();
  12. }
  13. public updateShaderUniforms() {
  14. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  15. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  16. this.setFloat("amplitude", this._amplitude);
  17. this.setColor3("marbleColor", this._marbleColor);
  18. this.setColor3("jointColor", this._jointColor);
  19. }
  20. public get numberOfTilesHeight(): number {
  21. return this._numberOfTilesHeight;
  22. }
  23. public set numberOfTilesHeight(value: number) {
  24. this._numberOfTilesHeight = value;
  25. this.updateShaderUniforms();
  26. }
  27. public get amplitude(): number {
  28. return this._amplitude;
  29. }
  30. public set amplitude(value: number) {
  31. this._amplitude = value;
  32. this.updateShaderUniforms();
  33. }
  34. public get numberOfTilesWidth(): number {
  35. return this._numberOfTilesWidth;
  36. }
  37. public set numberOfTilesWidth(value: number) {
  38. this._numberOfTilesWidth = value;
  39. this.updateShaderUniforms();
  40. }
  41. public get jointColor(): Color3 {
  42. return this._jointColor;
  43. }
  44. public set jointColor(value: Color3) {
  45. this._jointColor = value;
  46. this.updateShaderUniforms();
  47. }
  48. public get marbleColor(): Color3 {
  49. return this._marbleColor;
  50. }
  51. public set marbleColor(value: Color3) {
  52. this._marbleColor = value;
  53. this.updateShaderUniforms();
  54. }
  55. }
  56. }