Browse Source

videoTexture fix

David Catuhe 8 years ago
parent
commit
e9a37918d7

File diff suppressed because it is too large
+ 22 - 22
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 4513 - 4512
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 30 - 30
dist/preview release/babylon.js


+ 28 - 0
dist/preview release/babylon.max.js

@@ -12325,6 +12325,26 @@ var BABYLON;
             enumerable: true,
             configurable: true
         });
+        Object.defineProperty(AbstractMesh.prototype, "material", {
+            get: function () {
+                return this._material;
+            },
+            set: function (value) {
+                if (this._material === value) {
+                    return;
+                }
+                this._material = value;
+                if (!this.subMeshes) {
+                    return;
+                }
+                for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
+                    var subMesh = _a[_i];
+                    subMesh.effect = null;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
             get: function () {
                 return this._receiveShadows;
@@ -26106,6 +26126,10 @@ var BABYLON;
                 return this._materialEffect;
             },
             set: function (effect) {
+                if (this._materialEffect === effect) {
+                    return;
+                }
+                this._materialDefines = null;
                 this._materialEffect = effect;
             },
             enumerable: true,
@@ -29048,6 +29072,7 @@ var BABYLON;
         }
         VideoTexture.prototype._createTexture = function () {
             this._texture = this.getScene().getEngine().createDynamicTexture(this.video.videoWidth, this.video.videoHeight, this._generateMipMaps, this._samplingMode);
+            this.getScene().getEngine().updateVideoTexture(this._texture, this.video, this._invertY);
             this._texture.isReady = true;
         };
         VideoTexture.prototype.update = function () {
@@ -31845,6 +31870,9 @@ var BABYLON;
         StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
             var scene = this.getScene();
             var defines = subMesh._materialDefines;
+            if (!defines) {
+                return;
+            }
             var effect = subMesh.effect;
             this._activeEffect = effect;
             // Matrices        

File diff suppressed because it is too large
+ 4513 - 4512
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 30 - 30
dist/preview release/babylon.noworker.js


+ 0 - 1
src/Materials/Textures/babylon.videoTexture.ts

@@ -99,7 +99,6 @@
 		    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
 		    window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
 
-
 		    if (navigator.getUserMedia) {
 			    navigator.getUserMedia({                     
                     video: {

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

@@ -1079,6 +1079,9 @@ module BABYLON {
             var scene = this.getScene();
 
             var defines = <StandardMaterialDefines>subMesh._materialDefines;
+            if (!defines) {
+                return;
+            }
 
             var effect = subMesh.effect;
             this._activeEffect = effect;

+ 19 - 1
src/Mesh/babylon.abstractMesh.ts

@@ -128,7 +128,25 @@
         public showSubMeshesBoundingBox = false;
         public isBlocker = false;
         public renderingGroupId = 0;
-        public material: Material;
+        private _material: Material
+        public get material(): Material {
+            return this._material;
+        }
+        public set material(value: Material) {
+            if (this._material === value) {
+                return;
+            }
+
+            this._material = value;
+            if (!this.subMeshes) {
+                return;
+            }
+            
+            for (var subMesh of this.subMeshes) {
+                subMesh.effect = null;
+            }
+        }
+
         private _receiveShadows = false;
         public get receiveShadows(): boolean {
             return this._receiveShadows;

+ 4 - 0
src/Mesh/babylon.subMesh.ts

@@ -23,6 +23,10 @@
         }
 
         public set effect(effect: Effect) {
+            if (this._materialEffect === effect) {
+                return;
+            }
+            this._materialDefines = null;
             this._materialEffect = effect;
         }
 

+ 5 - 1
src/babylon.engine.ts

@@ -3124,7 +3124,11 @@
             if (texture instanceof VideoTexture) {
                 this.activateTexture(this._gl["TEXTURE" + channel]);
                 alreadyActivated = true;
-                texture.update();
+                if (!texture.update()) {
+                    this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
+                    this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
+                    return;
+                }
             } else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
                 texture.delayLoad();
                 return;