David Catuhe 6 years ago
parent
commit
e1440245c6

+ 30 - 6
src/Materials/Textures/babylon.baseTexture.ts

@@ -147,13 +147,41 @@ module BABYLON {
          * Define if the texture is a cube texture or if false a 2d texture.
          */
         @serialize()
-        public isCube = false;
+        public get isCube(): boolean {
+            if (!this._texture) {
+                return false;
+            }
+
+            return this._texture.isCube;
+        }
+
+        public set isCube(value: boolean) {
+            if (!this._texture) {
+                return;
+            }
+
+            this._texture.isCube = value;
+        }
 
         /**
          * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
          */
         @serialize()
-        public is3D = false;
+        public get is3D(): boolean {
+            if (!this._texture) {
+                return false;
+            }
+
+            return this._texture.is3D;
+        }
+
+        public set is3D(value: boolean) {
+            if (!this._texture) {
+                return;
+            }
+
+            this._texture.is3D = value;
+        }
 
         /**
          * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
@@ -277,9 +305,6 @@ module BABYLON {
         private _scene: Nullable<Scene>;
 
         /** @hidden */
-        public _samplingMode: number;
-
-        /** @hidden */
         public _texture: Nullable<InternalTexture>;
         private _uid: Nullable<string>;
 
@@ -439,7 +464,6 @@ module BABYLON {
                 return;
             }
 
-            this._samplingMode = samplingMode;
             scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
         }
 

+ 1 - 1
src/Materials/Textures/babylon.dynamicTexture.ts

@@ -70,7 +70,7 @@ module BABYLON {
 
             this.releaseInternalTexture();
 
-            this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this._samplingMode);
+            this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
         }
 
         /**

+ 14 - 7
src/Materials/Textures/babylon.texture.ts

@@ -172,6 +172,9 @@ module BABYLON {
         private _cachedCoordinatesMode: number;
 
         /** @hidden */
+        protected _initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
+
+        /** @hidden */
         public _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
         private _deleteBuffer: boolean;
         protected _format: Nullable<number>;
@@ -200,7 +203,11 @@ module BABYLON {
          * Get the current sampling mode associated with the texture.
          */
         public get samplingMode(): number {
-            return this._samplingMode;
+            if (!this._texture) {
+                return this._initialSamplingMode;
+            }
+
+            return this._texture.samplingMode;
         }
 
         /**
@@ -232,7 +239,7 @@ module BABYLON {
             this.url = url;
             this._noMipmap = noMipmap;
             this._invertY = invertY;
-            this._samplingMode = samplingMode;
+            this._initialSamplingMode = samplingMode;
             this._buffer = buffer;
             this._deleteBuffer = deleteBuffer;
             if (format) {
@@ -272,7 +279,7 @@ module BABYLON {
 
             if (!this._texture) {
                 if (!scene.useDelayedTextureLoading) {
-                    this._texture = scene.getEngine().createTexture(this.url, noMipmap, invertY, scene, this._samplingMode, load, onError, this._buffer, undefined, this._format);
+                    this._texture = scene.getEngine().createTexture(this.url, noMipmap, invertY, scene, samplingMode, load, onError, this._buffer, undefined, this._format);
                     if (deleteBuffer) {
                         delete this._buffer;
                     }
@@ -329,10 +336,10 @@ module BABYLON {
             }
 
             this.delayLoadState = Engine.DELAYLOADSTATE_LOADED;
-            this._texture = this._getFromCache(this.url, this._noMipmap, this._samplingMode);
+            this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
 
             if (!this._texture) {
-                this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this._samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
+                this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
                 if (this._deleteBuffer) {
                     delete this._buffer;
                 }
@@ -506,7 +513,7 @@ module BABYLON {
          */
         public clone(): Texture {
             return SerializationHelper.Clone(() => {
-                return new Texture(this._texture ? this._texture.url : null, this.getScene(), this._noMipmap, this._invertY, this._samplingMode);
+                return new Texture(this._texture ? this._texture.url : null, this.getScene(), this._noMipmap, this._invertY, this.samplingMode);
             }, this);
         }
 
@@ -625,7 +632,7 @@ module BABYLON {
             // Update Sampling Mode
             if (parsedTexture.samplingMode) {
                 var sampling: number = parsedTexture.samplingMode;
-                if (texture && texture._samplingMode !== sampling) {
+                if (texture && texture.samplingMode !== sampling) {
                     texture.updateSamplingMode(sampling);
                 }
             }

+ 2 - 2
src/Materials/Textures/babylon.videoTexture.ts

@@ -90,7 +90,7 @@ module BABYLON {
 
             this._engine = this.getScene()!.getEngine();
             this._generateMipMaps = generateMipMaps;
-            this._samplingMode = samplingMode;
+            this._initialSamplingMode = samplingMode;
             this.autoUpdateTexture = settings.autoUpdateTexture;
 
             this.name = name || this._getName(src);
@@ -184,7 +184,7 @@ module BABYLON {
                 this.video.videoWidth,
                 this.video.videoHeight,
                 this._generateMipMaps,
-                this._samplingMode
+                this.samplingMode
             );
 
             if (!this.video.autoplay && !this._settings.poster) {

+ 1 - 1
src/Tools/babylon.textureTools.ts

@@ -24,7 +24,7 @@ module BABYLON {
                 true,
                 (<InternalTexture>texture._texture).type,
                 false,
-                texture._samplingMode,
+                texture.samplingMode,
                 false
             );