David catuhe 9 лет назад
Родитель
Сommit
2bf66f15f8

Разница между файлами не показана из-за своего большого размера
+ 8 - 8
dist/preview release/babylon.core.js


Разница между файлами не показана из-за своего большого размера
+ 1153 - 1148
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 18 - 18
dist/preview release/babylon.js


+ 164 - 165
dist/preview release/babylon.max.js

@@ -16389,6 +16389,66 @@ var BABYLON;
                 this.onDispose();
             }
         };
+        BaseTexture.ParseCubeTexture = function (parsedTexture, scene, rootUrl) {
+            var texture = null;
+            if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
+                texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
+                texture.name = parsedTexture.name;
+                texture.hasAlpha = parsedTexture.hasAlpha;
+                texture.level = parsedTexture.level;
+                texture.coordinatesMode = parsedTexture.coordinatesMode;
+            }
+            return texture;
+        };
+        BaseTexture.ParseTexture = function (parsedTexture, scene, rootUrl) {
+            if (parsedTexture.isCube) {
+                return BaseTexture.ParseCubeTexture(parsedTexture, scene, rootUrl);
+            }
+            if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
+                return null;
+            }
+            var texture;
+            if (parsedTexture.mirrorPlane) {
+                texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+                texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
+            }
+            else if (parsedTexture.isRenderTarget) {
+                texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+            }
+            else {
+                if (parsedTexture.base64String) {
+                    texture = BABYLON.Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
+                }
+                else {
+                    texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
+                }
+            }
+            texture.name = parsedTexture.name;
+            texture.hasAlpha = parsedTexture.hasAlpha;
+            texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
+            texture.level = parsedTexture.level;
+            texture.coordinatesIndex = parsedTexture.coordinatesIndex;
+            texture.coordinatesMode = parsedTexture.coordinatesMode;
+            texture.uOffset = parsedTexture.uOffset;
+            texture.vOffset = parsedTexture.vOffset;
+            texture.uScale = parsedTexture.uScale;
+            texture.vScale = parsedTexture.vScale;
+            texture.uAng = parsedTexture.uAng;
+            texture.vAng = parsedTexture.vAng;
+            texture.wAng = parsedTexture.wAng;
+            texture.wrapU = parsedTexture.wrapU;
+            texture.wrapV = parsedTexture.wrapV;
+            // Animations
+            if (parsedTexture.animations) {
+                for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
+                    var parsedAnimation = parsedTexture.animations[animationIndex];
+                    texture.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
+                }
+            }
+            return texture;
+        };
         return BaseTexture;
     })();
     BABYLON.BaseTexture = BaseTexture;
@@ -19000,6 +19060,74 @@ var BABYLON;
             }
             return newStandardMaterial;
         };
+        StandardMaterial.ParseFresnelParameters = function (parsedFresnelParameters) {
+            var fresnelParameters = new FresnelParameters();
+            fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
+            fresnelParameters.leftColor = BABYLON.Color3.FromArray(parsedFresnelParameters.leftColor);
+            fresnelParameters.rightColor = BABYLON.Color3.FromArray(parsedFresnelParameters.rightColor);
+            fresnelParameters.bias = parsedFresnelParameters.bias;
+            fresnelParameters.power = parsedFresnelParameters.power || 1.0;
+            return fresnelParameters;
+        };
+        StandardMaterial.Parse = function (source, scene, rootUrl) {
+            var material = new StandardMaterial(source.name, scene);
+            material.ambientColor = BABYLON.Color3.FromArray(source.ambient);
+            material.diffuseColor = BABYLON.Color3.FromArray(source.diffuse);
+            material.specularColor = BABYLON.Color3.FromArray(source.specular);
+            material.specularPower = source.specularPower;
+            material.emissiveColor = BABYLON.Color3.FromArray(source.emissive);
+            material.useReflectionFresnelFromSpecular = source.useReflectionFresnelFromSpecular;
+            material.useEmissiveAsIllumination = source.useEmissiveAsIllumination;
+            material.alpha = source.alpha;
+            material.id = source.id;
+            if (source.disableDepthWrite) {
+                material.disableDepthWrite = source.disableDepthWrite;
+            }
+            BABYLON.Tags.AddTagsTo(material, source.tags);
+            material.backFaceCulling = source.backFaceCulling;
+            material.wireframe = source.wireframe;
+            if (source.diffuseTexture) {
+                material.diffuseTexture = BABYLON.BaseTexture.ParseTexture(source.diffuseTexture, scene, rootUrl);
+            }
+            if (source.diffuseFresnelParameters) {
+                material.diffuseFresnelParameters = StandardMaterial.ParseFresnelParameters(source.diffuseFresnelParameters);
+            }
+            if (source.ambientTexture) {
+                material.ambientTexture = BABYLON.BaseTexture.ParseTexture(source.ambientTexture, scene, rootUrl);
+            }
+            if (source.opacityTexture) {
+                material.opacityTexture = BABYLON.BaseTexture.ParseTexture(source.opacityTexture, scene, rootUrl);
+            }
+            if (source.opacityFresnelParameters) {
+                material.opacityFresnelParameters = StandardMaterial.ParseFresnelParameters(source.opacityFresnelParameters);
+            }
+            if (source.reflectionTexture) {
+                material.reflectionTexture = BABYLON.BaseTexture.ParseTexture(source.reflectionTexture, scene, rootUrl);
+            }
+            if (source.reflectionFresnelParameters) {
+                material.reflectionFresnelParameters = StandardMaterial.ParseFresnelParameters(source.reflectionFresnelParameters);
+            }
+            if (source.emissiveTexture) {
+                material.emissiveTexture = BABYLON.BaseTexture.ParseTexture(source.emissiveTexture, scene, rootUrl);
+            }
+            if (source.lightmapTexture) {
+                material.lightmapTexture = BABYLON.BaseTexture.ParseTexture(source.lightmapTexture, scene, rootUrl);
+                material.useLightmapAsShadowmap = source.useLightmapAsShadowmap;
+            }
+            if (source.emissiveFresnelParameters) {
+                material.emissiveFresnelParameters = StandardMaterial.ParseFresnelParameters(source.emissiveFresnelParameters);
+            }
+            if (source.specularTexture) {
+                material.specularTexture = BABYLON.BaseTexture.ParseTexture(source.specularTexture, scene, rootUrl);
+            }
+            if (source.bumpTexture) {
+                material.bumpTexture = BABYLON.BaseTexture.ParseTexture(source.bumpTexture, scene, rootUrl);
+            }
+            if (source.checkReadyOnlyOnce) {
+                material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
+            }
+            return material;
+        };
         StandardMaterial._scaledDiffuse = new BABYLON.Color3();
         StandardMaterial._scaledSpecular = new BABYLON.Color3();
         // Statics
