Mr.doob пре 4 година
родитељ
комит
dd7cf08e78
3 измењених фајлова са 294 додато и 312 уклоњено
  1. 121 128
      build/three.js
  2. 0 0
      build/three.min.js
  3. 173 184
      build/three.module.js

+ 121 - 128
build/three.js

@@ -9339,6 +9339,27 @@
 	CubeCamera.prototype = Object.create(Object3D.prototype);
 	CubeCamera.prototype = Object.create(Object3D.prototype);
 	CubeCamera.prototype.constructor = CubeCamera;
 	CubeCamera.prototype.constructor = CubeCamera;
 
 
+	function CubeTexture(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
+		images = images !== undefined ? images : [];
+		mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
+		format = format !== undefined ? format : RGBFormat;
+		Texture.call(this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
+		this.flipY = false;
+		this._needsFlipEnvMap = true;
+	}
+
+	CubeTexture.prototype = Object.create(Texture.prototype);
+	CubeTexture.prototype.constructor = CubeTexture;
+	CubeTexture.prototype.isCubeTexture = true;
+	Object.defineProperty(CubeTexture.prototype, 'images', {
+		get: function get() {
+			return this.image;
+		},
+		set: function set(value) {
+			this.image = value;
+		}
+	});
+
 	function WebGLCubeRenderTarget(size, options, dummy) {
 	function WebGLCubeRenderTarget(size, options, dummy) {
 		if (Number.isInteger(options)) {
 		if (Number.isInteger(options)) {
 			console.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )');
 			console.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )');
@@ -9346,7 +9367,9 @@
 		}
 		}
 
 
 		WebGLRenderTarget.call(this, size, size, options);
 		WebGLRenderTarget.call(this, size, size, options);
-		this.texture.isWebGLCubeRenderTargetTexture = true; // HACK Why is texture not a CubeTexture?
+		options = options || {};
+		this.texture = new CubeTexture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);
+		this.texture._needsFlipEnvMap = false;
 	}
 	}
 
 
 	WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
 	WebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);
@@ -10653,7 +10676,7 @@
 				renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
 				renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
 			}
 			}
 
 
