Sfoglia il codice sorgente

Merge pull request #4479 from julien-moreau/master

Fixing some serialization issues with procedural textures library
David Catuhe 7 anni fa
parent
commit
0c4b1b484f

+ 21 - 1
proceduralTexturesLibrary/src/fire/babylon.fireProceduralTexture.ts

@@ -79,7 +79,15 @@ module BABYLON {
             ];
         }
 
-        @serializeAsColor3()
+        @serialize()
+        public get autoGenerateTime(): boolean {
+            return this._autoGenerateTime;
+        }
+
+        public set autoGenerateTime(value: boolean) {
+            this._autoGenerateTime = value;
+        }
+        
         public get fireColors(): Color3[] {
             return this._fireColors;
         }
@@ -127,6 +135,11 @@ module BABYLON {
             var serializationObject = SerializationHelper.Serialize(this, super.serialize());
             serializationObject.customType = "BABYLON.FireProceduralTexture";
 
+            serializationObject.fireColors = [];
+            for (var i = 0; i < this._fireColors.length; i++) {
+                serializationObject.fireColors.push(this._fireColors[i].asArray());
+            }
+
             return serializationObject;
         }
 
@@ -140,6 +153,13 @@ module BABYLON {
         public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): FireProceduralTexture {
             var texture = SerializationHelper.Parse(() => new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
 
+            var colors: Color3[] = [];
+            for (var i = 0; i < parsedTexture.fireColors.length; i++) {
+                colors.push(Color3.FromArray(parsedTexture.fireColors[i]));
+            }
+
+            texture.fireColors = colors;
+
             return texture;
         }
     }

+ 12 - 1
proceduralTexturesLibrary/src/grass/babylon.grassProceduralTexture.ts

@@ -24,7 +24,6 @@ module BABYLON {
             this.setColor3("groundColor", this._groundColor);
         }
 
-        @serializeAsColor3()
         public get grassColors(): Color3[] {
             return this._grassColors;
         }
@@ -52,6 +51,11 @@ module BABYLON {
             var serializationObject = SerializationHelper.Serialize(this, super.serialize());
             serializationObject.customType = "BABYLON.GrassProceduralTexture";
 
+            serializationObject.grassColors = [];
+            for (var i = 0; i < this._grassColors.length; i++) {
+                serializationObject.grassColors.push(this._grassColors[i].asArray());
+            }
+
             return serializationObject;
         }
 
@@ -65,6 +69,13 @@ module BABYLON {
         public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): GrassProceduralTexture {
             var texture = SerializationHelper.Parse(() => new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps), parsedTexture, scene, rootUrl);
 
+            var colors: Color3[] = [];
+            for (var i = 0; i < parsedTexture.grassColors.length; i++) {
+                colors.push(Color3.FromArray(parsedTexture.grassColors[i]));
+            }
+
+            texture.grassColors = colors;
+
             return texture;
         }
     }

+ 2 - 2
proceduralTexturesLibrary/src/perlinNoise/babylon.perlinNoiseProceduralTexture.ts

@@ -6,7 +6,7 @@ module BABYLON {
         public time: number = 0.0;
 
         @serialize()
-        public speed: number = 1.0;
+        public timeScale: number = 1.0;
 
         @serialize()
         public translationSpeed: number = 1.0;
@@ -29,7 +29,7 @@ module BABYLON {
             var deltaTime = scene.getEngine().getDeltaTime();
 
             this.time += deltaTime;
-            this.setFloat("time", this.time * this.speed / 1000);
+            this.setFloat("time", this.time * this.timeScale / 1000);
 
             this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
             this.setFloat("translationSpeed", this._currentTranslation);