@@ -19261,66 +19389,6 @@ var BABYLON;
             }
             return colors;
         };
-        var loadCubeTexture = function (rootUrl, parsedTexture, scene) {
-            var texture = null;
-            if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
-                texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
-                texture.name = parsedTexture.name;
-                texture.hasAlpha = parsedTexture.hasAlpha;
-                texture.level = parsedTexture.level;
-                texture.coordinatesMode = parsedTexture.coordinatesMode;
-            }
-            return texture;
-        };
-        var loadTexture = function (rootUrl, parsedTexture, scene) {
-            if (parsedTexture.isCube) {
-                return loadCubeTexture(rootUrl, parsedTexture, scene);
-            }
-            if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
-                return null;
-            }
-            var texture;
-            if (parsedTexture.mirrorPlane) {
-                texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-                texture._waitingRenderList = parsedTexture.renderList;
-                texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
-            }
-            else if (parsedTexture.isRenderTarget) {
-                texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-                texture._waitingRenderList = parsedTexture.renderList;
-            }
-            else {
-                if (parsedTexture.base64String) {
-                    texture = BABYLON.Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
-                }
-                else {
-                    texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
-                }
-            }
-            texture.name = parsedTexture.name;
-            texture.hasAlpha = parsedTexture.hasAlpha;
-            texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
-            texture.level = parsedTexture.level;
-            texture.coordinatesIndex = parsedTexture.coordinatesIndex;
-            texture.coordinatesMode = parsedTexture.coordinatesMode;
-            texture.uOffset = parsedTexture.uOffset;
-            texture.vOffset = parsedTexture.vOffset;
-            texture.uScale = parsedTexture.uScale;
-            texture.vScale = parsedTexture.vScale;
-            texture.uAng = parsedTexture.uAng;
-            texture.vAng = parsedTexture.vAng;
-            texture.wAng = parsedTexture.wAng;
-            texture.wrapU = parsedTexture.wrapU;
-            texture.wrapV = parsedTexture.wrapV;
-            // Animations
-            if (parsedTexture.animations) {
-                for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
-                    var parsedAnimation = parsedTexture.animations[animationIndex];
-                    texture.animations.push(parseAnimation(parsedAnimation));
-                }
-            }
-            return texture;
-        };
         var parseSkeleton = function (parsedSkeleton, scene) {
             var skeleton = new BABYLON.Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
             for (var index = 0; index < parsedSkeleton.bones.length; index++) {
@@ -19331,86 +19399,17 @@ var BABYLON;
                 }
                 var bone = new BABYLON.Bone(parsedBone.name, skeleton, parentBone, BABYLON.Matrix.FromArray(parsedBone.matrix));
                 if (parsedBone.animation) {
-                    bone.animations.push(parseAnimation(parsedBone.animation));
+                    bone.animations.push(BABYLON.Animation.ParseAnimation(parsedBone.animation));
                 }
             }
             return skeleton;
         };
-        var parseFresnelParameters = function (parsedFresnelParameters) {
-            var fresnelParameters = new BABYLON.FresnelParameters();
-            fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
-            fresnelParameters.leftColor = BABYLON.Color3.FromArray(parsedFresnelParameters.leftColor);
-            fresnelParameters.rightColor = BABYLON.Color3.FromArray(parsedFresnelParameters.rightColor);
-            fresnelParameters.bias = parsedFresnelParameters.bias;
-            fresnelParameters.power = parsedFresnelParameters.power || 1.0;
-            return fresnelParameters;
-        };
         var parseCustomMaterial = function (parsedMaterial, scene, rootUrl) {
             return null;
         };
-        var parseStandardMaterial = function (parsedMaterial, scene, rootUrl) {
-            var material;
-            material = new BABYLON.StandardMaterial(parsedMaterial.name, scene);
-            material.ambientColor = BABYLON.Color3.FromArray(parsedMaterial.ambient);
-            material.diffuseColor = BABYLON.Color3.FromArray(parsedMaterial.diffuse);
-            material.specularColor = BABYLON.Color3.FromArray(parsedMaterial.specular);
-            material.specularPower = parsedMaterial.specularPower;
-            material.emissiveColor = BABYLON.Color3.FromArray(parsedMaterial.emissive);
-            material.useReflectionFresnelFromSpecular = parsedMaterial.useReflectionFresnelFromSpecular;
-            material.useEmissiveAsIllumination = parsedMaterial.useEmissiveAsIllumination;
-            material.alpha = parsedMaterial.alpha;
-            material.id = parsedMaterial.id;
-            if (parsedMaterial.disableDepthWrite) {
-                material.disableDepthWrite = parsedMaterial.disableDepthWrite;
-            }
-            BABYLON.Tags.AddTagsTo(material, parsedMaterial.tags);
-            material.backFaceCulling = parsedMaterial.backFaceCulling;
-            material.wireframe = parsedMaterial.wireframe;
-            if (parsedMaterial.diffuseTexture) {
-                material.diffuseTexture = loadTexture(rootUrl, parsedMaterial.diffuseTexture, scene);
-            }
-            if (parsedMaterial.diffuseFresnelParameters) {
-                material.diffuseFresnelParameters = parseFresnelParameters(parsedMaterial.diffuseFresnelParameters);
-            }
-            if (parsedMaterial.ambientTexture) {
-                material.ambientTexture = loadTexture(rootUrl, parsedMaterial.ambientTexture, scene);
-            }
-            if (parsedMaterial.opacityTexture) {
-                material.opacityTexture = loadTexture(rootUrl, parsedMaterial.opacityTexture, scene);
-            }
-            if (parsedMaterial.opacityFresnelParameters) {
-                material.opacityFresnelParameters = parseFresnelParameters(parsedMaterial.opacityFresnelParameters);
-            }
-            if (parsedMaterial.reflectionTexture) {
-                material.reflectionTexture = loadTexture(rootUrl, parsedMaterial.reflectionTexture, scene);
-            }
-            if (parsedMaterial.reflectionFresnelParameters) {
-                material.reflectionFresnelParameters = parseFresnelParameters(parsedMaterial.reflectionFresnelParameters);
-            }
-            if (parsedMaterial.emissiveTexture) {
-                material.emissiveTexture = loadTexture(rootUrl, parsedMaterial.emissiveTexture, scene);
-            }
-            if (parsedMaterial.lightmapTexture) {
-                material.lightmapTexture = loadTexture(rootUrl, parsedMaterial.lightmapTexture, scene);
-                material.lightmapThreshold = parsedMaterial.lightmapThreshold;
-            }
-            if (parsedMaterial.emissiveFresnelParameters) {
-                material.emissiveFresnelParameters = parseFresnelParameters(parsedMaterial.emissiveFresnelParameters);
-            }
-            if (parsedMaterial.specularTexture) {
-                material.specularTexture = loadTexture(rootUrl, parsedMaterial.specularTexture, scene);
-            }
-            if (parsedMaterial.bumpTexture) {
-                material.bumpTexture = loadTexture(rootUrl, parsedMaterial.bumpTexture, scene);
-            }
-            if (parsedMaterial.checkReadyOnlyOnce) {
-                material.checkReadyOnlyOnce = parsedMaterial.checkReadyOnlyOnce;
-            }
-            return material;
-        };
         var parseMaterial = function (parsedMaterial, scene, rootUrl) {
             if (!parsedMaterial.customType) {
-                return parseStandardMaterial(parsedMaterial, scene, rootUrl);
+                return BABYLON.StandardMaterial.Parse(parsedMaterial, scene, rootUrl);
             }
             return parseCustomMaterial(parsedMaterial, scene, rootUrl);
         };