-			if (background && (background.isCubeTexture || background.isWebGLCubeRenderTarget || background.isWebGLCubeRenderTargetTexture || background.mapping === CubeUVReflectionMapping)) {
+			if (background && (background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping)) {
 				if (boxMesh === undefined) {
 				if (boxMesh === undefined) {
 					boxMesh = new Mesh(new BoxBufferGeometry(1, 1, 1), new ShaderMaterial({
 					boxMesh = new Mesh(new BoxBufferGeometry(1, 1, 1), new ShaderMaterial({
 						name: 'BackgroundCubeMaterial',
 						name: 'BackgroundCubeMaterial',
@@ -10687,7 +10710,7 @@
 				}
 				}
 
 
 				boxMesh.material.uniforms.envMap.value = background;
 				boxMesh.material.uniforms.envMap.value = background;
-				boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture ? -1 : 1;
+				boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background._needsFlipEnvMap ? -1 : 1;
 
 
 				if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
 				if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
 					boxMesh.material.needsUpdate = true;
 					boxMesh.material.needsUpdate = true;
@@ -11881,26 +11904,6 @@
 		};
 		};
 	}
 	}
 
 
-	function CubeTexture(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {
-		images = images !== undefined ? images : [];
-		mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
-		format = format !== undefined ? format : RGBFormat;
-		Texture.call(this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);
-		this.flipY = false;
-	}
-
-	CubeTexture.prototype = Object.create(Texture.prototype);
-	CubeTexture.prototype.constructor = CubeTexture;
-	CubeTexture.prototype.isCubeTexture = true;
-	Object.defineProperty(CubeTexture.prototype, 'images', {
-		get: function get() {
-			return this.image;
-		},
-		set: function set(value) {
-			this.image = value;
-		}
-	});
-
 	function DataTexture2DArray(data, width, height, depth) {
 	function DataTexture2DArray(data, width, height, depth) {
 		Texture.call(this, null);
 		Texture.call(this, null);
 		this.image = {
 		this.image = {
@@ -15287,97 +15290,15 @@
 		}
 		}
 
 
 		function setTextureCube(texture, slot) {
 		function setTextureCube(texture, slot) {
-			if (texture.image.length !== 6) return;
 			var textureProperties = properties.get(texture);
 			var textureProperties = properties.get(texture);
 
 
 			if (texture.version > 0 && textureProperties.__version !== texture.version) {
 			if (texture.version > 0 && textureProperties.__version !== texture.version) {
-				initTexture(textureProperties, texture);
-				state.activeTexture(33984 + slot);
-				state.bindTexture(34067, textureProperties.__webglTexture);
-
-				_gl.pixelStorei(37440, texture.flipY);
-
-				var isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture);
-				var isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
-				var cubeImage = [];
-
-				for (var i = 0; i < 6; i++) {
-					if (!isCompressed && !isDataTexture) {
-						cubeImage[i] = resizeImage(texture.image[i], false, true, maxCubemapSize);
-					} else {
-						cubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i];
-					}
-				}
-
-				var image = cubeImage[0],
-						supportsMips = isPowerOfTwo(image) || isWebGL2,
-						glFormat = utils.convert(texture.format),
-						glType = utils.convert(texture.type),
-						glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
-				setTextureParameters(34067, texture, supportsMips);
-				var mipmaps;
-
-				if (isCompressed) {
-					for (var _i = 0; _i < 6; _i++) {
-						mipmaps = cubeImage[_i].mipmaps;
-
-						for (var j = 0; j < mipmaps.length; j++) {
-							var mipmap = mipmaps[j];
-
-							if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
-								if (glFormat !== null) {
-									state.compressedTexImage2D(34069 + _i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
-								} else {
-									console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
-								}
-							} else {
-								state.texImage2D(34069 + _i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
-							}
-						}
-					}
-
-					textureProperties.__maxMipLevel = mipmaps.length - 1;
-				} else {
-					mipmaps = texture.mipmaps;
-
-					for (var _i2 = 0; _i2 < 6; _i2++) {
-						if (isDataTexture) {
-							state.texImage2D(34069 + _i2, 0, glInternalFormat, cubeImage[_i2].width, cubeImage[_i2].height, 0, glFormat, glType, cubeImage[_i2].data);
-
-							for (var _j = 0; _j < mipmaps.length; _j++) {
-								var _mipmap = mipmaps[_j];
-								var mipmapImage = _mipmap.image[_i2].image;
-								state.texImage2D(34069 + _i2, _j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
-							}
-						} else {
-							state.texImage2D(34069 + _i2, 0, glInternalFormat, glFormat, glType, cubeImage[_i2]);
-
-							for (var _j2 = 0; _j2 < mipmaps.length; _j2++) {
-								var _mipmap2 = mipmaps[_j2];
-								state.texImage2D(34069 + _i2, _j2 + 1, glInternalFormat, glFormat, glType, _mipmap2.image[_i2]);
-							}
-						}
-					}
-
-					textureProperties.__maxMipLevel = mipmaps.length;
-				}
-
-				if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
-					// We assume images for cube map have the same size.
-					generateMipmap(34067, texture, image.width, image.height);
-				}
-
-				textureProperties.__version = texture.version;
-				if (texture.onUpdate) texture.onUpdate(texture);
-			} else {
-				state.activeTexture(33984 + slot);
-				state.bindTexture(34067, textureProperties.__webglTexture);
+				uploadCubeTexture(textureProperties, texture, slot);
+				return;
 			}
 			}
-		}
 
 
-		function setTextureCubeDynamic(texture, slot) {
 			state.activeTexture(33984 + slot);
 			state.activeTexture(33984 + slot);
-			state.bindTexture(34067, properties.get(texture).__webglTexture);
+			state.bindTexture(34067, textureProperties.__webglTexture);
 		}
 		}
 
 
 		var wrappingToGL = (_wrappingToGL = {}, _wrappingToGL[RepeatWrapping] = 10497, _wrappingToGL[ClampToEdgeWrapping] = 33071, _wrappingToGL[MirroredRepeatWrapping] = 33648, _wrappingToGL);
 		var wrappingToGL = (_wrappingToGL = {}, _wrappingToGL[RepeatWrapping] = 10497, _wrappingToGL[ClampToEdgeWrapping] = 33071, _wrappingToGL[MirroredRepeatWrapping] = 33648, _wrappingToGL);
@@ -15530,17 +15451,17 @@
 					textureProperties.__maxMipLevel = 0;
 					textureProperties.__maxMipLevel = 0;
 				}
 				}
 			} else if (texture.isCompressedTexture) {
 			} else if (texture.isCompressedTexture) {
-				for (var _i3 = 0, _il = mipmaps.length; _i3 < _il; _i3++) {
-					mipmap = mipmaps[_i3];
+				for (var _i = 0, _il = mipmaps.length; _i < _il; _i++) {
+					mipmap = mipmaps[_i];
 
 
 					if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
 					if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
 						if (glFormat !== null) {
 						if (glFormat !== null) {
-							state.compressedTexImage2D(3553, _i3, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
+							state.compressedTexImage2D(3553, _i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
 						} else {
 						} else {
 							console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
 							console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');
 						}
 						}
 					} else {
 					} else {
-						state.texImage2D(3553, _i3, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
+						state.texImage2D(3553, _i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
 					}
 					}
 				}
 				}
 
 
@@ -15557,9 +15478,9 @@
 				// if there are no manual mipmaps
 				// if there are no manual mipmaps
 				// set 0 level mipmap and then use GL to generate other mipmap levels
 				// set 0 level mipmap and then use GL to generate other mipmap levels
 				if (mipmaps.length > 0 && supportsMips) {
 				if (mipmaps.length > 0 && supportsMips) {
-					for (var _i4 = 0, _il2 = mipmaps.length; _i4 < _il2; _i4++) {
-						mipmap = mipmaps[_i4];
-						state.texImage2D(3553, _i4, glInternalFormat, glFormat, glType, mipmap);
+					for (var _i2 = 0, _il2 = mipmaps.length; _i2 < _il2; _i2++) {
+						mipmap = mipmaps[_i2];
+						state.texImage2D(3553, _i2, glInternalFormat, glFormat, glType, mipmap);
 					}
 					}
 
 
 					texture.generateMipmaps = false;
 					texture.generateMipmaps = false;
@@ -15574,6 +15495,88 @@
 				generateMipmap(textureType, texture, image.width, image.height);
 				generateMipmap(textureType, texture, image.width, image.height);
 			}
 			}
 
 
+			textureProperties.__version = texture.version;
+			if (texture.onUpdate) texture.onUpdate(texture);
+		}
+
+		function uploadCubeTexture(textureProperties, texture, slot) {
+			if (texture.image.length !== 6) return;
+			initTexture(textureProperties, texture);
+			state.activeTexture(33984 + slot);
+			state.bindTexture(34067, textureProperties.__webglTexture);
+
+			_gl.pixelStorei(37440, texture.flipY);
+
+			var isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture);
+			var isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
+			var cubeImage = [];
+
+			for (var i = 0; i < 6; i++) {
+				if (!isCompressed && !isDataTexture) {
+					cubeImage[i] = resizeImage(texture.image[i], false, true, maxCubemapSize);
+				} else {
+					cubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i];
+				}
+			}
+
+			var image = cubeImage[0],
+					supportsMips = isPowerOfTwo(image) || isWebGL2,
+					glFormat = utils.convert(texture.format),
+					glType = utils.convert(texture.type),
+					glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);
+			setTextureParameters(34067, texture, supportsMips);
+			var mipmaps;
+
+			if (isCompressed) {
+				for (var _i3 = 0; _i3 < 6; _i3++) {
+					mipmaps = cubeImage[_i3].mipmaps;
+
+					for (var j = 0; j < mipmaps.length; j++) {
+						var mipmap = mipmaps[j];
+
+						if (texture.format !== RGBAFormat && texture.format !== RGBFormat) {
+							if (glFormat !== null) {
+								state.compressedTexImage2D(34069 + _i3, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);
+							} else {
+								console.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');
+							}
+						} else {
+							state.texImage2D(34069 + _i3, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);
+						}
+					}
+				}
+
+				textureProperties.__maxMipLevel = mipmaps.length - 1;
+			} else {
+				mipmaps = texture.mipmaps;
+
+				for (var _i4 = 0; _i4 < 6; _i4++) {
+					if (isDataTexture) {
+						state.texImage2D(34069 + _i4, 0, glInternalFormat, cubeImage[_i4].width, cubeImage[_i4].height, 0, glFormat, glType, cubeImage[_i4].data);
+
+						for (var _j = 0; _j < mipmaps.length; _j++) {
+							var _mipmap = mipmaps[_j];
+							var mipmapImage = _mipmap.image[_i4].image;
+							state.texImage2D(34069 + _i4, _j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);
+						}
+					} else {
+						state.texImage2D(34069 + _i4, 0, glInternalFormat, glFormat, glType, cubeImage[_i4]);
+
+						for (var _j2 = 0; _j2 < mipmaps.length; _j2++) {
+							var _mipmap2 = mipmaps[_j2];
+							state.texImage2D(34069 + _i4, _j2 + 1, glInternalFormat, glFormat, glType, _mipmap2.image[_i4]);
+						}
+					}
+				}
+
+				textureProperties.__maxMipLevel = mipmaps.length;
+			}
+
+			if (textureNeedsGenerateMipmaps(texture, supportsMips)) {
+				// We assume images for cube map have the same size.
+				generateMipmap(34067, texture, image.width, image.height);
+			}
+
 			textureProperties.__version = texture.version;
 			textureProperties.__version = texture.version;
 			if (texture.onUpdate) texture.onUpdate(texture);
 			if (texture.onUpdate) texture.onUpdate(texture);
 		} // Render targets
 		} // Render targets
@@ -15876,18 +15879,9 @@
 				}
 				}
 
 
 				texture = texture.texture;
 				texture = texture.texture;
