提交 ec0bd8ad 编写于 作者: M Mugen87

VideoTexture: Refactor update

上级 84c0b9fb
......@@ -1124,6 +1124,10 @@ function WebGLRenderer( parameters ) {
//
textures.updateVideoTextures();
//
if ( _clippingEnabled ) _clipping.beginShadows();
shadowMap.render( shadowsArray, scene, camera );
......
......@@ -8,6 +8,7 @@ import { _Math } from '../../math/Math.js';
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, infoMemory ) {
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof window.WebGL2RenderingContext );
var _videoTextures = {};
//
......@@ -102,8 +103,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
deallocateTexture( texture );
infoMemory.textures --;
if ( texture.isVideoTexture ) {
delete _videoTextures[ texture.id ];
}
infoMemory.textures --;
}
......@@ -405,6 +411,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
textureProperties.__webglTexture = _gl.createTexture();
if ( texture.isVideoTexture ) {
_videoTextures[ texture.id ] = texture;
}
infoMemory.textures ++;
}
......@@ -786,11 +798,22 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
function updateVideoTextures() {
for ( var id in _videoTextures ) {
_videoTextures[ id ].update();
}
}
this.setTexture2D = setTexture2D;
this.setTextureCube = setTextureCube;
this.setTextureCubeDynamic = setTextureCubeDynamic;
this.setupRenderTarget = setupRenderTarget;
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
this.updateVideoTextures = updateVideoTextures;
}
......
......@@ -9,29 +9,29 @@ function VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, forma
Texture.call( this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.generateMipmaps = false;
this.needsUpdate = true;
var scope = this;
}
function update() {
VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), {
var video = scope.image;
constructor: VideoTexture,
if ( video.readyState >= video.HAVE_CURRENT_DATA ) {
isVideoTexture: true,
scope.needsUpdate = true;
update: function () {
}
var video = this.image;
requestAnimationFrame( update );
if ( video.readyState >= video.HAVE_CURRENT_DATA ) {
}
this.needsUpdate = true;
requestAnimationFrame( update );
}
}
}
VideoTexture.prototype = Object.create( Texture.prototype );
VideoTexture.prototype.constructor = VideoTexture;
} );
export { VideoTexture };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册