@@ -19505,36 +19504,6 @@ var BABYLON;
             }
             return shadowGenerator;
         };
-        var parseAnimation = function (parsedAnimation) {
-            var animation = new BABYLON.Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
-            var dataType = parsedAnimation.dataType;
-            var keys = [];
-            for (var index = 0; index < parsedAnimation.keys.length; index++) {
-                var key = parsedAnimation.keys[index];
-                var data;
-                switch (dataType) {
-                    case BABYLON.Animation.ANIMATIONTYPE_FLOAT:
-                        data = key.values[0];
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:
-                        data = BABYLON.Quaternion.FromArray(key.values);
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_MATRIX:
-                        data = BABYLON.Matrix.FromArray(key.values);
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:
-                    default:
-                        data = BABYLON.Vector3.FromArray(key.values);
-                        break;
-                }
-                keys.push({
-                    frame: key.frame,
-                    value: data
-                });
-            }
-            animation.setKeys(keys);
-            return animation;
-        };
         var parseLight = function (parsedLight, scene) {
             var light;
             switch (parsedLight.type) {
@@ -19577,7 +19546,7 @@ var BABYLON;
             if (parsedLight.animations) {
                 for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
                     var parsedAnimation = parsedLight.animations[animationIndex];
-                    light.animations.push(parseAnimation(parsedAnimation));
+                    light.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedLight.autoAnimate) {
@@ -19676,7 +19645,7 @@ var BABYLON;
             if (parsedCamera.animations) {
                 for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
                     var parsedAnimation = parsedCamera.animations[animationIndex];
-                    camera.animations.push(parseAnimation(parsedAnimation));
+                    camera.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedCamera.autoAnimate) {
@@ -19925,7 +19894,7 @@ var BABYLON;
             if (parsedMesh.animations) {
                 for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                     var parsedAnimation = parsedMesh.animations[animationIndex];
-                    mesh.animations.push(parseAnimation(parsedAnimation));
+                    mesh.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedMesh.autoAnimate) {
@@ -19956,7 +19925,7 @@ var BABYLON;
                     if (parsedMesh.animations) {
                         for (animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                             parsedAnimation = parsedMesh.animations[animationIndex];
-                            instance.animations.push(parseAnimation(parsedAnimation));
+                            instance.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                         }
                     }
                 }
@@ -21926,6 +21895,36 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Animation.ParseAnimation = function (parsedAnimation) {
+            var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
+            var dataType = parsedAnimation.dataType;
+            var keys = [];
+            for (var index = 0; index < parsedAnimation.keys.length; index++) {
+                var key = parsedAnimation.keys[index];
+                var data;
+                switch (dataType) {
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        data = key.values[0];
+                        break;
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        data = BABYLON.Quaternion.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_MATRIX:
+                        data = BABYLON.Matrix.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                    default:
+                        data = BABYLON.Vector3.FromArray(key.values);
+                        break;
+                }
+                keys.push({
+                    frame: key.frame,
+                    value: data
+                });
+            }
+            animation.setKeys(keys);
+            return animation;
+        };
         // Statics
         Animation._ANIMATIONTYPE_FLOAT = 0;
         Animation._ANIMATIONTYPE_VECTOR3 = 1;

Разница между файлами не показана из-за своего большого размера
+ 14 - 14
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -18,6 +18,7 @@
     - New `Mesh.CreateIcoSphere()` method. [Demo here](http://www.babylonjs-playground.com/#24DUYD) (G'kar)
     - Introducing [babylon.core.js](http://doc.babylonjs.com/generals/Framework_versions) ([deltakosh](https://github.com/deltakosh))
   - **Updates**
+    - New parse mechanism (for loading .babylon file) ([deltakosh](https://github.com/deltakosh))   
     - New button to log the camera position in the debug layer ([temechon](https://github.com/temechon))
     - Added `Animatable.goToFrame()` ([deltakosh](https://github.com/deltakosh))   
     - Fixed behavior or `Animation.CreateAndStartAnimation` and added `Animation.CreateMergeAndStartAnimation` to reproduce previous behavior ([deltakosh](https://github.com/deltakosh))

+ 30 - 0
src/Animations/babylon.animation.js

@@ -466,6 +466,36 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Animation.ParseAnimation = function (parsedAnimation) {
+            var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
+            var dataType = parsedAnimation.dataType;
+            var keys = [];
+            for (var index = 0; index < parsedAnimation.keys.length; index++) {
+                var key = parsedAnimation.keys[index];
+                var data;
+                switch (dataType) {
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        data = key.values[0];
+                        break;
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        data = BABYLON.Quaternion.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_MATRIX:
+                        data = BABYLON.Matrix.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                    default:
+                        data = BABYLON.Vector3.FromArray(key.values);
+                        break;
+                }
+                keys.push({
+                    frame: key.frame,
+                    value: data
+                });
+            }
+            animation.setKeys(keys);
+            return animation;
+        };
         // Statics
         Animation._ANIMATIONTYPE_FLOAT = 0;
         Animation._ANIMATIONTYPE_VECTOR3 = 1;

+ 37 - 0
src/Animations/babylon.animation.ts

@@ -514,6 +514,43 @@
         public static get ANIMATIONLOOPMODE_CONSTANT(): number {
             return Animation._ANIMATIONLOOPMODE_CONSTANT;
         }
+
+        public static ParseAnimation(parsedAnimation: any): Animation {
+            var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
+
+            var dataType = parsedAnimation.dataType;
+            var keys = [];
+            for (var index = 0; index < parsedAnimation.keys.length; index++) {
+                var key = parsedAnimation.keys[index];
+
+                var data;
+
+                switch (dataType) {
+                    case Animation.ANIMATIONTYPE_FLOAT:
+                        data = key.values[0];
+                        break;
+                    case Animation.ANIMATIONTYPE_QUATERNION:
+                        data = Quaternion.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_MATRIX:
+                        data = Matrix.FromArray(key.values);
+                        break;
+                    case Animation.ANIMATIONTYPE_VECTOR3:
+                    default:
+                        data = Vector3.FromArray(key.values);
+                        break;
+                }
+
+                keys.push({
+                    frame: key.frame,
+                    value: data
+                });
+            }
+
+            animation.setKeys(keys);
+
+            return animation;
+        }
     }
 } 
 

+ 6 - 165
src/Loading/Plugins/babylon.babylonFileLoader.js

@@ -17,66 +17,6 @@ var BABYLON;
             }
             return colors;
         };
-        var loadCubeTexture = function (rootUrl, parsedTexture, scene) {
-            var texture = null;
-            if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
-                texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
-                texture.name = parsedTexture.name;
-                texture.hasAlpha = parsedTexture.hasAlpha;
-                texture.level = parsedTexture.level;
-                texture.coordinatesMode = parsedTexture.coordinatesMode;
-            }
-            return texture;
-        };
-        var loadTexture = function (rootUrl, parsedTexture, scene) {
-            if (parsedTexture.isCube) {
-                return loadCubeTexture(rootUrl, parsedTexture, scene);
-            }
-            if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
-                return null;
-            }
-            var texture;
-            if (parsedTexture.mirrorPlane) {
-                texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-                texture._waitingRenderList = parsedTexture.renderList;
-                texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
-            }
-            else if (parsedTexture.isRenderTarget) {
-                texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-                texture._waitingRenderList = parsedTexture.renderList;
-            }
-            else {
-                if (parsedTexture.base64String) {
-                    texture = BABYLON.Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
-                }
-                else {
-                    texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
-                }
-            }
-            texture.name = parsedTexture.name;
-            texture.hasAlpha = parsedTexture.hasAlpha;
-            texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
-            texture.level = parsedTexture.level;
-            texture.coordinatesIndex = parsedTexture.coordinatesIndex;
-            texture.coordinatesMode = parsedTexture.coordinatesMode;
-            texture.uOffset = parsedTexture.uOffset;
-            texture.vOffset = parsedTexture.vOffset;
-            texture.uScale = parsedTexture.uScale;
-            texture.vScale = parsedTexture.vScale;
-            texture.uAng = parsedTexture.uAng;
-            texture.vAng = parsedTexture.vAng;
-            texture.wAng = parsedTexture.wAng;
-            texture.wrapU = parsedTexture.wrapU;
-            texture.wrapV = parsedTexture.wrapV;
-            // Animations
-            if (parsedTexture.animations) {
-                for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
-                    var parsedAnimation = parsedTexture.animations[animationIndex];
-                    texture.animations.push(parseAnimation(parsedAnimation));
-                }
-            }
-            return texture;
-        };
         var parseSkeleton = function (parsedSkeleton, scene) {
             var skeleton = new BABYLON.Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
             for (var index = 0; index < parsedSkeleton.bones.length; index++) {
@@ -87,86 +27,17 @@ var BABYLON;
                 }
                 var bone = new BABYLON.Bone(parsedBone.name, skeleton, parentBone, BABYLON.Matrix.FromArray(parsedBone.matrix));
                 if (parsedBone.animation) {
-                    bone.animations.push(parseAnimation(parsedBone.animation));
+                    bone.animations.push(BABYLON.Animation.ParseAnimation(parsedBone.animation));
                 }
             }
             return skeleton;
         };
-        var parseFresnelParameters = function (parsedFresnelParameters) {
-            var fresnelParameters = new BABYLON.FresnelParameters();
-            fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
-            fresnelParameters.leftColor = BABYLON.Color3.FromArray(parsedFresnelParameters.leftColor);
-            fresnelParameters.rightColor = BABYLON.Color3.FromArray(parsedFresnelParameters.rightColor);
-            fresnelParameters.bias = parsedFresnelParameters.bias;
-            fresnelParameters.power = parsedFresnelParameters.power || 1.0;
-            return fresnelParameters;
-        };
         var parseCustomMaterial = function (parsedMaterial, scene, rootUrl) {
             return null;
         };
-        var parseStandardMaterial = function (parsedMaterial, scene, rootUrl) {
-            var material;
-            material = new BABYLON.StandardMaterial(parsedMaterial.name, scene);
-            material.ambientColor = BABYLON.Color3.FromArray(parsedMaterial.ambient);
-            material.diffuseColor = BABYLON.Color3.FromArray(parsedMaterial.diffuse);
-            material.specularColor = BABYLON.Color3.FromArray(parsedMaterial.specular);
-            material.specularPower = parsedMaterial.specularPower;
-            material.emissiveColor = BABYLON.Color3.FromArray(parsedMaterial.emissive);
-            material.useReflectionFresnelFromSpecular = parsedMaterial.useReflectionFresnelFromSpecular;
-            material.useEmissiveAsIllumination = parsedMaterial.useEmissiveAsIllumination;
-            material.alpha = parsedMaterial.alpha;
-            material.id = parsedMaterial.id;
-            if (parsedMaterial.disableDepthWrite) {
-                material.disableDepthWrite = parsedMaterial.disableDepthWrite;
-            }
-            BABYLON.Tags.AddTagsTo(material, parsedMaterial.tags);
-            material.backFaceCulling = parsedMaterial.backFaceCulling;
-            material.wireframe = parsedMaterial.wireframe;
-            if (parsedMaterial.diffuseTexture) {
-                material.diffuseTexture = loadTexture(rootUrl, parsedMaterial.diffuseTexture, scene);
-            }
-            if (parsedMaterial.diffuseFresnelParameters) {
-                material.diffuseFresnelParameters = parseFresnelParameters(parsedMaterial.diffuseFresnelParameters);
-            }
-            if (parsedMaterial.ambientTexture) {
-                material.ambientTexture = loadTexture(rootUrl, parsedMaterial.ambientTexture, scene);
-            }
-            if (parsedMaterial.opacityTexture) {
-                material.opacityTexture = loadTexture(rootUrl, parsedMaterial.opacityTexture, scene);
-            }
-            if (parsedMaterial.opacityFresnelParameters) {
-                material.opacityFresnelParameters = parseFresnelParameters(parsedMaterial.opacityFresnelParameters);
-            }
-            if (parsedMaterial.reflectionTexture) {
-                material.reflectionTexture = loadTexture(rootUrl, parsedMaterial.reflectionTexture, scene);
-            }
-            if (parsedMaterial.reflectionFresnelParameters) {
-                material.reflectionFresnelParameters = parseFresnelParameters(parsedMaterial.reflectionFresnelParameters);
-            }
-            if (parsedMaterial.emissiveTexture) {
-                material.emissiveTexture = loadTexture(rootUrl, parsedMaterial.emissiveTexture, scene);
-            }
-            if (parsedMaterial.lightmapTexture) {
-                material.lightmapTexture = loadTexture(rootUrl, parsedMaterial.lightmapTexture, scene);
-                material.lightmapThreshold = parsedMaterial.lightmapThreshold;
-            }
-            if (parsedMaterial.emissiveFresnelParameters) {
-                material.emissiveFresnelParameters = parseFresnelParameters(parsedMaterial.emissiveFresnelParameters);
-            }
-            if (parsedMaterial.specularTexture) {
-                material.specularTexture = loadTexture(rootUrl, parsedMaterial.specularTexture, scene);
-            }
-            if (parsedMaterial.bumpTexture) {
-                material.bumpTexture = loadTexture(rootUrl, parsedMaterial.bumpTexture, scene);
-            }
-            if (parsedMaterial.checkReadyOnlyOnce) {
-                material.checkReadyOnlyOnce = parsedMaterial.checkReadyOnlyOnce;
-            }
-            return material;
-        };
         var parseMaterial = function (parsedMaterial, scene, rootUrl) {
             if (!parsedMaterial.customType) {
-                return parseStandardMaterial(parsedMaterial, scene, rootUrl);
+                return BABYLON.StandardMaterial.Parse(parsedMaterial, scene, rootUrl);
             }
             return parseCustomMaterial(parsedMaterial, scene, rootUrl);
         };
@@ -261,36 +132,6 @@ var BABYLON;
             }
             return shadowGenerator;
         };
-        var parseAnimation = function (parsedAnimation) {
-            var animation = new BABYLON.Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
-            var dataType = parsedAnimation.dataType;
-            var keys = [];
-            for (var index = 0; index < parsedAnimation.keys.length; index++) {
-                var key = parsedAnimation.keys[index];
-                var data;
-                switch (dataType) {
-                    case BABYLON.Animation.ANIMATIONTYPE_FLOAT:
-                        data = key.values[0];
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:
-                        data = BABYLON.Quaternion.FromArray(key.values);
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_MATRIX:
-                        data = BABYLON.Matrix.FromArray(key.values);
-                        break;
-                    case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:
-                    default:
-                        data = BABYLON.Vector3.FromArray(key.values);
-                        break;
-                }
-                keys.push({
-                    frame: key.frame,
-                    value: data
-                });
-            }
-            animation.setKeys(keys);
-            return animation;
-        };
         var parseLight = function (parsedLight, scene) {
             var light;
             switch (parsedLight.type) {
@@ -333,7 +174,7 @@ var BABYLON;
             if (parsedLight.animations) {
                 for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
                     var parsedAnimation = parsedLight.animations[animationIndex];
-                    light.animations.push(parseAnimation(parsedAnimation));
+                    light.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedLight.autoAnimate) {
@@ -432,7 +273,7 @@ var BABYLON;
             if (parsedCamera.animations) {
                 for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
                     var parsedAnimation = parsedCamera.animations[animationIndex];
-                    camera.animations.push(parseAnimation(parsedAnimation));
+                    camera.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedCamera.autoAnimate) {
@@ -681,7 +522,7 @@ var BABYLON;
             if (parsedMesh.animations) {
                 for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                     var parsedAnimation = parsedMesh.animations[animationIndex];
-                    mesh.animations.push(parseAnimation(parsedAnimation));
+                    mesh.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                 }
             }
             if (parsedMesh.autoAnimate) {
@@ -712,7 +553,7 @@ var BABYLON;
                     if (parsedMesh.animations) {
                         for (animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                             parsedAnimation = parsedMesh.animations[animationIndex];
-                            instance.animations.push(parseAnimation(parsedAnimation));
+                            instance.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
                         }
                     }
                 }

+ 8 - 205
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -17,75 +17,7 @@
 
         return colors;
     }
-
-    var loadCubeTexture = (rootUrl, parsedTexture, scene) => {
-        var texture = null;
-        if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
-            texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
-            texture.name = parsedTexture.name;
-            texture.hasAlpha = parsedTexture.hasAlpha;
-            texture.level = parsedTexture.level;
-            texture.coordinatesMode = parsedTexture.coordinatesMode;
-        }
-        return texture;
-    };
-
-    var loadTexture = (rootUrl, parsedTexture, scene) => {
-        if (parsedTexture.isCube) {
-            return loadCubeTexture(rootUrl, parsedTexture, scene);
-        }
-
-        if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
-            return null;
-        }
-
-        var texture;
-
-        if (parsedTexture.mirrorPlane) {
-            texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-            texture._waitingRenderList = parsedTexture.renderList;
-            texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
-        } else if (parsedTexture.isRenderTarget) {
-            texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-            texture._waitingRenderList = parsedTexture.renderList;
-        } else {
-            if (parsedTexture.base64String) {
-                texture = BABYLON.Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
-            } else {
-                texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
-            }
-        }
-
-        texture.name = parsedTexture.name;
-        texture.hasAlpha = parsedTexture.hasAlpha;
-        texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
-        texture.level = parsedTexture.level;
-
-        texture.coordinatesIndex = parsedTexture.coordinatesIndex;
-        texture.coordinatesMode = parsedTexture.coordinatesMode;
-        texture.uOffset = parsedTexture.uOffset;
-        texture.vOffset = parsedTexture.vOffset;
-        texture.uScale = parsedTexture.uScale;
-        texture.vScale = parsedTexture.vScale;
-        texture.uAng = parsedTexture.uAng;
-        texture.vAng = parsedTexture.vAng;
-        texture.wAng = parsedTexture.wAng;
-
-        texture.wrapU = parsedTexture.wrapU;
-        texture.wrapV = parsedTexture.wrapV;
-
-        // Animations
-        if (parsedTexture.animations) {
-            for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
-                var parsedAnimation = parsedTexture.animations[animationIndex];
-
-                texture.animations.push(parseAnimation(parsedAnimation));
-            }
-        }
-
-        return texture;
-    };
-
+    
     var parseSkeleton = (parsedSkeleton, scene) => {
         var skeleton = new BABYLON.Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
 
@@ -100,112 +32,20 @@
             var bone = new BABYLON.Bone(parsedBone.name, skeleton, parentBone, BABYLON.Matrix.FromArray(parsedBone.matrix));
 
             if (parsedBone.animation) {
-                bone.animations.push(parseAnimation(parsedBone.animation));
+                bone.animations.push(Animation.ParseAnimation(parsedBone.animation));
             }
         }
 
         return skeleton;
-    };
-
-    var parseFresnelParameters = (parsedFresnelParameters) => {
-        var fresnelParameters = new BABYLON.FresnelParameters();
-
-        fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
-        fresnelParameters.leftColor = BABYLON.Color3.FromArray(parsedFresnelParameters.leftColor);
-        fresnelParameters.rightColor = BABYLON.Color3.FromArray(parsedFresnelParameters.rightColor);
-        fresnelParameters.bias = parsedFresnelParameters.bias;
-        fresnelParameters.power = parsedFresnelParameters.power || 1.0;
-
-        return fresnelParameters;
-    }
+    };    
 
     var parseCustomMaterial = (parsedMaterial, scene, rootUrl): Material => {
         return null;
     }
 
-    var parseStandardMaterial = (parsedMaterial, scene, rootUrl): Material => {
-        var material;
-        material = new BABYLON.StandardMaterial(parsedMaterial.name, scene);
-
-        material.ambientColor = BABYLON.Color3.FromArray(parsedMaterial.ambient);
-        material.diffuseColor = BABYLON.Color3.FromArray(parsedMaterial.diffuse);
-        material.specularColor = BABYLON.Color3.FromArray(parsedMaterial.specular);
-        material.specularPower = parsedMaterial.specularPower;
-        material.emissiveColor = BABYLON.Color3.FromArray(parsedMaterial.emissive);
-        material.useReflectionFresnelFromSpecular = parsedMaterial.useReflectionFresnelFromSpecular;
-        material.useEmissiveAsIllumination = parsedMaterial.useEmissiveAsIllumination;
-
-        material.alpha = parsedMaterial.alpha;
-
-        material.id = parsedMaterial.id;
-
-        if (parsedMaterial.disableDepthWrite) {
-            material.disableDepthWrite = parsedMaterial.disableDepthWrite;
-        }
-
-        BABYLON.Tags.AddTagsTo(material, parsedMaterial.tags);
-        material.backFaceCulling = parsedMaterial.backFaceCulling;
-        material.wireframe = parsedMaterial.wireframe;
-
-        if (parsedMaterial.diffuseTexture) {
-            material.diffuseTexture = loadTexture(rootUrl, parsedMaterial.diffuseTexture, scene);
-        }
-
-        if (parsedMaterial.diffuseFresnelParameters) {
-            material.diffuseFresnelParameters = parseFresnelParameters(parsedMaterial.diffuseFresnelParameters);
-        }
-
-        if (parsedMaterial.ambientTexture) {
-            material.ambientTexture = loadTexture(rootUrl, parsedMaterial.ambientTexture, scene);
-        }
-
-        if (parsedMaterial.opacityTexture) {
-            material.opacityTexture = loadTexture(rootUrl, parsedMaterial.opacityTexture, scene);
-        }
-
-        if (parsedMaterial.opacityFresnelParameters) {
-            material.opacityFresnelParameters = parseFresnelParameters(parsedMaterial.opacityFresnelParameters);
-        }
-
-        if (parsedMaterial.reflectionTexture) {
-            material.reflectionTexture = loadTexture(rootUrl, parsedMaterial.reflectionTexture, scene);
-        }
-
-        if (parsedMaterial.reflectionFresnelParameters) {
-            material.reflectionFresnelParameters = parseFresnelParameters(parsedMaterial.reflectionFresnelParameters);
-        }
-
-        if (parsedMaterial.emissiveTexture) {
-            material.emissiveTexture = loadTexture(rootUrl, parsedMaterial.emissiveTexture, scene);
-        }
-
-        if (parsedMaterial.lightmapTexture) {
-            material.lightmapTexture = loadTexture(rootUrl, parsedMaterial.lightmapTexture, scene);
-            material.lightmapThreshold = parsedMaterial.lightmapThreshold;
-        }
-
-        if (parsedMaterial.emissiveFresnelParameters) {
-            material.emissiveFresnelParameters = parseFresnelParameters(parsedMaterial.emissiveFresnelParameters);
-        }
-
-        if (parsedMaterial.specularTexture) {
-            material.specularTexture = loadTexture(rootUrl, parsedMaterial.specularTexture, scene);
-        }
-
-        if (parsedMaterial.bumpTexture) {
-            material.bumpTexture = loadTexture(rootUrl, parsedMaterial.bumpTexture, scene);
-        }
-
-        if (parsedMaterial.checkReadyOnlyOnce) {
-            material.checkReadyOnlyOnce = parsedMaterial.checkReadyOnlyOnce;
-        }
-
-        return material;
-    };
-
     var parseMaterial = (parsedMaterial, scene, rootUrl): Material => {
         if (!parsedMaterial.customType) {
-            return parseStandardMaterial(parsedMaterial, scene, rootUrl);
+            return StandardMaterial.Parse(parsedMaterial, scene, rootUrl);
         }
 
         return parseCustomMaterial(parsedMaterial, scene, rootUrl);
@@ -322,43 +162,6 @@
         return shadowGenerator;
     };
 
-    var parseAnimation = parsedAnimation => {
-        var animation = new BABYLON.Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
-
-        var dataType = parsedAnimation.dataType;
-        var keys = [];
-        for (var index = 0; index < parsedAnimation.keys.length; index++) {
-            var key = parsedAnimation.keys[index];
-
-            var data;
-
-            switch (dataType) {
-                case BABYLON.Animation.ANIMATIONTYPE_FLOAT:
-                    data = key.values[0];
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:
-                    data = BABYLON.Quaternion.FromArray(key.values);
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_MATRIX:
-                    data = BABYLON.Matrix.FromArray(key.values);
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:
-                default:
-                    data = BABYLON.Vector3.FromArray(key.values);
-                    break;
-            }
-
-            keys.push({
-                frame: key.frame,
-                value: data
-            });
-        }
-
-        animation.setKeys(keys);
-
-        return animation;
-    };
-
     var parseLight = (parsedLight, scene) => {
         var light;
 
@@ -412,7 +215,7 @@
             for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
                 var parsedAnimation = parsedLight.animations[animationIndex];
 
-                light.animations.push(parseAnimation(parsedAnimation));
+                light.animations.push(Animation.ParseAnimation(parsedAnimation));
             }
         }
 