-			} // currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture
-			// TODO: unify these code paths
-
-
-			if (texture && texture.isCubeTexture || Array.isArray(texture.image) && texture.image.length === 6) {
-				// CompressedTexture can have Array in image :/
-				// this function alone should take care of cube textures
-				setTextureCube(texture, slot);
-			} else {
-				// assumed: texture property of THREE.WebGLCubeRenderTarget
-				setTextureCubeDynamic(texture, slot);
 			}
 			}
+
+			setTextureCube(texture, slot);
 		} //
 		} //
 
 
 
 
@@ -15897,7 +15891,6 @@
 		this.setTexture2DArray = setTexture2DArray;
 		this.setTexture2DArray = setTexture2DArray;
 		this.setTexture3D = setTexture3D;
 		this.setTexture3D = setTexture3D;
 		this.setTextureCube = setTextureCube;
 		this.setTextureCube = setTextureCube;
-		this.setTextureCubeDynamic = setTextureCubeDynamic;
 		this.setupRenderTarget = setupRenderTarget;
 		this.setupRenderTarget = setupRenderTarget;
 		this.updateRenderTargetMipmap = updateRenderTargetMipmap;
 		this.updateRenderTargetMipmap = updateRenderTargetMipmap;
 		this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
 		this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
@@ -16666,7 +16659,7 @@
 
 
 			if (envMap) {
 			if (envMap) {
 				uniforms.envMap.value = envMap;
 				uniforms.envMap.value = envMap;
-				uniforms.flipEnvMap.value = envMap.isCubeTexture ? -1 : 1;
+				uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap._needsFlipEnvMap ? -1 : 1;
 				uniforms.reflectivity.value = material.reflectivity;
 				uniforms.reflectivity.value = material.reflectivity;
 				uniforms.refractionRatio.value = material.refractionRatio;
 				uniforms.refractionRatio.value = material.refractionRatio;
 
 

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
build/three.min.js


+ 173 - 184
build/three.module.js

@@ -12326,6 +12326,41 @@ function CubeCamera( near, far, renderTarget ) {
 CubeCamera.prototype = Object.create( Object3D.prototype );
 CubeCamera.prototype = Object.create( Object3D.prototype );
 CubeCamera.prototype.constructor = CubeCamera;
 CubeCamera.prototype.constructor = CubeCamera;
 
 
+function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+
+	images = images !== undefined ? images : [];
+	mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
+	format = format !== undefined ? format : RGBFormat;
+
+	Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+
+	this.flipY = false;
+
+	this._needsFlipEnvMap = true;
+
+}
+
+CubeTexture.prototype = Object.create( Texture.prototype );
+CubeTexture.prototype.constructor = CubeTexture;
+
+CubeTexture.prototype.isCubeTexture = true;
+
+Object.defineProperty( CubeTexture.prototype, 'images', {
+
+	get: function () {
+
+		return this.image;
+
+	},
+
+	set: function ( value ) {
+
+		this.image = value;
+
+	}
+
+} );
+
 function WebGLCubeRenderTarget( size, options, dummy ) {
 function WebGLCubeRenderTarget( size, options, dummy ) {
 
 
 	if ( Number.isInteger( options ) ) {
 	if ( Number.isInteger( options ) ) {
@@ -12338,7 +12373,11 @@ function WebGLCubeRenderTarget( size, options, dummy ) {
 
 
 	WebGLRenderTarget.call( this, size, size, options );
 	WebGLRenderTarget.call( this, size, size, options );
 
 
-	this.texture.isWebGLCubeRenderTargetTexture = true; // HACK Why is texture not a CubeTexture?
+	options = options || {};
+
+	this.texture = new CubeTexture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+
+	this.texture._needsFlipEnvMap = false;
 
 
 }
 }
 
 
@@ -13888,7 +13927,7 @@ function WebGLBackground( renderer, cubemaps, state, objects, premultipliedAlpha
 
 
 		}
 		}
 
 
-		if ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.isWebGLCubeRenderTargetTexture || background.mapping === CubeUVReflectionMapping ) ) {
+		if ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) {
 
 
 			if ( boxMesh === undefined ) {
 			if ( boxMesh === undefined ) {
 
 
@@ -13939,7 +13978,7 @@ function WebGLBackground( renderer, cubemaps, state, objects, premultipliedAlpha
 			}
 			}
 
 
 			boxMesh.material.uniforms.envMap.value = background;
 			boxMesh.material.uniforms.envMap.value = background;
-			boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture ? - 1 : 1;
+			boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background._needsFlipEnvMap ) ? - 1 : 1;
 
 
 			if ( currentBackground !== background ||
 			if ( currentBackground !== background ||
 				currentBackgroundVersion !== background.version ||
 				currentBackgroundVersion !== background.version ||
@@ -15674,39 +15713,6 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 
 }
 }
 
 
-function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
-
-	images = images !== undefined ? images : [];
-	mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
-	format = format !== undefined ? format : RGBFormat;
-
-	Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
-
-	this.flipY = false;
-
-}
-
-CubeTexture.prototype = Object.create( Texture.prototype );
-CubeTexture.prototype.constructor = CubeTexture;
-
-CubeTexture.prototype.isCubeTexture = true;
-
-Object.defineProperty( CubeTexture.prototype, 'images', {
-
-	get: function () {
-
-		return this.image;
-
-	},
-
-	set: function ( value ) {
-
-		this.image = value;
-
-	}
-
-} );
-
 function DataTexture2DArray( data, width, height, depth ) {
 function DataTexture2DArray( data, width, height, depth ) {
 
 
 	Texture.call( this, null );
 	Texture.call( this, null );
@@ -20620,145 +20626,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 	function setTextureCube( texture, slot ) {
 	function setTextureCube( texture, slot ) {
 
 
-		if ( texture.image.length !== 6 ) return;
-
 		const textureProperties = properties.get( texture );
 		const textureProperties = properties.get( texture );
 
 
 		if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
 		if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
 
 
-			initTexture( textureProperties, texture );
-
-			state.activeTexture( 33984 + slot );
-			state.bindTexture( 34067, textureProperties.__webglTexture );
-
-			_gl.pixelStorei( 37440, texture.flipY );
-
-			const isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );
-			const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
-
-			const cubeImage = [];
-
-			for ( let i = 0; i < 6; i ++ ) {
-
-				if ( ! isCompressed && ! isDataTexture ) {
-
-					cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
-
-				} else {
-
-					cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];
-
-				}
-
-			}
-
-			const image = cubeImage[ 0 ],
-				supportsMips = isPowerOfTwo( image ) || isWebGL2,
-				glFormat = utils.convert( texture.format ),
-				glType = utils.convert( texture.type ),
-				glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
-
-			setTextureParameters( 34067, texture, supportsMips );
-
-			let mipmaps;
-
-			if ( isCompressed ) {
-
-				for ( let i = 0; i < 6; i ++ ) {
-
-					mipmaps = cubeImage[ i ].mipmaps;
-
-					for ( let j = 0; j < mipmaps.length; j ++ ) {
-
-						const mipmap = mipmaps[ j ];
-
-						if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
-
-							if ( glFormat !== null ) {
-
-								state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
-
-							} else {
-
-								console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
-
-							}
-
-						} else {
-
-							state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
-
-						}
-
-					}
-
-				}
-
-				textureProperties.__maxMipLevel = mipmaps.length - 1;
-
-			} else {
-
-				mipmaps = texture.mipmaps;
-
-				for ( let i = 0; i < 6; i ++ ) {
-
-					if ( isDataTexture ) {
-
-						state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
-
-						for ( let j = 0; j < mipmaps.length; j ++ ) {
-
-							const mipmap = mipmaps[ j ];
-							const mipmapImage = mipmap.image[ i ].image;
-
-							state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
-
-						}
-
-					} else {
-
-						state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
-
-						for ( let j = 0; j < mipmaps.length; j ++ ) {
-
-							const mipmap = mipmaps[ j ];
-
-							state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
-
-						}
-
-					}
-
-				}
-
-				textureProperties.__maxMipLevel = mipmaps.length;
-
-			}
-
-			if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
-
-				// We assume images for cube map have the same size.
-				generateMipmap( 34067, texture, image.width, image.height );
-
-			}
-
-			textureProperties.__version = texture.version;
-
-			if ( texture.onUpdate ) texture.onUpdate( texture );
-
-		} else {
-
-			state.activeTexture( 33984 + slot );
-			state.bindTexture( 34067, textureProperties.__webglTexture );
+			uploadCubeTexture( textureProperties, texture, slot );
+			return;
 
 
 		}
 		}
 
 
