Bläddra i källkod

Merge pull request #844 from RaananW/materialLibrary-parse

Materiallibrary parse
Raanan Weber 9 år sedan
förälder
incheckning
9b4a8aa337

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 43 - 2
materialsLibrary/dist/babylon.fireMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.fireMaterial.min.js


+ 6 - 5
materialsLibrary/dist/babylon.lavaMaterial.js

@@ -455,7 +455,8 @@ var BABYLON;
         };
         LavaMaterial.prototype.serialize = function () {
             var serializationObject = _super.prototype.serialize.call(this);
-            serializationObject.diffuse = this.diffuseColor.asArray();
+            serializationObject.customType = "lava";
+            serializationObject.diffuseColor = this.diffuseColor.asArray();
             serializationObject.fogColor = this.fogColor.asArray();
             serializationObject.speed = this.speed;
             serializationObject.movingSpeed = this.movingSpeed;
@@ -466,13 +467,13 @@ var BABYLON;
                 serializationObject.diffuseTexture = this.diffuseTexture.serialize();
             }
             if (this.noiseTexture) {
-                serializationObject.diffuseTexture = this.noiseTexture.serialize();
+                serializationObject.noiseTexture = this.noiseTexture.serialize();
             }
             return serializationObject;
         };
         LavaMaterial.Parse = function (source, scene, rootUrl) {
             var material = new LavaMaterial(source.name, scene);
-            material.diffuseColor = BABYLON.Color3.FromArray(source.diffuse);
+            material.diffuseColor = BABYLON.Color3.FromArray(source.diffuseColor);
             material.speed = source.speed;
             material.fogColor = BABYLON.Color3.FromArray(source.fogColor);
             material.movingSpeed = source.movingSpeed;
@@ -484,10 +485,10 @@ var BABYLON;
             material.backFaceCulling = source.backFaceCulling;
             material.wireframe = source.wireframe;
             if (source.diffuseTexture) {
-                material.diffuseTexture = BABYLON.Texture.ParseTexture(source.diffuseTexture, scene, rootUrl);
+                material.diffuseTexture = BABYLON.Texture.Parse(source.diffuseTexture, scene, rootUrl);
             }
             if (source.noiseTexture) {
-                material.noiseTexture = BABYLON.Texture.ParseTexture(source.noiseTexture, scene, rootUrl);
+                material.noiseTexture = BABYLON.Texture.Parse(source.noiseTexture, scene, rootUrl);
             }
             if (source.checkReadyOnlyOnce) {
                 material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.lavaMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 26 - 2
materialsLibrary/dist/babylon.normalMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.normalMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 4
materialsLibrary/dist/babylon.pbrMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 3 - 3
materialsLibrary/dist/babylon.pbrMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 2
materialsLibrary/dist/babylon.simpleMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 66 - 2
materialsLibrary/dist/babylon.terrainMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.terrainMaterial.min.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 51 - 2
materialsLibrary/dist/babylon.waterMaterial.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
materialsLibrary/dist/babylon.waterMaterial.min.js


+ 414 - 357
materialsLibrary/materials/fire/babylon.fireMaterial.ts

@@ -1,357 +1,414 @@
-/// <reference path="../../../dist/preview release/babylon.d.ts"/>
-
-module BABYLON {
-    var maxSimultaneousLights = 4;
-
-    class FireMaterialDefines extends MaterialDefines {
-        public DIFFUSE = false;
-        public CLIPPLANE = false;
-        public ALPHATEST = false;
-        public POINTSIZE = false;
-        public FOG = false;
-        public UV1 = false;
-        public NORMAL = false;
-        public VERTEXCOLOR = false;
-        public VERTEXALPHA = false;
-        public BONES = false;
-        public BONES4 = false;
-        public BonesPerMesh = 0;
-        public INSTANCES = false;
-
-        constructor() {
-            super();
-            this._keys = Object.keys(this);
-        }
-    }
-
-    export class FireMaterial extends Material {
-        public diffuseTexture: BaseTexture;
-        public distortionTexture: BaseTexture;
-        public opacityTexture: BaseTexture;
-
-        public diffuseColor = new Color3(1, 1, 1);
-        public disableLighting = false;
-        
-        public speed = 1.0;
-        
-        private _scaledDiffuse = new Color3();
-        private _renderId: number;
-
-        private _defines = new FireMaterialDefines();
-        private _cachedDefines = new FireMaterialDefines();
-        
-        private _lastTime: number = 0;
-
-        constructor(name: string, scene: Scene) {
-            super(name, scene);
-
-            this._cachedDefines.BonesPerMesh = -1;
-        }
-
-        public needAlphaBlending(): boolean {
-            return (this.alpha < 1.0);
-        }
-
-        public needAlphaTesting(): boolean {
-            return false;
-        }
-
-        public getAlphaTestTexture(): BaseTexture {
-            return null;
-        }
-
-        // Methods   
-        private _checkCache(scene: Scene, mesh?: AbstractMesh, useInstances?: boolean): boolean {
-            if (!mesh) {
-                return true;
-            }
-
-            if (this._defines.INSTANCES !== useInstances) {
-                return false;
-            }
-
-            if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
-                return true;
-            }
-
-            return false;
-        }
-
-        public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
-            if (this.checkReadyOnlyOnce) {
-                if (this._wasPreviouslyReady) {
-                    return true;
-                }
-            }
-
-            var scene = this.getScene();
-
-            if (!this.checkReadyOnEveryCall) {
-                if (this._renderId === scene.getRenderId()) {
-                    if (this._checkCache(scene, mesh, useInstances)) {
-                        return true;
-                    }
-                }
-            }
-
-            var engine = scene.getEngine();
-            var needNormals = false;
-            var needUVs = false;
-
-            this._defines.reset();
-
-            // Textures
-            if (scene.texturesEnabled) {
-                if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
-                    if (!this.diffuseTexture.isReady()) {
-                        return false;
-                    } else {
-                        needUVs = true;
-                        this._defines.DIFFUSE = true;
-                    }
-                }                
-            }
-
-            // Effect
-            if (scene.clipPlane) {
-                this._defines.CLIPPLANE = true;
-            }
-            
-            this._defines.ALPHATEST = true;
-
-            // Point size
-            if (this.pointsCloud || scene.forcePointsCloud) {
-                this._defines.POINTSIZE = true;
-            }
-
-            // Fog
-            if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
-                this._defines.FOG = true;
-            }
-            
-            // Attribs
-            if (mesh) {
-                if (needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
-                    this._defines.NORMAL = true;
-                }
-                if (needUVs) {
-                    if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
-                        this._defines.UV1 = true;
-                    }
-                }
-                if (mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {
-                    this._defines.VERTEXCOLOR = true;
-
-                    if (mesh.hasVertexAlpha) {
-                        this._defines.VERTEXALPHA = true;
-                    }
-                }
-                if (mesh.useBones && mesh.computeBonesUsingShaders) {
-                    this._defines.BONES = true;
-                    this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
-                    this._defines.BONES4 = true;
-                }
-
-                // Instances
-                if (useInstances) {
-                    this._defines.INSTANCES = true;
-                }
-            }
-
-            // Get correct effect      
-            if (!this._defines.isEqual(this._cachedDefines)) {
-                this._defines.cloneTo(this._cachedDefines);
-
-                scene.resetCachedMaterial();
-
-                // Fallbacks
-                var fallbacks = new EffectFallbacks();             
-                if (this._defines.FOG) {
-                    fallbacks.addFallback(1, "FOG");
-                }
-             
-                if (this._defines.BONES4) {
-                    fallbacks.addFallback(0, "BONES4");
-                }
-
-                //Attributes
-                var attribs = [VertexBuffer.PositionKind];
-
-                if (this._defines.NORMAL) {
-                    attribs.push(VertexBuffer.NormalKind);
-                }
-
-                if (this._defines.UV1) {
-                    attribs.push(VertexBuffer.UVKind);
-                }
-
-                if (this._defines.VERTEXCOLOR) {
-                    attribs.push(VertexBuffer.ColorKind);
-                }
-
-                if (this._defines.BONES) {
-                    attribs.push(VertexBuffer.MatricesIndicesKind);
-                    attribs.push(VertexBuffer.MatricesWeightsKind);
-                }
-
-                if (this._defines.INSTANCES) {
-                    attribs.push("world0");
-                    attribs.push("world1");
-                    attribs.push("world2");
-                    attribs.push("world3");
-                }
-
-                // Legacy browser patch
-                var shaderName = "fire";
-                
-                var join = this._defines.toString();
-                this._effect = scene.getEngine().createEffect(shaderName,
-                    attribs,
-                    ["world", "view", "viewProjection", "vEyePosition",
-                        "vFogInfos", "vFogColor", "pointSize",
-                        "vDiffuseInfos", 
-                        "mBones",
-                        "vClipPlane", "diffuseMatrix",
-                        // Fire
-                        "time", "speed"
-                    ],
-                    ["diffuseSampler",
-                        // Fire
-                        "distortionSampler", "opacitySampler"
-                    ],
-                    join, fallbacks, this.onCompiled, this.onError);
-            }
-            
-            if (!this._effect.isReady()) {
-                return false;
-            }
-
-            this._renderId = scene.getRenderId();
-            this._wasPreviouslyReady = true;
-
-            if (mesh) {
-                if (!mesh._materialDefines) {
-                    mesh._materialDefines = new FireMaterialDefines();
-                }
-
-                this._defines.cloneTo(mesh._materialDefines);
-            }
-
-            return true;
-        }
-
-        public bindOnlyWorldMatrix(world: Matrix): void {
-            this._effect.setMatrix("world", world);
-        }
-
-        public bind(world: Matrix, mesh?: Mesh): void {
-            var scene = this.getScene();
-
-            // Matrices        
-            this.bindOnlyWorldMatrix(world);
-            this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
-
-            // Bones
-            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
-                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
-            }
-
-            if (scene.getCachedMaterial() !== this) {
-                // Textures        
-                if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
-                    this._effect.setTexture("diffuseSampler", this.diffuseTexture);
-
-                    this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
-                    this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
-                    
-                    this._effect.setTexture("distortionSampler", this.distortionTexture);
-                    this._effect.setTexture("opacitySampler", this.opacityTexture);
-                }
-                
-                // Clip plane
-                if (scene.clipPlane) {
-                    var clipPlane = scene.clipPlane;
-                    this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
-                }
-
-                // Point size
-                if (this.pointsCloud) {
-                    this._effect.setFloat("pointSize", this.pointSize);
-                }
-
-                this._effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);                
-            }
-
-            this._effect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
-
-            // View
-            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
-                this._effect.setMatrix("view", scene.getViewMatrix());
-            }
-            
-            // Fog
-            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
-                this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
-                this._effect.setColor3("vFogColor", scene.fogColor);
-            }
-            
-            // Time
-            this._lastTime += scene.getEngine().getDeltaTime();
-            this._effect.setFloat("time", this._lastTime);
-            
-            // Speed
-            this._effect.setFloat("speed", this.speed);
-
-            super.bind(world, mesh);
-        }
-
-        public getAnimatables(): IAnimatable[] {
-            var results = [];
-
-            if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
-                results.push(this.diffuseTexture);
-            }
-            if (this.distortionTexture && this.distortionTexture.animations && this.distortionTexture.animations.length > 0) {
-                results.push(this.distortionTexture);
-            }
-            if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) {
-                results.push(this.opacityTexture);
-            }
-
-            return results;
-        }
-
-        public dispose(forceDisposeEffect?: boolean): void {
-            if (this.diffuseTexture) {
-                this.diffuseTexture.dispose();
-            }
-            if (this.distortionTexture) {
-                this.distortionTexture.dispose();
-            }
-
-            super.dispose(forceDisposeEffect);
-        }
-
-        public clone(name: string): FireMaterial {
-            var newMaterial = new FireMaterial(name, this.getScene());
-
-            // Base material
-            this.copyTo(newMaterial);
-
-            // Fire material
-            if (this.diffuseTexture && this.diffuseTexture.clone) {
-                newMaterial.diffuseTexture = this.diffuseTexture.clone();
-            }
-            if (this.distortionTexture && this.distortionTexture.clone) {
-                newMaterial.distortionTexture = this.distortionTexture.clone();
-            }
-            if (this.opacityTexture && this.opacityTexture.clone) {
-                newMaterial.opacityTexture = this.opacityTexture.clone();
-            }
-
-            newMaterial.diffuseColor = this.diffuseColor.clone();
-            return newMaterial;
-        }
-    }
-} 
-
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
+    var maxSimultaneousLights = 4;
+
+    class FireMaterialDefines extends MaterialDefines {
+        public DIFFUSE = false;
+        public CLIPPLANE = false;
+        public ALPHATEST = false;
+        public POINTSIZE = false;
+        public FOG = false;
+        public UV1 = false;
+        public NORMAL = false;
+        public VERTEXCOLOR = false;
+        public VERTEXALPHA = false;
+        public BONES = false;
+        public BONES4 = false;
+        public BonesPerMesh = 0;
+        public INSTANCES = false;
+
+        constructor() {
+            super();
+            this._keys = Object.keys(this);
+        }
+    }
+
+    export class FireMaterial extends Material {
+        public diffuseTexture: BaseTexture;
+        public distortionTexture: BaseTexture;
+        public opacityTexture: BaseTexture;
+
+        public diffuseColor = new Color3(1, 1, 1);
+        public disableLighting = false;
+        
+        public speed = 1.0;
+        
+        private _scaledDiffuse = new Color3();
+        private _renderId: number;
+
+        private _defines = new FireMaterialDefines();
+        private _cachedDefines = new FireMaterialDefines();
+        
+        private _lastTime: number = 0;
+
+        constructor(name: string, scene: Scene) {
+            super(name, scene);
+
+            this._cachedDefines.BonesPerMesh = -1;
+        }
+
+        public needAlphaBlending(): boolean {
+            return (this.alpha < 1.0);
+        }
+
+        public needAlphaTesting(): boolean {
+            return false;
+        }
+
+        public getAlphaTestTexture(): BaseTexture {
+            return null;
+        }
+
+        // Methods   
+        private _checkCache(scene: Scene, mesh?: AbstractMesh, useInstances?: boolean): boolean {
+            if (!mesh) {
+                return true;
+            }
+
+            if (this._defines.INSTANCES !== useInstances) {
+                return false;
+            }
+
+            if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
+                return true;
+            }
+
+            return false;
+        }
+
+        public isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean {
+            if (this.checkReadyOnlyOnce) {
+                if (this._wasPreviouslyReady) {
+                    return true;
+                }
+            }
+
+            var scene = this.getScene();
+
+            if (!this.checkReadyOnEveryCall) {
+                if (this._renderId === scene.getRenderId()) {
+                    if (this._checkCache(scene, mesh, useInstances)) {
+                        return true;
+                    }
+                }
+            }
+
+            var engine = scene.getEngine();
+            var needNormals = false;
+            var needUVs = false;
+
+            this._defines.reset();
+
+            // Textures
+            if (scene.texturesEnabled) {
+                if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
+                    if (!this.diffuseTexture.isReady()) {
+                        return false;
+                    } else {
+                        needUVs = true;
+                        this._defines.DIFFUSE = true;
+                    }
+                }                
+            }
+
+            // Effect
+            if (scene.clipPlane) {
+                this._defines.CLIPPLANE = true;
+            }
+            
+            this._defines.ALPHATEST = true;
+
+            // Point size
+            if (this.pointsCloud || scene.forcePointsCloud) {
+                this._defines.POINTSIZE = true;
+            }
+
+            // Fog
+            if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE && this.fogEnabled) {
+                this._defines.FOG = true;
+            }
+            
+            // Attribs
+            if (mesh) {
+                if (needNormals && mesh.isVerticesDataPresent(VertexBuffer.NormalKind)) {
+                    this._defines.NORMAL = true;
+                }
+                if (needUVs) {
+                    if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
+                        this._defines.UV1 = true;
+                    }
+                }
+                if (mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind)) {
+                    this._defines.VERTEXCOLOR = true;
+
+                    if (mesh.hasVertexAlpha) {
+                        this._defines.VERTEXALPHA = true;
+                    }
+                }
+                if (mesh.useBones && mesh.computeBonesUsingShaders) {
+                    this._defines.BONES = true;
+                    this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
+                    this._defines.BONES4 = true;
+                }
+
+                // Instances
+                if (useInstances) {
+                    this._defines.INSTANCES = true;
+                }
+            }
+
+            // Get correct effect      
+            if (!this._defines.isEqual(this._cachedDefines)) {
+                this._defines.cloneTo(this._cachedDefines);
+
+                scene.resetCachedMaterial();
+
+                // Fallbacks
+                var fallbacks = new EffectFallbacks();             
+                if (this._defines.FOG) {
+                    fallbacks.addFallback(1, "FOG");
+                }
+             
+                if (this._defines.BONES4) {
+                    fallbacks.addFallback(0, "BONES4");
+                }
+
+                //Attributes
+                var attribs = [VertexBuffer.PositionKind];
+
+                if (this._defines.NORMAL) {
+                    attribs.push(VertexBuffer.NormalKind);
+                }
+
+                if (this._defines.UV1) {
+                    attribs.push(VertexBuffer.UVKind);
+                }
+
+                if (this._defines.VERTEXCOLOR) {
+                    attribs.push(VertexBuffer.ColorKind);
+                }
+
+                if (this._defines.BONES) {
+                    attribs.push(VertexBuffer.MatricesIndicesKind);
+                    attribs.push(VertexBuffer.MatricesWeightsKind);
+                }
+
+                if (this._defines.INSTANCES) {
+                    attribs.push("world0");
+                    attribs.push("world1");
+                    attribs.push("world2");
+                    attribs.push("world3");
+                }
+
+                // Legacy browser patch
+                var shaderName = "fire";
+                
+                var join = this._defines.toString();
+                this._effect = scene.getEngine().createEffect(shaderName,
+                    attribs,
+                    ["world", "view", "viewProjection", "vEyePosition",
+                        "vFogInfos", "vFogColor", "pointSize",
+                        "vDiffuseInfos", 
+                        "mBones",
+                        "vClipPlane", "diffuseMatrix",
+                        // Fire
+                        "time", "speed"
+                    ],
+                    ["diffuseSampler",
+                        // Fire
+                        "distortionSampler", "opacitySampler"
+                    ],
+                    join, fallbacks, this.onCompiled, this.onError);
+            }
+            
+            if (!this._effect.isReady()) {
+                return false;
+            }
+
+            this._renderId = scene.getRenderId();
+            this._wasPreviouslyReady = true;
+
+            if (mesh) {
+                if (!mesh._materialDefines) {
+                    mesh._materialDefines = new FireMaterialDefines();
+                }
+
+                this._defines.cloneTo(mesh._materialDefines);
+            }
+
+            return true;
+        }
+
+        public bindOnlyWorldMatrix(world: Matrix): void {
+            this._effect.setMatrix("world", world);
+        }
+
+        public bind(world: Matrix, mesh?: Mesh): void {
+            var scene = this.getScene();
+
+            // Matrices        
+            this.bindOnlyWorldMatrix(world);
+            this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
+
+            // Bones
+            if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
+                this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
+            }
+
+            if (scene.getCachedMaterial() !== this) {
+                // Textures        
+                if (this.diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
+                    this._effect.setTexture("diffuseSampler", this.diffuseTexture);
+
+                    this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
+                    this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
+                    
+                    this._effect.setTexture("distortionSampler", this.distortionTexture);
+                    this._effect.setTexture("opacitySampler", this.opacityTexture);
+                }
+                
+                // Clip plane
+                if (scene.clipPlane) {
+                    var clipPlane = scene.clipPlane;
+                    this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
+                }
+
+                // Point size
+                if (this.pointsCloud) {
+                    this._effect.setFloat("pointSize", this.pointSize);
+                }
+
+                this._effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);                
+            }
+
+            this._effect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
+
+            // View
+            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
+                this._effect.setMatrix("view", scene.getViewMatrix());
+            }
+            
+            // Fog
+            if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
+                this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
+                this._effect.setColor3("vFogColor", scene.fogColor);
+            }
+            
+            // Time
+            this._lastTime += scene.getEngine().getDeltaTime();
+            this._effect.setFloat("time", this._lastTime);
+            
+            // Speed
+            this._effect.setFloat("speed", this.speed);
+
+            super.bind(world, mesh);
+        }
+
+        public getAnimatables(): IAnimatable[] {
+            var results = [];
+
+            if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
+                results.push(this.diffuseTexture);
+            }
+            if (this.distortionTexture && this.distortionTexture.animations && this.distortionTexture.animations.length > 0) {
+                results.push(this.distortionTexture);
+            }
+            if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) {
+                results.push(this.opacityTexture);
+            }
+
+            return results;
+        }
+
+        public dispose(forceDisposeEffect?: boolean): void {
+            if (this.diffuseTexture) {
+                this.diffuseTexture.dispose();
+            }
+            if (this.distortionTexture) {
+                this.distortionTexture.dispose();
+            }
+
+            super.dispose(forceDisposeEffect);
+        }
+
+        public clone(name: string): FireMaterial {
+            var newMaterial = new FireMaterial(name, this.getScene());
+
+            // Base material
+            this.copyTo(newMaterial);
+
+            // Fire material
+            if (this.diffuseTexture && this.diffuseTexture.clone) {
+                newMaterial.diffuseTexture = this.diffuseTexture.clone();
+            }
+            if (this.distortionTexture && this.distortionTexture.clone) {
+                newMaterial.distortionTexture = this.distortionTexture.clone();
+            }
+            if (this.opacityTexture && this.opacityTexture.clone) {
+                newMaterial.opacityTexture = this.opacityTexture.clone();
+            }
+
+            newMaterial.diffuseColor = this.diffuseColor.clone();
+            return newMaterial;
+        }
+		
+		public serialize(): any {
+		
+            var serializationObject = super.serialize();
+            serializationObject.customType 		= "fire";
+            serializationObject.diffuseColor    = this.diffuseColor.asArray();
+            serializationObject.speed           = this.speed;
+            serializationObject.disableLighting = this.disableLighting;
+
+            if (this.diffuseTexture) {
+                serializationObject.diffuseTexture = this.diffuseTexture.serialize();
+            }
+            
+			if (this.distortionTexture) {
+                serializationObject.distortionTexture = this.distortionTexture.serialize();
+            }
+			
+			if (this.opacityTexture) {
+                serializationObject.opacityTexture = this.opacityTexture.serialize();
+            }
+
+            return serializationObject;
+        }
+
+        public static Parse(source: any, scene: Scene, rootUrl: string): FireMaterial {
+            var material = new FireMaterial(source.name, scene);
+
+            material.diffuseColor   = Color3.FromArray(source.diffuseColor);
+            material.speed          = source.speed;
+            material.disableLighting    = source.disableLighting;
+
+            material.alpha          = source.alpha;
+
+            material.id             = source.id;
+
+            Tags.AddTagsTo(material, source.tags);
+            material.backFaceCulling = source.backFaceCulling;
+            material.wireframe = source.wireframe;
+
+            if (source.diffuseTexture) {
+                material.diffuseTexture = Texture.Parse(source.diffuseTexture, scene, rootUrl);
+            }
+
+            if (source.distortionTexture) {
+                material.distortionTexture = Texture.Parse(source.distortionTexture, scene, rootUrl);
+            }
+			
+			if (source.opacityTexture) {
+                material.opacityTexture = Texture.Parse(source.opacityTexture, scene, rootUrl);
+            }
+
+            if (source.checkReadyOnlyOnce) {
+                material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
+            }
+
+            return material;
+        }
+    }
+} 
+