@@ -522,7 +325,7 @@
             for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
                 var parsedAnimation = parsedCamera.animations[animationIndex];
 
-                camera.animations.push(parseAnimation(parsedAnimation));
+                camera.animations.push(Animation.ParseAnimation(parsedAnimation));
             }
         }
 
@@ -852,7 +655,7 @@
             for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                 var parsedAnimation = parsedMesh.animations[animationIndex];
 
-                mesh.animations.push(parseAnimation(parsedAnimation));
+                mesh.animations.push(Animation.ParseAnimation(parsedAnimation));
             }
         }
 
@@ -891,7 +694,7 @@
                     for (animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
                         parsedAnimation = parsedMesh.animations[animationIndex];
 
-                        instance.animations.push(parseAnimation(parsedAnimation));
+                        instance.animations.push(Animation.ParseAnimation(parsedAnimation));
                     }
                 }
             }

+ 60 - 0
src/Materials/Textures/babylon.baseTexture.js

@@ -114,6 +114,66 @@ var BABYLON;
                 this.onDispose();
             }
         };
+        BaseTexture.ParseCubeTexture = function (parsedTexture, scene, rootUrl) {
+            var texture = null;
+            if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
+                texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
+                texture.name = parsedTexture.name;
+                texture.hasAlpha = parsedTexture.hasAlpha;
+                texture.level = parsedTexture.level;
+                texture.coordinatesMode = parsedTexture.coordinatesMode;
+            }
+            return texture;
+        };
+        BaseTexture.ParseTexture = function (parsedTexture, scene, rootUrl) {
+            if (parsedTexture.isCube) {
+                return BaseTexture.ParseCubeTexture(parsedTexture, scene, rootUrl);
+            }
+            if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
+                return null;
+            }
+            var texture;
+            if (parsedTexture.mirrorPlane) {
+                texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+                texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
+            }
+            else if (parsedTexture.isRenderTarget) {
+                texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+            }
+            else {
+                if (parsedTexture.base64String) {
+                    texture = BABYLON.Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
+                }
+                else {
+                    texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
+                }
+            }
+            texture.name = parsedTexture.name;
+            texture.hasAlpha = parsedTexture.hasAlpha;
+            texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
+            texture.level = parsedTexture.level;
+            texture.coordinatesIndex = parsedTexture.coordinatesIndex;
+            texture.coordinatesMode = parsedTexture.coordinatesMode;
+            texture.uOffset = parsedTexture.uOffset;
+            texture.vOffset = parsedTexture.vOffset;
+            texture.uScale = parsedTexture.uScale;
+            texture.vScale = parsedTexture.vScale;
+            texture.uAng = parsedTexture.uAng;
+            texture.vAng = parsedTexture.vAng;
+            texture.wAng = parsedTexture.wAng;
+            texture.wrapU = parsedTexture.wrapU;
+            texture.wrapV = parsedTexture.wrapV;
+            // Animations
+            if (parsedTexture.animations) {
+                for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
+                    var parsedAnimation = parsedTexture.animations[animationIndex];
+                    texture.animations.push(BABYLON.Animation.ParseAnimation(parsedAnimation));
+                }
+            }
+            return texture;
+        };
         return BaseTexture;
     })();
     BABYLON.BaseTexture = BaseTexture;

