babylon.woodProceduralTexture.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class WoodProceduralTexture extends ProceduralTexture {
  4. private _ampScale: number = 100.0;
  5. private _woodColor: Color3 = new Color3(0.32, 0.17, 0.09);
  6. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
  7. super(name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps);
  8. this.updateShaderUniforms();
  9. }
  10. public updateShaderUniforms() {
  11. this.setFloat("ampScale", this._ampScale);
  12. this.setColor3("woodColor", this._woodColor);
  13. }
  14. @serialize()
  15. public get ampScale(): number {
  16. return this._ampScale;
  17. }
  18. public set ampScale(value: number) {
  19. this._ampScale = value;
  20. this.updateShaderUniforms();
  21. }
  22. @serializeAsColor3()
  23. public get woodColor(): Color3 {
  24. return this._woodColor;
  25. }
  26. public set woodColor(value: Color3) {
  27. this._woodColor = value;
  28. this.updateShaderUniforms();
  29. }
  30. /**
  31. * Serializes this wood procedural texture
  32. * @returns a serialized wood procedural texture object
  33. */
  34. public serialize(): any {
  35. var serializationObject = SerializationHelper.Serialize(this, super.serialize());
  36. serializationObject.customType = "BABYLON.WoodProceduralTexture";
  37. return serializationObject;
  38. }
  39. /**
  40. * Creates a Wood Procedural Texture from parsed wood procedural texture data
  41. * @param parsedTexture defines parsed texture data
  42. * @param scene defines the current scene
  43. * @param rootUrl defines the root URL containing wood procedural texture information
  44. * @returns a parsed Wood Procedural Texture
  45. */
  46. public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): WoodProceduralTexture {
  47. var texture = SerializationHelper.Parse(() => new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
  48. return texture;
  49. }
  50. }
  51. }