|
@@ -5,7 +5,7 @@
|
|
|
import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants.js';
|
|
|
import { _Math } from '../../math/Math.js';
|
|
|
|
|
|
-function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, infoMemory ) {
|
|
|
+function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, infoMemory, infoRender ) {
|
|
|
|
|
|
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
|
|
|
var _videoTextures = {};
|
|
@@ -200,6 +200,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
var textureProperties = properties.get( texture );
|
|
|
|
|
|
+ if ( texture.isVideoTexture ) updateVideoTexture( texture );
|
|
|
+
|
|
|
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
|
|
|
|
|
|
var image = texture.image;
|
|
@@ -411,12 +413,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
textureProperties.__webglTexture = _gl.createTexture();
|
|
|
|
|
|
- if ( texture.isVideoTexture ) {
|
|
|
-
|
|
|
- _videoTextures[ texture.id ] = texture;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
infoMemory.textures ++;
|
|
|
|
|
|
}
|
|
@@ -798,11 +794,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
}
|
|
|
|
|
|
- function updateVideoTextures() {
|
|
|
+ function updateVideoTexture( texture ) {
|
|
|
+
|
|
|
+ var id = texture.id;
|
|
|
+ var frame = infoRender.frame;
|
|
|
+
|
|
|
+ // Check the last frame we updated the VideoTexture
|
|
|
|
|
|
- for ( var id in _videoTextures ) {
|
|
|
+ if ( _videoTextures[ id ] !== frame ) {
|
|
|
|
|
|
- _videoTextures[ id ].update();
|
|
|
+ _videoTextures[ id ] = frame;
|
|
|
+ texture.update();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -813,7 +815,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
this.setTextureCubeDynamic = setTextureCubeDynamic;
|
|
|
this.setupRenderTarget = setupRenderTarget;
|
|
|
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
|
|
|
- this.updateVideoTextures = updateVideoTextures;
|
|
|
|
|
|
}
|
|
|
|