+ 68 - 0
src/Materials/Textures/babylon.baseTexture.ts

@@ -144,5 +144,73 @@
                 this.onDispose();
             }
         }
+
+        public static ParseCubeTexture(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture {
+            var texture = null;
+            if ((parsedTexture.name || parsedTexture.extensions) && !parsedTexture.isRenderTarget) {
+                texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
+                texture.name = parsedTexture.name;
+                texture.hasAlpha = parsedTexture.hasAlpha;
+                texture.level = parsedTexture.level;
+                texture.coordinatesMode = parsedTexture.coordinatesMode;
+            }
+            return texture;
+        }
+
+        public static ParseTexture(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture {
+            if (parsedTexture.isCube) {
+                return BaseTexture.ParseCubeTexture(parsedTexture, scene, rootUrl);
+            }
+
+            if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
+                return null;
+            }
+
+            var texture;
+
+            if (parsedTexture.mirrorPlane) {
+                texture = new MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+                texture.mirrorPlane = Plane.FromArray(parsedTexture.mirrorPlane);
+            } else if (parsedTexture.isRenderTarget) {
+                texture = new RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
+                texture._waitingRenderList = parsedTexture.renderList;
+            } else {
+                if (parsedTexture.base64String) {
+                    texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene);
+                } else {
+                    texture = new Texture(rootUrl + parsedTexture.name, scene);
+                }
+            }
+
+            texture.name = parsedTexture.name;
+            texture.hasAlpha = parsedTexture.hasAlpha;
+            texture.getAlphaFromRGB = parsedTexture.getAlphaFromRGB;
+            texture.level = parsedTexture.level;
+
+            texture.coordinatesIndex = parsedTexture.coordinatesIndex;
+            texture.coordinatesMode = parsedTexture.coordinatesMode;
+            texture.uOffset = parsedTexture.uOffset;
+            texture.vOffset = parsedTexture.vOffset;
+            texture.uScale = parsedTexture.uScale;
+            texture.vScale = parsedTexture.vScale;
+            texture.uAng = parsedTexture.uAng;
+            texture.vAng = parsedTexture.vAng;
+            texture.wAng = parsedTexture.wAng;
+
+            texture.wrapU = parsedTexture.wrapU;
+            texture.wrapV = parsedTexture.wrapV;
+
+            // Animations
+            if (parsedTexture.animations) {
+                for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
+                    var parsedAnimation = parsedTexture.animations[animationIndex];
+
+                    texture.animations.push(Animation.ParseAnimation(parsedAnimation));
+                }
+            }
+
+            return texture;
+        }
     }
 } 

