babylon.roadProceduralTexture.ts 2.0 KB

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