-	}
-
-	function setTextureCubeDynamic( texture, slot ) {
-
 		state.activeTexture( 33984 + slot );
 		state.activeTexture( 33984 + slot );
-		state.bindTexture( 34067, properties.get( texture ).__webglTexture );
+		state.bindTexture( 34067, textureProperties.__webglTexture );
 
 
 	}
 	}
 
 
@@ -21068,6 +20946,132 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 	}
 	}
 
 
+	function uploadCubeTexture( textureProperties, texture, slot ) {
+
+		if ( texture.image.length !== 6 ) return;
+
+		initTexture( textureProperties, texture );
+
+		state.activeTexture( 33984 + slot );
+		state.bindTexture( 34067, textureProperties.__webglTexture );
+
+		_gl.pixelStorei( 37440, texture.flipY );
+
+		const isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );
+		const isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );
+
+		const cubeImage = [];
+
+		for ( let i = 0; i < 6; i ++ ) {
+
+			if ( ! isCompressed && ! isDataTexture ) {
+
+				cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
+
+			} else {
+
+				cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];
+
+			}
+
+		}
+
+		const image = cubeImage[ 0 ],
+			supportsMips = isPowerOfTwo( image ) || isWebGL2,
+			glFormat = utils.convert( texture.format ),
+			glType = utils.convert( texture.type ),
+			glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );
+
+		setTextureParameters( 34067, texture, supportsMips );
+
+		let mipmaps;
+
+		if ( isCompressed ) {
+
+			for ( let i = 0; i < 6; i ++ ) {
+
+				mipmaps = cubeImage[ i ].mipmaps;
+
+				for ( let j = 0; j < mipmaps.length; j ++ ) {
+
+					const mipmap = mipmaps[ j ];
+
+					if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {
+
+						if ( glFormat !== null ) {
+
+							state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
+
+						} else {
+
+							console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );
+
+						}
+
+					} else {
+
+						state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
+
+					}
+
+				}
+
+			}
+
+			textureProperties.__maxMipLevel = mipmaps.length - 1;
+
+		} else {
+
+			mipmaps = texture.mipmaps;
+
+			for ( let i = 0; i < 6; i ++ ) {
+
+				if ( isDataTexture ) {
+
+					state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );
+
+					for ( let j = 0; j < mipmaps.length; j ++ ) {
+
+						const mipmap = mipmaps[ j ];
+						const mipmapImage = mipmap.image[ i ].image;
+
+						state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );
+
+					}
+
+				} else {
+
+					state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
+
+					for ( let j = 0; j < mipmaps.length; j ++ ) {
+
+						const mipmap = mipmaps[ j ];
+
+						state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
+
+					}
+
+				}
+
+			}
+
+			textureProperties.__maxMipLevel = mipmaps.length;
+
+		}
+
+		if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
+
+			// We assume images for cube map have the same size.
+			generateMipmap( 34067, texture, image.width, image.height );
+
+		}
+
+		textureProperties.__version = texture.version;
+
+		if ( texture.onUpdate ) texture.onUpdate( texture );
+
+	}
+
 	// Render targets
 	// Render targets
 
 
 	// Setup storage for target texture and bind it to correct framebuffer
 	// Setup storage for target texture and bind it to correct framebuffer