+ 68 - 0
src/Materials/babylon.standardMaterial.js

@@ -868,6 +868,74 @@ var BABYLON;
             }
             return newStandardMaterial;
         };
+        StandardMaterial.ParseFresnelParameters = function (parsedFresnelParameters) {
+            var fresnelParameters = new FresnelParameters();
+            fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
+            fresnelParameters.leftColor = BABYLON.Color3.FromArray(parsedFresnelParameters.leftColor);
+            fresnelParameters.rightColor = BABYLON.Color3.FromArray(parsedFresnelParameters.rightColor);
+            fresnelParameters.bias = parsedFresnelParameters.bias;
+            fresnelParameters.power = parsedFresnelParameters.power || 1.0;
+            return fresnelParameters;
+        };
+        StandardMaterial.Parse = function (source, scene, rootUrl) {
+            var material = new StandardMaterial(source.name, scene);
+            material.ambientColor = BABYLON.Color3.FromArray(source.ambient);
+            material.diffuseColor = BABYLON.Color3.FromArray(source.diffuse);
+            material.specularColor = BABYLON.Color3.FromArray(source.specular);
+            material.specularPower = source.specularPower;
+            material.emissiveColor = BABYLON.Color3.FromArray(source.emissive);
+            material.useReflectionFresnelFromSpecular = source.useReflectionFresnelFromSpecular;
+            material.useEmissiveAsIllumination = source.useEmissiveAsIllumination;
+            material.alpha = source.alpha;
+            material.id = source.id;
+            if (source.disableDepthWrite) {
+                material.disableDepthWrite = source.disableDepthWrite;
+            }
+            BABYLON.Tags.AddTagsTo(material, source.tags);
+            material.backFaceCulling = source.backFaceCulling;
+            material.wireframe = source.wireframe;
+            if (source.diffuseTexture) {
+                material.diffuseTexture = BABYLON.BaseTexture.ParseTexture(source.diffuseTexture, scene, rootUrl);
+            }
+            if (source.diffuseFresnelParameters) {
+                material.diffuseFresnelParameters = StandardMaterial.ParseFresnelParameters(source.diffuseFresnelParameters);
+            }
+            if (source.ambientTexture) {
+                material.ambientTexture = BABYLON.BaseTexture.ParseTexture(source.ambientTexture, scene, rootUrl);
+            }
+            if (source.opacityTexture) {
+                material.opacityTexture = BABYLON.BaseTexture.ParseTexture(source.opacityTexture, scene, rootUrl);
+            }
+            if (source.opacityFresnelParameters) {
+                material.opacityFresnelParameters = StandardMaterial.ParseFresnelParameters(source.opacityFresnelParameters);
+            }
+            if (source.reflectionTexture) {
+                material.reflectionTexture = BABYLON.BaseTexture.ParseTexture(source.reflectionTexture, scene, rootUrl);
+            }
+            if (source.reflectionFresnelParameters) {
+                material.reflectionFresnelParameters = StandardMaterial.ParseFresnelParameters(source.reflectionFresnelParameters);
+            }
+            if (source.emissiveTexture) {
+                material.emissiveTexture = BABYLON.BaseTexture.ParseTexture(source.emissiveTexture, scene, rootUrl);
+            }
+            if (source.lightmapTexture) {
+                material.lightmapTexture = BABYLON.BaseTexture.ParseTexture(source.lightmapTexture, scene, rootUrl);
+                material.useLightmapAsShadowmap = source.useLightmapAsShadowmap;
+            }
+            if (source.emissiveFresnelParameters) {
+                material.emissiveFresnelParameters = StandardMaterial.ParseFresnelParameters(source.emissiveFresnelParameters);
+            }
+            if (source.specularTexture) {
+                material.specularTexture = BABYLON.BaseTexture.ParseTexture(source.specularTexture, scene, rootUrl);
+            }
+            if (source.bumpTexture) {
+                material.bumpTexture = BABYLON.BaseTexture.ParseTexture(source.bumpTexture, scene, rootUrl);
+            }
+            if (source.checkReadyOnlyOnce) {
+                material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
+            }
+            return material;
+        };
         StandardMaterial._scaledDiffuse = new BABYLON.Color3();
         StandardMaterial._scaledSpecular = new BABYLON.Color3();
         // Statics

