Bladeren bron

Moving texture functions to the right location

Raanan Weber 9 jaren geleden
bovenliggende
commit
a77e54c3f9

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

@@ -144,73 +144,5 @@
                 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;
-        }
     }
 } 

+ 12 - 0
src/Materials/Textures/babylon.cubeTexture.ts

@@ -70,5 +70,17 @@
         public getReflectionTextureMatrix(): Matrix {
             return this._textureMatrix;
         }
+        
+        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;
+        }
     }
 } 

+ 56 - 0
src/Materials/Textures/babylon.texture.ts

@@ -241,5 +241,61 @@
         public static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, onLoad: () => void = null, onError: () => void = null): Texture {
             return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data);
         }
+        
+        public static ParseTexture(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture {
+            if (parsedTexture.isCube) {
+                return CubeTexture.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;
+        }
     }
 }