+ 5 - 5
materialsLibrary/materials/lava/babylon.lavaMaterial.ts

@@ -559,7 +559,7 @@ module BABYLON {
         public serialize(): any {
             var serializationObject = super.serialize();
             serializationObject.customType = "lava";
-            serializationObject.diffuse         = this.diffuseColor.asArray();
+            serializationObject.diffuseColor    = this.diffuseColor.asArray();
             serializationObject.fogColor        = this.fogColor.asArray();
             serializationObject.speed           = this.speed;
             serializationObject.movingSpeed     = this.movingSpeed;
@@ -571,7 +571,7 @@ module BABYLON {
                 serializationObject.diffuseTexture = this.diffuseTexture.serialize();
             }
             if (this.noiseTexture) {
-                serializationObject.diffuseTexture = this.noiseTexture.serialize();
+                serializationObject.noiseTexture = this.noiseTexture.serialize();
             }
 
             return serializationObject;
@@ -580,7 +580,7 @@ module BABYLON {
         public static Parse(source: any, scene: Scene, rootUrl: string): LavaMaterial {
             var material = new LavaMaterial(source.name, scene);
 
-            material.diffuseColor   = Color3.FromArray(source.diffuse);
+            material.diffuseColor   = Color3.FromArray(source.diffuseColor);
             material.speed          = source.speed;
             material.fogColor       = Color3.FromArray(source.fogColor);
             material.movingSpeed    = source.movingSpeed;
@@ -596,11 +596,11 @@ module BABYLON {
             material.wireframe = source.wireframe;
 
             if (source.diffuseTexture) {
-                material.diffuseTexture = Texture.ParseTexture(source.diffuseTexture, scene, rootUrl);
+                material.diffuseTexture = Texture.Parse(source.diffuseTexture, scene, rootUrl);
             }
 
             if (source.noiseTexture) {
-                material.noiseTexture = Texture.ParseTexture(source.noiseTexture, scene, rootUrl);
+                material.noiseTexture = Texture.Parse(source.noiseTexture, scene, rootUrl);
             }
 
             if (source.checkReadyOnlyOnce) {

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 551 - 516
materialsLibrary/materials/normal/babylon.normalMaterial.ts


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 664 - 577
materialsLibrary/materials/terrain/babylon.terrainMaterial.ts


+ 64 - 1
materialsLibrary/materials/water/babylon.waterMaterial.ts

@@ -128,7 +128,7 @@ module BABYLON {
 		/**
 		* Constructor
 		*/
-		constructor(name: string, scene: Scene, renderTargetSize: Vector2 = new Vector2(512, 512)) {
+		constructor(name: string, scene: Scene, public renderTargetSize: Vector2 = new Vector2(512, 512)) {
             super(name, scene);
 			
 			// Create render targets
@@ -720,6 +720,69 @@ module BABYLON {
             return newMaterial;
         }
         
+		public serialize(): any {
+		        		
+            var serializationObject = super.serialize();
+			
+            serializationObject.customType 			= "water";
+            serializationObject.diffuseColor    	= this.diffuseColor.asArray();
+			serializationObject.specularColor   	= this.specularColor.asArray();
+            serializationObject.specularPower   	= this.specularPower;
+            serializationObject.disableLighting 	= this.disableLighting;
+            serializationObject.windForce     		= this.windForce;
+            serializationObject.windDirection 		= this.windDirection.asArray();
+            serializationObject.waveHeight      	= this.waveHeight;
+            serializationObject.bumpHeight 			= this.bumpHeight;
+			serializationObject.waterColor 			= this.waterColor.asArray();
+			serializationObject.colorBlendFactor	= this.colorBlendFactor;
+			serializationObject.waveLength 			= this.waveLength;
+			serializationObject.renderTargetSize	= this.renderTargetSize.asArray();
+			
+            if (this.bumpTexture) {
+                serializationObject.bumpTexture 	= this.bumpTexture.serialize();
+            }
+
+            return serializationObject;
+        }
+
+        public static Parse(source: any, scene: Scene, rootUrl: string): WaterMaterial {
+		
+			var renderTargetSize = source.renderTargetSize ? Vector2.FromArray(source.renderTargetSize) : null;
+		
+            var material = new WaterMaterial(source.name, scene, renderTargetSize);
+
+            material.diffuseColor    	= Color3.FromArray(source.diffuseColor);
+			material.specularColor   	= Color3.FromArray(source.specularColor);
+            material.specularPower   	= source.specularPower;
+            material.disableLighting 	= source.disableLighting;
+            material.windForce     		= source.windForce;
+            material.windDirection 		= Vector2.FromArray(source.windDirection);
+            material.waveHeight      	= source.waveHeight;
+            material.bumpHeight 		= source.bumpHeight;
+			material.waterColor 		= Color3.FromArray(source.waterColor);
+			material.colorBlendFactor	= source.colorBlendFactor;
+			material.waveLength 		= source.waveLength;
+			material.renderTargetSize	= Vector2.FromArray(source.renderTargetSize);
+
+            material.alpha          = source.alpha;
+
+            material.id             = source.id;
+
+            Tags.AddTagsTo(material, source.tags);
+            material.backFaceCulling = source.backFaceCulling;
+            material.wireframe = source.wireframe;
+
+            if (source.bumpTexture) {
+                material.bumpTexture = Texture.Parse(source.bumpTexture, scene, rootUrl);
+            }
+
+            if (source.checkReadyOnlyOnce) {
+                material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
+            }
+
+            return material;
+        }
+		
 		public static CreateDefaultMesh(name: string, scene: Scene): Mesh {
 			var mesh = Mesh.CreateGround(name, 512, 512, 32, scene, false);
 			return mesh;

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 36871 - 0
materialsLibrary/test/babylon.max.js


+ 0 - 1
src/Materials/babylon.material.js

@@ -262,7 +262,6 @@ var BABYLON;
             }
             var materialType = BABYLON.Tools.Instantiate(parsedMaterial.customType);
             return materialType.Parse(parsedMaterial, scene, rootUrl);
-            ;
         };
         Material._TriangleFillMode = 0;
         Material._WireFrameFillMode = 1;

+ 1 - 1
src/Materials/babylon.material.ts

@@ -306,7 +306,7 @@
             }
 
             var materialType = Tools.Instantiate(parsedMaterial.customType);
-            return materialType.Parse(parsedMaterial, scene, rootUrl);;
+            return materialType.Parse(parsedMaterial, scene, rootUrl);
         }
     }
 }