@@ -21488,22 +21492,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
-		// currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture
-		// TODO: unify these code paths
-		if ( ( texture && texture.isCubeTexture ) ||
-			( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {
-
-			// CompressedTexture can have Array in image :/
-
-			// this function alone should take care of cube textures
-			setTextureCube( texture, slot );
 
 
-		} else {
-
-			// assumed: texture property of THREE.WebGLCubeRenderTarget
-			setTextureCubeDynamic( texture, slot );
-
-		}
+		setTextureCube( texture, slot );
 
 
 	}
 	}
 
 
@@ -21516,7 +21506,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 	this.setTexture2DArray = setTexture2DArray;
 	this.setTexture2DArray = setTexture2DArray;
 	this.setTexture3D = setTexture3D;
 	this.setTexture3D = setTexture3D;
 	this.setTextureCube = setTextureCube;
 	this.setTextureCube = setTextureCube;
-	this.setTextureCubeDynamic = setTextureCubeDynamic;
 	this.setupRenderTarget = setupRenderTarget;
 	this.setupRenderTarget = setupRenderTarget;
 	this.updateRenderTargetMipmap = updateRenderTargetMipmap;
 	this.updateRenderTargetMipmap = updateRenderTargetMipmap;
 	this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
 	this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
@@ -22624,7 +22613,7 @@ function WebGLMaterials( properties ) {
 
 
 			uniforms.envMap.value = envMap;
 			uniforms.envMap.value = envMap;
 
 
-			uniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;
+			uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap._needsFlipEnvMap ) ? - 1 : 1;
 
 
 			uniforms.reflectivity.value = material.reflectivity;
 			uniforms.reflectivity.value = material.reflectivity;
 			uniforms.refractionRatio.value = material.refractionRatio;
 			uniforms.refractionRatio.value = material.refractionRatio;

Неке датотеке нису приказане због велике количине промена