提交 38ad9b56 编写于 作者: D dubejf

Use version counter for texture updates.

- Use version counter for texture updates.
- WebGLTextures is not used (removed).
上级 fe245700
......@@ -3217,9 +3217,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
this.uploadTexture = function ( texture, slot ) {
var textureProperties = properties.get( texture );
function uploadTexture( textureProperties, texture, slot ) {
if ( textureProperties.__webglInit === undefined ) {
......@@ -3329,15 +3327,17 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( texture.generateMipmaps && isImagePowerOfTwo ) _gl.generateMipmap( _gl.TEXTURE_2D );
texture.needsUpdate = false;
textureProperties.__version = texture.version;
if ( texture.onUpdate ) texture.onUpdate( texture );
};
}
this.setTexture = function ( texture, slot ) {
if ( texture.needsUpdate === true ) {
var textureProperties = properties.get( texture );
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
var image = texture.image;
......@@ -3355,13 +3355,13 @@ THREE.WebGLRenderer = function ( parameters ) {
}
_this.uploadTexture( texture, slot );
uploadTexture( textureProperties, texture, slot );
return;
}
state.activeTexture( _gl.TEXTURE0 + slot );
state.bindTexture( _gl.TEXTURE_2D, properties.get( texture ).__webglTexture );
state.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );
};
......@@ -3397,7 +3397,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( texture.image.length === 6 ) {
if ( texture.needsUpdate ) {
if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
if ( ! textureProperties.__image__webglTextureCube ) {
......@@ -3492,7 +3492,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
texture.needsUpdate = false;
textureProperties.__version = texture.version;
if ( texture.onUpdate ) texture.onUpdate( texture );
......
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.WebGLTextures = function ( gl ) {
var textures = {};
this.get = function ( texture ) {
if ( textures[ texture.id ] !== undefined ) {
return textures[ texture.id ];
}
return this.create( texture );
};
this.create = function ( texture ) {
texture.addEventListener( 'dispose', this.delete );
textures[ texture.id ] = gl.createTexture();
return textures[ texture.id ];
};
this.delete = function ( texture ) {
texture.removeEventListener( 'dispose', this.delete );
gl.deleteTexture( textures[ texture.id ] );
delete textures[ texture.id ];
};
};
......@@ -37,7 +37,7 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter, f
this.flipY = true;
this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
this._needsUpdate = false;
this.version = 0;
this.onUpdate = null;
};
......@@ -49,17 +49,11 @@ THREE.Texture.prototype = {
constructor: THREE.Texture,
get needsUpdate () {
return this._needsUpdate;
},
set needsUpdate ( value ) {
if ( value === true ) this.update();
this._needsUpdate = value;
this.version ++;
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册