Browse Source

Need to set correct slot as gl.activeTexture in setTexture

Fixes lightMap bug https://github.com/mrdoob/three.js/issues/458
Andrew Wason 14 years ago
parent
commit
ce76a7406c
1 changed files with 4 additions and 6 deletions
  1. 4 6
      src/renderers/WebGLRenderer.js

+ 4 - 6
src/renderers/WebGLRenderer.js

@@ -4842,6 +4842,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
+			_gl.activeTexture( _gl.TEXTURE0 + slot );
 			_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
 
 			if ( texture.image.data ) {
@@ -4856,10 +4857,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			setTextureParameters( _gl.TEXTURE_2D, texture, texture.image );
 
-			_gl.bindTexture( _gl.TEXTURE_2D, null );
-
 			texture.needsUpdate = false;
 
+		} else {
+			_gl.activeTexture( _gl.TEXTURE0 + slot );
+			_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
 		}
 
 		/*
@@ -4890,10 +4892,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 		*/
 
-		_gl.activeTexture( _gl.TEXTURE0 + slot );
-		_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
-
-
 	};
 
 	function setCubeTexture( texture, slot ) {