babylon.cloudProceduralTexture.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class CloudProceduralTexture extends ProceduralTexture {
  4. private _skyColor = new Color4(0.15, 0.68, 1.0, 1.0);
  5. private _cloudColor = new Color4(1, 1, 1, 1.0);
  6. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
  7. super(name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps);
  8. this.updateShaderUniforms();
  9. }
  10. public updateShaderUniforms() {
  11. this.setColor4("skyColor", this._skyColor);
  12. this.setColor4("cloudColor", this._cloudColor);
  13. }
  14. @serializeAsColor4()
  15. public get skyColor(): Color4 {
  16. return this._skyColor;
  17. }
  18. public set skyColor(value: Color4) {
  19. this._skyColor = value;
  20. this.updateShaderUniforms();
  21. }
  22. @serializeAsColor4()
  23. public get cloudColor(): Color4 {
  24. return this._cloudColor;
  25. }
  26. public set cloudColor(value: Color4) {
  27. this._cloudColor = value;
  28. this.updateShaderUniforms();
  29. }
  30. /**
  31. * Serializes this cloud procedural texture
  32. * @returns a serialized cloud procedural texture object
  33. */
  34. public serialize(): any {
  35. var serializationObject = SerializationHelper.Serialize(this, super.serialize());
  36. serializationObject.customType = "BABYLON.CloudProceduralTexture";
  37. return serializationObject;
  38. }
  39. /**
  40. * Creates a Cloud Procedural Texture from parsed cloud 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 cloud procedural texture information
  44. * @returns a parsed Cloud Procedural Texture
  45. */
  46. public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CloudProceduralTexture {
  47. var texture = SerializationHelper.Parse(() => new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
  48. return texture;
  49. }
  50. }
  51. }