+ 91 - 0
src/Materials/babylon.standardMaterial.ts

@@ -1056,5 +1056,96 @@
         public static BumpTextureEnabled = true;
         public static FresnelEnabled = true;
         public static LightmapEnabled = true;
+
+        public static ParseFresnelParameters(parsedFresnelParameters: any): FresnelParameters {
+            var fresnelParameters = new FresnelParameters();
+
+            fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
+            fresnelParameters.leftColor = Color3.FromArray(parsedFresnelParameters.leftColor);
+            fresnelParameters.rightColor = Color3.FromArray(parsedFresnelParameters.rightColor);
+            fresnelParameters.bias = parsedFresnelParameters.bias;
+            fresnelParameters.power = parsedFresnelParameters.power || 1.0;
+
+            return fresnelParameters;
+        }
+
+        public static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial {
+            var material = new StandardMaterial(source.name, scene);
+
+            material.ambientColor = Color3.FromArray(source.ambient);
+            material.diffuseColor = Color3.FromArray(source.diffuse);
+            material.specularColor = Color3.FromArray(source.specular);
+            material.specularPower = source.specularPower;
+            material.emissiveColor = Color3.FromArray(source.emissive);
+            material.useReflectionFresnelFromSpecular = source.useReflectionFresnelFromSpecular;
+            material.useEmissiveAsIllumination = source.useEmissiveAsIllumination;
+
+            material.alpha = source.alpha;
+
+            material.id = source.id;
+
+            if (source.disableDepthWrite) {
+                material.disableDepthWrite = source.disableDepthWrite;
+            }
+
+            Tags.AddTagsTo(material, source.tags);
+            material.backFaceCulling = source.backFaceCulling;
+            material.wireframe = source.wireframe;
+
+            if (source.diffuseTexture) {
+                material.diffuseTexture = BaseTexture.ParseTexture(source.diffuseTexture, scene, rootUrl);
+            }
+
+            if (source.diffuseFresnelParameters) {
+                material.diffuseFresnelParameters =  StandardMaterial.ParseFresnelParameters(source.diffuseFresnelParameters);
+            }
+
+            if (source.ambientTexture) {
+                material.ambientTexture = BaseTexture.ParseTexture(source.ambientTexture, scene, rootUrl);
+            }
+
+            if (source.opacityTexture) {
+                material.opacityTexture = BaseTexture.ParseTexture(source.opacityTexture, scene, rootUrl);
+            }
+
+            if (source.opacityFresnelParameters) {
+                material.opacityFresnelParameters = StandardMaterial.ParseFresnelParameters(source.opacityFresnelParameters);
+            }
+
+            if (source.reflectionTexture) {
+                material.reflectionTexture = BaseTexture.ParseTexture(source.reflectionTexture, scene, rootUrl);
+            }
+
+            if (source.reflectionFresnelParameters) {
+                material.reflectionFresnelParameters = StandardMaterial.ParseFresnelParameters(source.reflectionFresnelParameters);
+            }
+
+            if (source.emissiveTexture) {
+                material.emissiveTexture = BaseTexture.ParseTexture(source.emissiveTexture, scene, rootUrl);
+            }
+
+            if (source.lightmapTexture) {
+                material.lightmapTexture = BaseTexture.ParseTexture(source.lightmapTexture, scene, rootUrl);
+                material.useLightmapAsShadowmap = source.useLightmapAsShadowmap;
+            }
+
+            if (source.emissiveFresnelParameters) {
+                material.emissiveFresnelParameters = StandardMaterial.ParseFresnelParameters(source.emissiveFresnelParameters);
+            }
+
+            if (source.specularTexture) {
+                material.specularTexture = BaseTexture.ParseTexture(source.specularTexture, scene, rootUrl);
+            }
+
+            if (source.bumpTexture) {
+                material.bumpTexture = BaseTexture.ParseTexture(source.bumpTexture, scene, rootUrl);
+            }
+
+            if (source.checkReadyOnlyOnce) {
+                material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
+            }
+
+            return material;
+        }
     }
 } 

+ 1 - 1
src/PostProcess/babylon.postProcess.ts

@@ -43,7 +43,7 @@
             this._samplers.push("textureSampler");
 
             this._fragmentUrl = fragmentUrl;
-            this._parameters = parameters || []
+            this._parameters = parameters || [];
 
             this.updateEffect(defines);
         }