浏览代码

Updated builds.

Mugen87 1 年之前
父节点
当前提交
528ab95777
共有 3 个文件被更改,包括 268 次插入330 次删除
  1. 134 165
      build/three.cjs
  2. 134 165
      build/three.module.js
  3. 0 0
      build/three.module.min.js

+ 134 - 165
build/three.cjs

@@ -2913,15 +2913,25 @@ class RenderTarget extends EventDispatcher {
 			depthBuffer: true,
 			depthBuffer: true,
 			stencilBuffer: false,
 			stencilBuffer: false,
 			depthTexture: null,
 			depthTexture: null,
-			samples: 0
+			samples: 0,
+			count: 1
 		}, options );
 		}, options );
 
 
-		this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
-		this.texture.isRenderTargetTexture = true;
+		const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
+
+		texture.flipY = false;
+		texture.generateMipmaps = options.generateMipmaps;
+		texture.internalFormat = options.internalFormat;
+
+		this.textures = [];
 
 
-		this.texture.flipY = false;
-		this.texture.generateMipmaps = options.generateMipmaps;
-		this.texture.internalFormat = options.internalFormat;
+		const count = options.count;
+		for ( let i = 0; i < count; i ++ ) {
+
+			this.textures[ i ] = texture.clone();
+			this.textures[ i ].isRenderTargetTexture = true;
+
+		}
 
 
 		this.depthBuffer = options.depthBuffer;
 		this.depthBuffer = options.depthBuffer;
 		this.stencilBuffer = options.stencilBuffer;
 		this.stencilBuffer = options.stencilBuffer;
@@ -2932,6 +2942,18 @@ class RenderTarget extends EventDispatcher {
 
 
 	}
 	}
 
 
+	get texture() {
+
+		return this.textures[ 0 ];
+
+	}
+
+	set texture( value ) {
+
+		this.textures[ 0 ] = value;
+
+	}
+
 	setSize( width, height, depth = 1 ) {
 	setSize( width, height, depth = 1 ) {
 
 
 		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
 		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
@@ -2940,9 +2962,13 @@ class RenderTarget extends EventDispatcher {
 			this.height = height;
 			this.height = height;
 			this.depth = depth;
 			this.depth = depth;
 
 
-			this.texture.image.width = width;
-			this.texture.image.height = height;
-			this.texture.image.depth = depth;
+			for ( let i = 0, il = this.textures.length; i < il; i ++ ) {
+
+				this.textures[ i ].image.width = width;
+				this.textures[ i ].image.height = height;
+				this.textures[ i ].image.depth = depth;
+
+			}
 
 
 			this.dispose();
 			this.dispose();
 
 
@@ -2970,8 +2996,14 @@ class RenderTarget extends EventDispatcher {
 
 
 		this.viewport.copy( source.viewport );
 		this.viewport.copy( source.viewport );
 
 
-		this.texture = source.texture.clone();
-		this.texture.isRenderTargetTexture = true;
+		this.textures.length = 0;
+
+		for ( let i = 0, il = source.textures.length; i < il; i ++ ) {
+
+			this.textures[ i ] = source.textures[ i ].clone();
+			this.textures[ i ].isRenderTargetTexture = true;
+
+		}
 
 
 		// ensure image object is not shared, see #20328
 		// ensure image object is not shared, see #20328
 
 
@@ -3099,85 +3131,6 @@ class WebGL3DRenderTarget extends WebGLRenderTarget {
 
 
 }
 }
 
 
-class WebGLMultipleRenderTargets extends WebGLRenderTarget {
-
-	constructor( width = 1, height = 1, count = 1, options = {} ) {
-
-		super( width, height, options );
-
-		this.isWebGLMultipleRenderTargets = true;
-
-		const texture = this.texture;
-
-		this.texture = [];
-
-		for ( let i = 0; i < count; i ++ ) {
-
-			this.texture[ i ] = texture.clone();
-			this.texture[ i ].isRenderTargetTexture = true;
-
-		}
-
-	}
-
-	setSize( width, height, depth = 1 ) {
-
-		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
-
-			this.width = width;
-			this.height = height;
-			this.depth = depth;
-
-			for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
-
-				this.texture[ i ].image.width = width;
-				this.texture[ i ].image.height = height;
-				this.texture[ i ].image.depth = depth;
-
-			}
-
-			this.dispose();
-
-		}
-
-		this.viewport.set( 0, 0, width, height );
-		this.scissor.set( 0, 0, width, height );
-
-	}
-
-	copy( source ) {
-
-		this.dispose();
-
-		this.width = source.width;
-		this.height = source.height;
-		this.depth = source.depth;
-
-		this.scissor.copy( source.scissor );
-		this.scissorTest = source.scissorTest;
-
-		this.viewport.copy( source.viewport );
-
-		this.depthBuffer = source.depthBuffer;
-		this.stencilBuffer = source.stencilBuffer;
-
-		if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
-
-		this.texture.length = 0;
-
-		for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
-
-			this.texture[ i ] = source.texture[ i ].clone();
-			this.texture[ i ].isRenderTargetTexture = true;
-
-		}
-
-		return this;
-
-	}
-
-}
-
 class Quaternion {
 class Quaternion {
 
 
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
@@ -23177,33 +23130,19 @@ function WebGLState( gl, extensions, capabilities ) {
 
 
 			}
 			}
 
 
-			if ( renderTarget.isWebGLMultipleRenderTargets ) {
-
-				const textures = renderTarget.texture;
+			const textures = renderTarget.textures;
 
 
-				if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
+			if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
 
 
-					for ( let i = 0, il = textures.length; i < il; i ++ ) {
+				for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
-						drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
-
-					}
-
-					drawBuffers.length = textures.length;
-
-					needsUpdate = true;
+					drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
 
 
 				}
 				}
 
 
-			} else {
+				drawBuffers.length = textures.length;
 
 
-				if ( drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
-
-					drawBuffers[ 0 ] = gl.COLOR_ATTACHMENT0;
-
-					needsUpdate = true;
-
-				}
+				needsUpdate = true;
 
 
 			}
 			}
 
 
@@ -23225,10 +23164,14 @@ function WebGLState( gl, extensions, capabilities ) {
 
 
 				gl.drawBuffers( drawBuffers );
 				gl.drawBuffers( drawBuffers );
 
 
-			} else {
+			} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
 
 
 				extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
 				extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
 
 
+			} else {
+
+				throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
+
 			}
 			}
 
 
 		}
 		}
@@ -24178,6 +24121,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
+		if ( glFormat === _gl.RG_INTEGER ) {
+
+			if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8UI;
+			if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RG16UI;
+			if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RG32UI;
+			if ( glType === _gl.BYTE ) internalFormat = _gl.RG8I;
+			if ( glType === _gl.SHORT ) internalFormat = _gl.RG16I;
+			if ( glType === _gl.INT ) internalFormat = _gl.RG32I;
+
+		}
+
 		if ( glFormat === _gl.RGBA ) {
 		if ( glFormat === _gl.RGBA ) {
 
 
 			const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
 			const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
@@ -24325,18 +24279,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 	function deallocateRenderTarget( renderTarget ) {
 	function deallocateRenderTarget( renderTarget ) {
 
 
-		const texture = renderTarget.texture;
-
 		const renderTargetProperties = properties.get( renderTarget );
 		const renderTargetProperties = properties.get( renderTarget );
-		const textureProperties = properties.get( texture );
-
-		if ( textureProperties.__webglTexture !== undefined ) {
-
-			_gl.deleteTexture( textureProperties.__webglTexture );
-
-			info.memory.textures --;
-
-		}
 
 
 		if ( renderTarget.depthTexture ) {
 		if ( renderTarget.depthTexture ) {
 
 
@@ -24391,27 +24334,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
-		if ( renderTarget.isWebGLMultipleRenderTargets ) {
+		const textures = renderTarget.textures;
 
 
-			for ( let i = 0, il = texture.length; i < il; i ++ ) {
-
-				const attachmentProperties = properties.get( texture[ i ] );
+		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
-				if ( attachmentProperties.__webglTexture ) {
+			const attachmentProperties = properties.get( textures[ i ] );
 
 
-					_gl.deleteTexture( attachmentProperties.__webglTexture );
+			if ( attachmentProperties.__webglTexture ) {
 
 
-					info.memory.textures --;
+				_gl.deleteTexture( attachmentProperties.__webglTexture );
 
 
-				}
-
-				properties.remove( texture[ i ] );
+				info.memory.textures --;
 
 
 			}
 			}
 
 
+			properties.remove( textures[ i ] );
+
 		}
 		}
 
 
-		properties.remove( texture );
 		properties.remove( renderTarget );
 		properties.remove( renderTarget );
 
 
 	}
 	}
@@ -24631,8 +24571,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
 		if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
 
 
-			const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
-
 			if ( texture.magFilter === NearestFilter ) return;
 			if ( texture.magFilter === NearestFilter ) return;
 			if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
 			if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
 			if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
 			if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
@@ -24640,6 +24578,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 			if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
 			if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
 
 
+				const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
 				_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
 				_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
 				properties.get( texture ).__currentAnisotropy = texture.anisotropy;
 				properties.get( texture ).__currentAnisotropy = texture.anisotropy;
 
 
@@ -25541,7 +25480,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		} else {
 		} else {
 
 
-			const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
+			const textures = renderTarget.textures;
 
 
 			for ( let i = 0; i < textures.length; i ++ ) {
 			for ( let i = 0; i < textures.length; i ++ ) {
 
 
@@ -25705,7 +25644,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
 		renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
 
 
-		if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
+		const textures = renderTarget.textures;
+
+		const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
+		const isMultipleRenderTargets = ( textures.length > 1 );
+		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
+
+		if ( ! isMultipleRenderTargets ) {
 
 
 			if ( textureProperties.__webglTexture === undefined ) {
 			if ( textureProperties.__webglTexture === undefined ) {
 
 
@@ -25718,10 +25663,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
-		const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
-		const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
-		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
-
 		// Setup framebuffer
 		// Setup framebuffer
 
 
 		if ( isCube ) {
 		if ( isCube ) {
@@ -25770,8 +25711,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 				if ( capabilities.drawBuffers ) {
 				if ( capabilities.drawBuffers ) {
 
 
-					const textures = renderTarget.texture;
-
 					for ( let i = 0, il = textures.length; i < il; i ++ ) {
 					for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
 						const attachmentProperties = properties.get( textures[ i ] );
 						const attachmentProperties = properties.get( textures[ i ] );
@@ -25796,8 +25735,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 			if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 			if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 
 
-				const textures = isMultipleRenderTargets ? texture : [ texture ];
-
 				renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
 				renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
 				renderTargetProperties.__webglColorRenderbuffer = [];
 				renderTargetProperties.__webglColorRenderbuffer = [];
 
 
@@ -25870,8 +25807,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		} else if ( isMultipleRenderTargets ) {
 		} else if ( isMultipleRenderTargets ) {
 
 
-			const textures = renderTarget.texture;
-
 			for ( let i = 0, il = textures.length; i < il; i ++ ) {
 			for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
 				const attachment = textures[ i ];
 				const attachment = textures[ i ];
@@ -25950,7 +25885,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
 		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
 
 
-		const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
+		const textures = renderTarget.textures;
 
 
 		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
@@ -25975,14 +25910,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 		if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 
 
-			const textures = renderTarget.isWebGLMultipleRenderTargets ? renderTarget.texture : [ renderTarget.texture ];
+			const textures = renderTarget.textures;
 			const width = renderTarget.width;
 			const width = renderTarget.width;
 			const height = renderTarget.height;
 			const height = renderTarget.height;
 			let mask = _gl.COLOR_BUFFER_BIT;
 			let mask = _gl.COLOR_BUFFER_BIT;
 			const invalidationArray = [];
 			const invalidationArray = [];
 			const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
 			const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
 			const renderTargetProperties = properties.get( renderTarget );
 			const renderTargetProperties = properties.get( renderTarget );
-			const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
+			const isMultipleRenderTargets = ( textures.length > 1 );
 
 
 			// If MRT we need to remove FBO attachments
 			// If MRT we need to remove FBO attachments
 			if ( isMultipleRenderTargets ) {
 			if ( isMultipleRenderTargets ) {
@@ -29118,7 +29053,7 @@ class WebGLRenderer {
 
 
 			}
 			}
 
 
-			state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
+			state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).round() );
 
 
 		};
 		};
 
 
@@ -29140,7 +29075,7 @@ class WebGLRenderer {
 
 
 			}
 			}
 
 
-			state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
+			state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).round() );
 
 
 		};
 		};
 
 
@@ -30800,20 +30735,16 @@ class WebGLRenderer {
 			const renderTargetProperties = properties.get( renderTarget );
 			const renderTargetProperties = properties.get( renderTarget );
 			renderTargetProperties.__hasExternalTextures = true;
 			renderTargetProperties.__hasExternalTextures = true;
 
 
-			if ( renderTargetProperties.__hasExternalTextures ) {
-
-				renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
+			renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
 
 
-				if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
+			if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
 
 
-					// The multisample_render_to_texture extension doesn't work properly if there
-					// are midframe flushes and an external depth buffer. Disable use of the extension.
-					if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
+				// The multisample_render_to_texture extension doesn't work properly if there
+				// are midframe flushes and an external depth buffer. Disable use of the extension.
+				if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
 
 
-						console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
-						renderTargetProperties.__useRenderToTexture = false;
-
-					}
+					console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
+					renderTargetProperties.__useRenderToTexture = false;
 
 
 				}
 				}
 
 
@@ -33002,6 +32933,24 @@ class InstancedMesh extends Mesh {
 
 
 	}
 	}
 
 
+	getMorphAt( index, object ) {
+
+		const objectInfluences = object.morphTargetInfluences;
+
+		const array = this.morphTexture.source.data.data;
+
+		const len = objectInfluences.length + 1; // All influences + the baseInfluenceSum
+
+		const dataIndex = index * len + 1; // Skip the baseInfluenceSum at the beginning
+
+		for ( let i = 0; i < objectInfluences.length; i ++ ) {
+
+			objectInfluences[ i ] = array[ dataIndex + i ];
+
+		}
+
+	}
+
 	raycast( raycaster, intersects ) {
 	raycast( raycaster, intersects ) {
 
 
 		const matrixWorld = this.matrixWorld;
 		const matrixWorld = this.matrixWorld;
@@ -33072,9 +33021,9 @@ class InstancedMesh extends Mesh {
 
 
 	}
 	}
 
 
-	setMorphAt( index, dummy ) {
+	setMorphAt( index, object ) {
 
 
-		const objectInfluences = dummy.morphTargetInfluences;
+		const objectInfluences = object.morphTargetInfluences;
 
 
 		const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
 		const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
 
 
@@ -53291,6 +53240,26 @@ class ShapePath {
 
 
 }
 }
 
 
+class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
+
+	constructor( width = 1, height = 1, count = 1, options = {} ) {
+
+		console.warn( 'THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.' );
+
+		super( width, height, { ...options, count } );
+
+		this.isWebGLMultipleRenderTargets = true;
+
+	}
+
+	get texture() {
+
+		return this.textures;
+
+	}
+
+}
+
 if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
 if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
 
 
 	__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
 	__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {

+ 134 - 165
build/three.module.js

@@ -2911,15 +2911,25 @@ class RenderTarget extends EventDispatcher {
 			depthBuffer: true,
 			depthBuffer: true,
 			stencilBuffer: false,
 			stencilBuffer: false,
 			depthTexture: null,
 			depthTexture: null,
-			samples: 0
+			samples: 0,
+			count: 1
 		}, options );
 		}, options );
 
 
-		this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
-		this.texture.isRenderTargetTexture = true;
+		const texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
+
+		texture.flipY = false;
+		texture.generateMipmaps = options.generateMipmaps;
+		texture.internalFormat = options.internalFormat;
+
+		this.textures = [];
 
 
-		this.texture.flipY = false;
-		this.texture.generateMipmaps = options.generateMipmaps;
-		this.texture.internalFormat = options.internalFormat;
+		const count = options.count;
+		for ( let i = 0; i < count; i ++ ) {
+
+			this.textures[ i ] = texture.clone();
+			this.textures[ i ].isRenderTargetTexture = true;
+
+		}
 
 
 		this.depthBuffer = options.depthBuffer;
 		this.depthBuffer = options.depthBuffer;
 		this.stencilBuffer = options.stencilBuffer;
 		this.stencilBuffer = options.stencilBuffer;
@@ -2930,6 +2940,18 @@ class RenderTarget extends EventDispatcher {
 
 
 	}
 	}
 
 
+	get texture() {
+
+		return this.textures[ 0 ];
+
+	}
+
+	set texture( value ) {
+
+		this.textures[ 0 ] = value;
+
+	}
+
 	setSize( width, height, depth = 1 ) {
 	setSize( width, height, depth = 1 ) {
 
 
 		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
 		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
@@ -2938,9 +2960,13 @@ class RenderTarget extends EventDispatcher {
 			this.height = height;
 			this.height = height;
 			this.depth = depth;
 			this.depth = depth;
 
 
-			this.texture.image.width = width;
-			this.texture.image.height = height;
-			this.texture.image.depth = depth;
+			for ( let i = 0, il = this.textures.length; i < il; i ++ ) {
+
+				this.textures[ i ].image.width = width;
+				this.textures[ i ].image.height = height;
+				this.textures[ i ].image.depth = depth;
+
+			}
 
 
 			this.dispose();
 			this.dispose();
 
 
@@ -2968,8 +2994,14 @@ class RenderTarget extends EventDispatcher {
 
 
 		this.viewport.copy( source.viewport );
 		this.viewport.copy( source.viewport );
 
 
-		this.texture = source.texture.clone();
-		this.texture.isRenderTargetTexture = true;
+		this.textures.length = 0;
+
+		for ( let i = 0, il = source.textures.length; i < il; i ++ ) {
+
+			this.textures[ i ] = source.textures[ i ].clone();
+			this.textures[ i ].isRenderTargetTexture = true;
+
+		}
 
 
 		// ensure image object is not shared, see #20328
 		// ensure image object is not shared, see #20328
 
 
@@ -3097,85 +3129,6 @@ class WebGL3DRenderTarget extends WebGLRenderTarget {
 
 
 }
 }
 
 
-class WebGLMultipleRenderTargets extends WebGLRenderTarget {
-
-	constructor( width = 1, height = 1, count = 1, options = {} ) {
-
-		super( width, height, options );
-
-		this.isWebGLMultipleRenderTargets = true;
-
-		const texture = this.texture;
-
-		this.texture = [];
-
-		for ( let i = 0; i < count; i ++ ) {
-
-			this.texture[ i ] = texture.clone();
-			this.texture[ i ].isRenderTargetTexture = true;
-
-		}
-
-	}
-
-	setSize( width, height, depth = 1 ) {
-
-		if ( this.width !== width || this.height !== height || this.depth !== depth ) {
-
-			this.width = width;
-			this.height = height;
-			this.depth = depth;
-
-			for ( let i = 0, il = this.texture.length; i < il; i ++ ) {
-
-				this.texture[ i ].image.width = width;
-				this.texture[ i ].image.height = height;
-				this.texture[ i ].image.depth = depth;
-
-			}
-
-			this.dispose();
-
-		}
-
-		this.viewport.set( 0, 0, width, height );
-		this.scissor.set( 0, 0, width, height );
-
-	}
-
-	copy( source ) {
-
-		this.dispose();
-
-		this.width = source.width;
-		this.height = source.height;
-		this.depth = source.depth;
-
-		this.scissor.copy( source.scissor );
-		this.scissorTest = source.scissorTest;
-
-		this.viewport.copy( source.viewport );
-
-		this.depthBuffer = source.depthBuffer;
-		this.stencilBuffer = source.stencilBuffer;
-
-		if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
-
-		this.texture.length = 0;
-
-		for ( let i = 0, il = source.texture.length; i < il; i ++ ) {
-
-			this.texture[ i ] = source.texture[ i ].clone();
-			this.texture[ i ].isRenderTargetTexture = true;
-
-		}
-
-		return this;
-
-	}
-
-}
-
 class Quaternion {
 class Quaternion {
 
 
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
@@ -23175,33 +23128,19 @@ function WebGLState( gl, extensions, capabilities ) {
 
 
 			}
 			}
 
 
-			if ( renderTarget.isWebGLMultipleRenderTargets ) {
-
-				const textures = renderTarget.texture;
+			const textures = renderTarget.textures;
 
 
-				if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
+			if ( drawBuffers.length !== textures.length || drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
 
 
-					for ( let i = 0, il = textures.length; i < il; i ++ ) {
+				for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
-						drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
-
-					}
-
-					drawBuffers.length = textures.length;
-
-					needsUpdate = true;
+					drawBuffers[ i ] = gl.COLOR_ATTACHMENT0 + i;
 
 
 				}
 				}
 
 
-			} else {
+				drawBuffers.length = textures.length;
 
 
-				if ( drawBuffers[ 0 ] !== gl.COLOR_ATTACHMENT0 ) {
-
-					drawBuffers[ 0 ] = gl.COLOR_ATTACHMENT0;
-
-					needsUpdate = true;
-
-				}
+				needsUpdate = true;
 
 
 			}
 			}
 
 
@@ -23223,10 +23162,14 @@ function WebGLState( gl, extensions, capabilities ) {
 
 
 				gl.drawBuffers( drawBuffers );
 				gl.drawBuffers( drawBuffers );
 
 
-			} else {
+			} else if ( extensions.has( 'WEBGL_draw_buffers' ) === true ) {
 
 
 				extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
 				extensions.get( 'WEBGL_draw_buffers' ).drawBuffersWEBGL( drawBuffers );
 
 
+			} else {
+
+				throw new Error( 'THREE.WebGLState: Usage of gl.drawBuffers() require WebGL2 or WEBGL_draw_buffers extension' );
+
 			}
 			}
 
 
 		}
 		}
@@ -24176,6 +24119,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
+		if ( glFormat === _gl.RG_INTEGER ) {
+
+			if ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RG8UI;
+			if ( glType === _gl.UNSIGNED_SHORT ) internalFormat = _gl.RG16UI;
+			if ( glType === _gl.UNSIGNED_INT ) internalFormat = _gl.RG32UI;
+			if ( glType === _gl.BYTE ) internalFormat = _gl.RG8I;
+			if ( glType === _gl.SHORT ) internalFormat = _gl.RG16I;
+			if ( glType === _gl.INT ) internalFormat = _gl.RG32I;
+
+		}
+
 		if ( glFormat === _gl.RGBA ) {
 		if ( glFormat === _gl.RGBA ) {
 
 
 			const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
 			const transfer = forceLinearTransfer ? LinearTransfer : ColorManagement.getTransfer( colorSpace );
@@ -24323,18 +24277,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 	function deallocateRenderTarget( renderTarget ) {
 	function deallocateRenderTarget( renderTarget ) {
 
 
-		const texture = renderTarget.texture;
-
 		const renderTargetProperties = properties.get( renderTarget );
 		const renderTargetProperties = properties.get( renderTarget );
-		const textureProperties = properties.get( texture );
-
-		if ( textureProperties.__webglTexture !== undefined ) {
-
-			_gl.deleteTexture( textureProperties.__webglTexture );
-
-			info.memory.textures --;
-
-		}
 
 
 		if ( renderTarget.depthTexture ) {
 		if ( renderTarget.depthTexture ) {
 
 
@@ -24389,27 +24332,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
-		if ( renderTarget.isWebGLMultipleRenderTargets ) {
+		const textures = renderTarget.textures;
 
 
-			for ( let i = 0, il = texture.length; i < il; i ++ ) {
-
-				const attachmentProperties = properties.get( texture[ i ] );
+		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
-				if ( attachmentProperties.__webglTexture ) {
+			const attachmentProperties = properties.get( textures[ i ] );
 
 
-					_gl.deleteTexture( attachmentProperties.__webglTexture );
+			if ( attachmentProperties.__webglTexture ) {
 
 
-					info.memory.textures --;
+				_gl.deleteTexture( attachmentProperties.__webglTexture );
 
 
-				}
-
-				properties.remove( texture[ i ] );
+				info.memory.textures --;
 
 
 			}
 			}
 
 
+			properties.remove( textures[ i ] );
+
 		}
 		}
 
 
-		properties.remove( texture );
 		properties.remove( renderTarget );
 		properties.remove( renderTarget );
 
 
 	}
 	}
@@ -24629,8 +24569,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
 		if ( extensions.has( 'EXT_texture_filter_anisotropic' ) === true ) {
 
 
-			const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
-
 			if ( texture.magFilter === NearestFilter ) return;
 			if ( texture.magFilter === NearestFilter ) return;
 			if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
 			if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return;
 			if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
 			if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2
@@ -24638,6 +24576,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 			if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
 			if ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {
 
 
+				const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
 				_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
 				_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );
 				properties.get( texture ).__currentAnisotropy = texture.anisotropy;
 				properties.get( texture ).__currentAnisotropy = texture.anisotropy;
 
 
@@ -25539,7 +25478,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		} else {
 		} else {
 
 
-			const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
+			const textures = renderTarget.textures;
 
 
 			for ( let i = 0; i < textures.length; i ++ ) {
 			for ( let i = 0; i < textures.length; i ++ ) {
 
 
@@ -25703,7 +25642,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
 		renderTarget.addEventListener( 'dispose', onRenderTargetDispose );
 
 
-		if ( renderTarget.isWebGLMultipleRenderTargets !== true ) {
+		const textures = renderTarget.textures;
+
+		const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
+		const isMultipleRenderTargets = ( textures.length > 1 );
+		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
+
+		if ( ! isMultipleRenderTargets ) {
 
 
 			if ( textureProperties.__webglTexture === undefined ) {
 			if ( textureProperties.__webglTexture === undefined ) {
 
 
@@ -25716,10 +25661,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		}
 		}
 
 
-		const isCube = ( renderTarget.isWebGLCubeRenderTarget === true );
-		const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
-		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
-
 		// Setup framebuffer
 		// Setup framebuffer
 
 
 		if ( isCube ) {
 		if ( isCube ) {
@@ -25768,8 +25709,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 				if ( capabilities.drawBuffers ) {
 				if ( capabilities.drawBuffers ) {
 
 
-					const textures = renderTarget.texture;
-
 					for ( let i = 0, il = textures.length; i < il; i ++ ) {
 					for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
 						const attachmentProperties = properties.get( textures[ i ] );
 						const attachmentProperties = properties.get( textures[ i ] );
@@ -25794,8 +25733,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 			if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 			if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 
 
-				const textures = isMultipleRenderTargets ? texture : [ texture ];
-
 				renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
 				renderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
 				renderTargetProperties.__webglColorRenderbuffer = [];
 				renderTargetProperties.__webglColorRenderbuffer = [];
 
 
@@ -25868,8 +25805,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		} else if ( isMultipleRenderTargets ) {
 		} else if ( isMultipleRenderTargets ) {
 
 
-			const textures = renderTarget.texture;
-
 			for ( let i = 0, il = textures.length; i < il; i ++ ) {
 			for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
 				const attachment = textures[ i ];
 				const attachment = textures[ i ];
@@ -25948,7 +25883,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
 		const supportsMips = isPowerOfTwo$1( renderTarget ) || isWebGL2;
 
 
-		const textures = renderTarget.isWebGLMultipleRenderTargets === true ? renderTarget.texture : [ renderTarget.texture ];
+		const textures = renderTarget.textures;
 
 
 		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 		for ( let i = 0, il = textures.length; i < il; i ++ ) {
 
 
@@ -25973,14 +25908,14 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 
 		if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 		if ( ( isWebGL2 && renderTarget.samples > 0 ) && useMultisampledRTT( renderTarget ) === false ) {
 
 
-			const textures = renderTarget.isWebGLMultipleRenderTargets ? renderTarget.texture : [ renderTarget.texture ];
+			const textures = renderTarget.textures;
 			const width = renderTarget.width;
 			const width = renderTarget.width;
 			const height = renderTarget.height;
 			const height = renderTarget.height;
 			let mask = _gl.COLOR_BUFFER_BIT;
 			let mask = _gl.COLOR_BUFFER_BIT;
 			const invalidationArray = [];
 			const invalidationArray = [];
 			const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
 			const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;
 			const renderTargetProperties = properties.get( renderTarget );
 			const renderTargetProperties = properties.get( renderTarget );
-			const isMultipleRenderTargets = ( renderTarget.isWebGLMultipleRenderTargets === true );
+			const isMultipleRenderTargets = ( textures.length > 1 );
 
 
 			// If MRT we need to remove FBO attachments
 			// If MRT we need to remove FBO attachments
 			if ( isMultipleRenderTargets ) {
 			if ( isMultipleRenderTargets ) {
@@ -29116,7 +29051,7 @@ class WebGLRenderer {
 
 
 			}
 			}
 
 
-			state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
+			state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).round() );
 
 
 		};
 		};
 
 
@@ -29138,7 +29073,7 @@ class WebGLRenderer {
 
 
 			}
 			}
 
 
-			state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
+			state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).round() );
 
 
 		};
 		};
 
 
@@ -30798,20 +30733,16 @@ class WebGLRenderer {
 			const renderTargetProperties = properties.get( renderTarget );
 			const renderTargetProperties = properties.get( renderTarget );
 			renderTargetProperties.__hasExternalTextures = true;
 			renderTargetProperties.__hasExternalTextures = true;
 
 
-			if ( renderTargetProperties.__hasExternalTextures ) {
-
-				renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
+			renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
 
 
-				if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
+			if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
 
 
-					// The multisample_render_to_texture extension doesn't work properly if there
-					// are midframe flushes and an external depth buffer. Disable use of the extension.
-					if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
+				// The multisample_render_to_texture extension doesn't work properly if there
+				// are midframe flushes and an external depth buffer. Disable use of the extension.
+				if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
 
 
-						console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
-						renderTargetProperties.__useRenderToTexture = false;
-
-					}
+					console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
+					renderTargetProperties.__useRenderToTexture = false;
 
 
 				}
 				}
 
 
@@ -33000,6 +32931,24 @@ class InstancedMesh extends Mesh {
 
 
 	}
 	}
 
 
+	getMorphAt( index, object ) {
+
+		const objectInfluences = object.morphTargetInfluences;
+
+		const array = this.morphTexture.source.data.data;
+
+		const len = objectInfluences.length + 1; // All influences + the baseInfluenceSum
+
+		const dataIndex = index * len + 1; // Skip the baseInfluenceSum at the beginning
+
+		for ( let i = 0; i < objectInfluences.length; i ++ ) {
+
+			objectInfluences[ i ] = array[ dataIndex + i ];
+
+		}
+
+	}
+
 	raycast( raycaster, intersects ) {
 	raycast( raycaster, intersects ) {
 
 
 		const matrixWorld = this.matrixWorld;
 		const matrixWorld = this.matrixWorld;
@@ -33070,9 +33019,9 @@ class InstancedMesh extends Mesh {
 
 
 	}
 	}
 
 
-	setMorphAt( index, dummy ) {
+	setMorphAt( index, object ) {
 
 
-		const objectInfluences = dummy.morphTargetInfluences;
+		const objectInfluences = object.morphTargetInfluences;
 
 
 		const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
 		const len = objectInfluences.length + 1; // morphBaseInfluence + all influences
 
 
@@ -53289,6 +53238,26 @@ class ShapePath {
 
 
 }
 }
 
 
+class WebGLMultipleRenderTargets extends WebGLRenderTarget { // @deprecated, r162
+
+	constructor( width = 1, height = 1, count = 1, options = {} ) {
+
+		console.warn( 'THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.' );
+
+		super( width, height, { ...options, count } );
+
+		this.isWebGLMultipleRenderTargets = true;
+
+	}
+
+	get texture() {
+
+		return this.textures;
+
+	}
+
+}
+
 if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
 if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
 
 
 	__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {
 	__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {

文件差异内容过多而无法显示
+ 0 - 0
build/three.module.min.js


部分文件因为文件数量过多而无法显示