Browse Source

Merge branch 'dev' of https://github.com/mrdoob/three.js into zh_doc

gogoend 6 years ago
parent
commit
fe5db994e8

+ 142 - 187
build/three.js

@@ -1635,6 +1635,8 @@
 	 * @author WestLangley / http://github.com/WestLangley
 	 * @author WestLangley / http://github.com/WestLangley
 	 */
 	 */
 
 
+	var _vector, _quaternion;
+
 	function Vector3( x, y, z ) {
 	function Vector3( x, y, z ) {
 
 
 		this.x = x || 0;
 		this.x = x || 0;
@@ -1856,35 +1858,27 @@
 
 
 		},
 		},
 
 
-		applyEuler: function () {
-
-			var quaternion = new Quaternion();
-
-			return function applyEuler( euler ) {
-
-				if ( ! ( euler && euler.isEuler ) ) {
+		applyEuler: function ( euler ) {
 
 
-					console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
-
-				}
+			if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-				return this.applyQuaternion( quaternion.setFromEuler( euler ) );
+			if ( ! ( euler && euler.isEuler ) ) {
 
 
-			};
+				console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
 
 
-		}(),
+			}
 
 
-		applyAxisAngle: function () {
+			return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
 
 
-			var quaternion = new Quaternion();
+		},
 
 
-			return function applyAxisAngle( axis, angle ) {
+		applyAxisAngle: function ( axis, angle ) {
 
 
-				return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+			if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-			};
+			return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
 
 
-		}(),
+		},
 
 
 		applyMatrix3: function ( m ) {
 		applyMatrix3: function ( m ) {
 
 
@@ -2168,34 +2162,26 @@
 
 
 		},
 		},
 
 
-		projectOnPlane: function () {
+		projectOnPlane: function ( planeNormal ) {
 
 
-			var v1 = new Vector3();
+			if ( _vector === undefined ) _vector = new Vector3();
 
 
-			return function projectOnPlane( planeNormal ) {
+			_vector.copy( this ).projectOnVector( planeNormal );
 
 
-				v1.copy( this ).projectOnVector( planeNormal );
+			return this.sub( _vector );
 
 
-				return this.sub( v1 );
+		},
 
 
-			};
+		reflect: function ( normal ) {
 
 
-		}(),
-
-		reflect: function () {
+			if ( _vector === undefined ) _vector = new Vector3();
 
 
 			// reflect incident vector off plane orthogonal to normal
 			// reflect incident vector off plane orthogonal to normal
 			// normal is assumed to have unit length
 			// normal is assumed to have unit length
 
 
-			var v1 = new Vector3();
-
-			return function reflect( normal ) {
+			return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
 
 
-				return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
-
-			};
-
-		}(),
+		},
 
 
 		angleTo: function ( v ) {
 		angleTo: function ( v ) {
 
 
@@ -2349,7 +2335,7 @@
 	 * @author tschw
 	 * @author tschw
 	 */
 	 */
 
 
-	var _vector;
+	var _vector$1;
 
 
 	function Matrix3() {
 	function Matrix3() {
 
 
@@ -2436,17 +2422,17 @@
 
 
 		applyToBufferAttribute: function ( attribute ) {
 		applyToBufferAttribute: function ( attribute ) {
 
 
-			if ( _vector === undefined ) _vector = new Vector3();
+			if ( _vector$1 === undefined ) _vector$1 = new Vector3();
 
 
 			for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 			for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 
 
-				_vector.x = attribute.getX( i );
-				_vector.y = attribute.getY( i );
-				_vector.z = attribute.getZ( i );
+				_vector$1.x = attribute.getX( i );
+				_vector$1.y = attribute.getY( i );
+				_vector$1.z = attribute.getZ( i );
 
 
-				_vector.applyMatrix3( this );
+				_vector$1.applyMatrix3( this );
 
 
-				attribute.setXYZ( i, _vector.x, _vector.y, _vector.z );
+				attribute.setXYZ( i, _vector$1.x, _vector$1.y, _vector$1.z );
 
 
 			}
 			}
 
 
@@ -4823,7 +4809,7 @@
 	 * @author bhouston / http://clara.io
 	 * @author bhouston / http://clara.io
 	 */
 	 */
 
 
-	var _matrix, _quaternion;
+	var _matrix, _quaternion$1;
 
 
 	function Euler( x, y, z, order ) {
 	function Euler( x, y, z, order ) {
 
 
@@ -5089,11 +5075,11 @@
 
 
 			// WARNING: this discards revolution information -bhouston
 			// WARNING: this discards revolution information -bhouston
 
 
-			if ( _quaternion === undefined ) _quaternion = new Quaternion();
+			if ( _quaternion$1 === undefined ) _quaternion$1 = new Quaternion();
 
 
-			_quaternion.setFromEuler( this );
+			_quaternion$1.setFromEuler( this );
 
 
-			return this.setFromQuaternion( _quaternion, newOrder );
+			return this.setFromQuaternion( _quaternion$1, newOrder );
 
 
 		},
 		},
 
 
@@ -7881,7 +7867,7 @@
 	 * @author mrdoob / http://mrdoob.com/
 	 * @author mrdoob / http://mrdoob.com/
 	 */
 	 */
 
 
-	var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
+	var _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
 		'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 		'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 		'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 		'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 		'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
 		'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
@@ -7906,6 +7892,9 @@
 		'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 		'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 		'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 		'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 
 
+	var _hslA = { h: 0, s: 0, l: 0 };
+	var _hslB = { h: 0, s: 0, l: 0 };
+
 	function Color( r, g, b ) {
 	function Color( r, g, b ) {
 
 
 		if ( g === undefined && b === undefined ) {
 		if ( g === undefined && b === undefined ) {
@@ -8136,7 +8125,7 @@
 			if ( style && style.length > 0 ) {
 			if ( style && style.length > 0 ) {
 
 
 				// color keywords
 				// color keywords
-				var hex = ColorKeywords[ style ];
+				var hex = _colorKeywords[ style ];
 
 
 				if ( hex !== undefined ) {
 				if ( hex !== undefined ) {
 
 
@@ -8318,23 +8307,17 @@
 
 
 		},
 		},
 
 
-		offsetHSL: function () {
-
-			var hsl = {};
+		offsetHSL: function ( h, s, l ) {
 
 
-			return function ( h, s, l ) {
+			this.getHSL( _hslA );
 
 
-				this.getHSL( hsl );
+			_hslA.h += h; _hslA.s += s; _hslA.l += l;
 
 
-				hsl.h += h; hsl.s += s; hsl.l += l;
+			this.setHSL( _hslA.h, _hslA.s, _hslA.l );
 
 
-				this.setHSL( hsl.h, hsl.s, hsl.l );
-
-				return this;
-
-			};
+			return this;
 
 
-		}(),
+		},
 
 
 		add: function ( color ) {
 		add: function ( color ) {
 
 
@@ -8406,27 +8389,20 @@
 
 
 		},
 		},
 
 
-		lerpHSL: function () {
-
-			var hslA = { h: 0, s: 0, l: 0 };
-			var hslB = { h: 0, s: 0, l: 0 };
-
-			return function lerpHSL( color, alpha ) {
+		lerpHSL: function ( color, alpha ) {
 
 
-				this.getHSL( hslA );
-				color.getHSL( hslB );
+			this.getHSL( _hslA );
+			color.getHSL( _hslB );
 
 
-				var h = _Math.lerp( hslA.h, hslB.h, alpha );
-				var s = _Math.lerp( hslA.s, hslB.s, alpha );
-				var l = _Math.lerp( hslA.l, hslB.l, alpha );
+			var h = _Math.lerp( _hslA.h, _hslB.h, alpha );
+			var s = _Math.lerp( _hslA.s, _hslB.s, alpha );
+			var l = _Math.lerp( _hslA.l, _hslB.l, alpha );
 
 
-				this.setHSL( h, s, l );
+			this.setHSL( h, s, l );
 
 
-				return this;
-
-			};
+			return this;
 
 
-		}(),
+		},
 
 
 		equals: function ( c ) {
 		equals: function ( c ) {
 
 
@@ -13918,6 +13894,8 @@
 	 * @author bhouston / http://clara.io
 	 * @author bhouston / http://clara.io
 	 */
 	 */
 
 
+	var _vector1, _vector2, _normalMatrix;
+
 	function Plane( normal, constant ) {
 	function Plane( normal, constant ) {
 
 
 		// normal is assumed to be normalized
 		// normal is assumed to be normalized
@@ -13958,24 +13936,24 @@
 
 
 		},
 		},
 
 
-		setFromCoplanarPoints: function () {
+		setFromCoplanarPoints: function ( a, b, c ) {
 
 
-			var v1 = new Vector3();
-			var v2 = new Vector3();
+			if ( _vector1 === undefined ) {
 
 
-			return function setFromCoplanarPoints( a, b, c ) {
+				_vector1 = new Vector3();
+				_vector2 = new Vector3();
 
 
-				var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+			}
 
 
-				// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+			var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();
 
 
-				this.setFromNormalAndCoplanarPoint( normal, a );
+			// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
 
 
-				return this;
+			this.setFromNormalAndCoplanarPoint( normal, a );
 
 
-			};
+			return this;
 
 
-		}(),
+		},
 
 
 		clone: function () {
 		clone: function () {
 
 
@@ -14038,50 +14016,46 @@
 
 
 		},
 		},
 
 
-		intersectLine: function () {
-
-			var v1 = new Vector3();
-
-			return function intersectLine( line, target ) {
+		intersectLine: function ( line, target ) {
 
 
-				if ( target === undefined ) {
-
-					console.warn( 'THREE.Plane: .intersectLine() target is now required' );
-					target = new Vector3();
+			if ( _vector1 === undefined ) _vector1 = new Vector3();
 
 
-				}
+			if ( target === undefined ) {
 
 
-				var direction = line.delta( v1 );
+				console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+				target = new Vector3();
 
 
-				var denominator = this.normal.dot( direction );
+			}
 
 
-				if ( denominator === 0 ) {
+			var direction = line.delta( _vector1 );
 
 
-					// line is coplanar, return origin
-					if ( this.distanceToPoint( line.start ) === 0 ) {
+			var denominator = this.normal.dot( direction );
 
 
-						return target.copy( line.start );
+			if ( denominator === 0 ) {
 
 
-					}
+				// line is coplanar, return origin
+				if ( this.distanceToPoint( line.start ) === 0 ) {
 
 
-					// Unsure if this is the correct method to handle this case.
-					return undefined;
+					return target.copy( line.start );
 
 
 				}
 				}
 
 
-				var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+				// Unsure if this is the correct method to handle this case.
+				return undefined;
 
 
-				if ( t < 0 || t > 1 ) {
+			}
 
 
-					return undefined;
+			var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
 
 
-				}
+			if ( t < 0 || t > 1 ) {
 
 
-				return target.copy( direction ).multiplyScalar( t ).add( line.start );
+				return undefined;
 
 
-			};
+			}
 
 
-		}(),
+			return target.copy( direction ).multiplyScalar( t ).add( line.start );
+
+		},
 
 
 		intersectsLine: function ( line ) {
 		intersectsLine: function ( line ) {
 
 
@@ -14119,26 +14093,26 @@
 
 
 		},
 		},
 
 
-		applyMatrix4: function () {
+		applyMatrix4: function ( matrix, optionalNormalMatrix ) {
 
 
-			var v1 = new Vector3();
-			var m1 = new Matrix3();
+			if ( _normalMatrix === undefined ) {
 
 
-			return function applyMatrix4( matrix, optionalNormalMatrix ) {
+				_normalMatrix = new Matrix3();
+				_vector1 = new Vector3();
 
 
-				var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+			}
 
 
-				var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+			var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );
 
 
-				var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+			var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );
 
 
-				this.constant = - referencePoint.dot( normal );
+			var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
 
 
-				return this;
+			this.constant = - referencePoint.dot( normal );
 
 
-			};
+			return this;
 
 
-		}(),
+		},
 
 
 		translate: function ( offset ) {
 		translate: function ( offset ) {
 
 
@@ -14162,6 +14136,9 @@
 	 * @author bhouston / http://clara.io
 	 * @author bhouston / http://clara.io
 	 */
 	 */
 
 
+	var _sphere;
+	var _vector$2;
+
 	function Frustum( p0, p1, p2, p3, p4, p5 ) {
 	function Frustum( p0, p1, p2, p3, p4, p5 ) {
 
 
 		this.planes = [
 		this.planes = [
@@ -14234,41 +14211,29 @@
 
 
 		},
 		},
 
 
-		intersectsObject: function () {
-
-			var sphere = new Sphere();
-
-			return function intersectsObject( object ) {
-
-				var geometry = object.geometry;
+		intersectsObject: function ( object ) {
 
 
-				if ( geometry.boundingSphere === null )
-					geometry.computeBoundingSphere();
+			if ( _sphere === undefined ) _sphere = new Sphere();
 
 
-				sphere.copy( geometry.boundingSphere )
-					.applyMatrix4( object.matrixWorld );
-
-				return this.intersectsSphere( sphere );
-
-			};
+			var geometry = object.geometry;
 
 
-		}(),
+			if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-		intersectsSprite: function () {
+			_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
 
 
-			var sphere = new Sphere();
+			return this.intersectsSphere( _sphere );
 
 
-			return function intersectsSprite( sprite ) {
+		},
 
 
-				sphere.center.set( 0, 0, 0 );
-				sphere.radius = 0.7071067811865476;
-				sphere.applyMatrix4( sprite.matrixWorld );
+		intersectsSprite: function ( sprite ) {
 
 
-				return this.intersectsSphere( sphere );
+			_sphere.center.set( 0, 0, 0 );
+			_sphere.radius = 0.7071067811865476;
+			_sphere.applyMatrix4( sprite.matrixWorld );
 
 
-			};
+			return this.intersectsSphere( _sphere );
 
 
-		}(),
+		},
 
 
 		intersectsSphere: function ( sphere ) {
 		intersectsSphere: function ( sphere ) {
 
 
@@ -14292,37 +14257,33 @@
 
 
 		},
 		},
 
 
-		intersectsBox: function () {
-
-			var p = new Vector3();
-
-			return function intersectsBox( box ) {
+		intersectsBox: function ( box ) {
 
 
-				var planes = this.planes;
+			if ( _vector$2 === undefined ) _vector$2 = new Vector3();
 
 
-				for ( var i = 0; i < 6; i ++ ) {
+			var planes = this.planes;
 
 
-					var plane = planes[ i ];
+			for ( var i = 0; i < 6; i ++ ) {
 
 
-					// corner at max distance
+				var plane = planes[ i ];
 
 
-					p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
-					p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
-					p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+				// corner at max distance
 
 
-					if ( plane.distanceToPoint( p ) < 0 ) {
+				_vector$2.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+				_vector$2.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+				_vector$2.z = plane.normal.z > 0 ? box.max.z : box.min.z;
 
 
-						return false;
+				if ( plane.distanceToPoint( _vector$2 ) < 0 ) {
 
 
-					}
+					return false;
 
 
 				}
 				}
 
 
-				return true;
+			}
 
 
-			};
+			return true;
 
 
-		}(),
+		},
 
 
 		containsPoint: function ( point ) {
 		containsPoint: function ( point ) {
 
 
@@ -44967,6 +44928,8 @@
 	 * @author bhouston / http://clara.io
 	 * @author bhouston / http://clara.io
 	 */
 	 */
 
 
+	var _vector$3;
+
 	function Box2( min, max ) {
 	function Box2( min, max ) {
 
 
 		this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
 		this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
@@ -44999,21 +44962,17 @@
 
 
 		},
 		},
 
 
-		setFromCenterAndSize: function () {
-
-			var v1 = new Vector2();
-
-			return function setFromCenterAndSize( center, size ) {
+		setFromCenterAndSize: function ( center, size ) {
 
 
-				var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
-				this.min.copy( center ).sub( halfSize );
-				this.max.copy( center ).add( halfSize );
+			if ( _vector$3 === undefined ) _vector$3 = new Vector2();
 
 
-				return this;
+			var halfSize = _vector$3.copy( size ).multiplyScalar( 0.5 );
+			this.min.copy( center ).sub( halfSize );
+			this.max.copy( center ).add( halfSize );
 
 
-			};
+			return this;
 
 
-		}(),
+		},
 
 
 		clone: function () {
 		clone: function () {
 
 
@@ -45155,18 +45114,14 @@
 
 
 		},
 		},
 
 
-		distanceToPoint: function () {
-
-			var v1 = new Vector2();
+		distanceToPoint: function ( point ) {
 
 
-			return function distanceToPoint( point ) {
+			if ( _vector$3 === undefined ) _vector$3 = new Vector2();
 
 
-				var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
-				return clampedPoint.sub( point ).length();
+			var clampedPoint = _vector$3.copy( point ).clamp( this.min, this.max );
+			return clampedPoint.sub( point ).length();
 
 
-			};
-
-		}(),
+		},
 
 
 		intersect: function ( box ) {
 		intersect: function ( box ) {
 
 

File diff suppressed because it is too large
+ 163 - 195
build/three.min.js


+ 142 - 187
build/three.module.js

@@ -1629,6 +1629,8 @@ Object.assign( Quaternion.prototype, {
  * @author WestLangley / http://github.com/WestLangley
  * @author WestLangley / http://github.com/WestLangley
  */
  */
 
 
+var _vector, _quaternion;
+
 function Vector3( x, y, z ) {
 function Vector3( x, y, z ) {
 
 
 	this.x = x || 0;
 	this.x = x || 0;
@@ -1850,35 +1852,27 @@ Object.assign( Vector3.prototype, {
 
 
 	},
 	},
 
 
-	applyEuler: function () {
-
-		var quaternion = new Quaternion();
-
-		return function applyEuler( euler ) {
-
-			if ( ! ( euler && euler.isEuler ) ) {
+	applyEuler: function ( euler ) {
 
 
-				console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
-
-			}
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-			return this.applyQuaternion( quaternion.setFromEuler( euler ) );
+		if ( ! ( euler && euler.isEuler ) ) {
 
 
-		};
+			console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
 
 
-	}(),
+		}
 
 
-	applyAxisAngle: function () {
+		return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
 
 
-		var quaternion = new Quaternion();
+	},
 
 
-		return function applyAxisAngle( axis, angle ) {
+	applyAxisAngle: function ( axis, angle ) {
 
 
-			return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-		};
+		return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
 
 
-	}(),
+	},
 
 
 	applyMatrix3: function ( m ) {
 	applyMatrix3: function ( m ) {
 
 
@@ -2162,34 +2156,26 @@ Object.assign( Vector3.prototype, {
 
 
 	},
 	},
 
 
-	projectOnPlane: function () {
+	projectOnPlane: function ( planeNormal ) {
 
 
-		var v1 = new Vector3();
+		if ( _vector === undefined ) _vector = new Vector3();
 
 
-		return function projectOnPlane( planeNormal ) {
+		_vector.copy( this ).projectOnVector( planeNormal );
 
 
-			v1.copy( this ).projectOnVector( planeNormal );
+		return this.sub( _vector );
 
 
-			return this.sub( v1 );
+	},
 
 
-		};
+	reflect: function ( normal ) {
 
 
-	}(),
-
-	reflect: function () {
+		if ( _vector === undefined ) _vector = new Vector3();
 
 
 		// reflect incident vector off plane orthogonal to normal
 		// reflect incident vector off plane orthogonal to normal
 		// normal is assumed to have unit length
 		// normal is assumed to have unit length
 
 
-		var v1 = new Vector3();
-
-		return function reflect( normal ) {
+		return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
 
 
-			return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
-
-		};
-
-	}(),
+	},
 
 
 	angleTo: function ( v ) {
 	angleTo: function ( v ) {
 
 
@@ -2343,7 +2329,7 @@ Object.assign( Vector3.prototype, {
  * @author tschw
  * @author tschw
  */
  */
 
 
-var _vector;
+var _vector$1;
 
 
 function Matrix3() {
 function Matrix3() {
 
 
@@ -2430,17 +2416,17 @@ Object.assign( Matrix3.prototype, {
 
 
 	applyToBufferAttribute: function ( attribute ) {
 	applyToBufferAttribute: function ( attribute ) {
 
 
-		if ( _vector === undefined ) _vector = new Vector3();
+		if ( _vector$1 === undefined ) _vector$1 = new Vector3();
 
 
 		for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 		for ( var i = 0, l = attribute.count; i < l; i ++ ) {
 
 
-			_vector.x = attribute.getX( i );
-			_vector.y = attribute.getY( i );
-			_vector.z = attribute.getZ( i );
+			_vector$1.x = attribute.getX( i );
+			_vector$1.y = attribute.getY( i );
+			_vector$1.z = attribute.getZ( i );
 
 
-			_vector.applyMatrix3( this );
+			_vector$1.applyMatrix3( this );
 
 
-			attribute.setXYZ( i, _vector.x, _vector.y, _vector.z );
+			attribute.setXYZ( i, _vector$1.x, _vector$1.y, _vector$1.z );
 
 
 		}
 		}
 
 
@@ -4817,7 +4803,7 @@ Object.assign( Matrix4.prototype, {
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
-var _matrix, _quaternion;
+var _matrix, _quaternion$1;
 
 
 function Euler( x, y, z, order ) {
 function Euler( x, y, z, order ) {
 
 
@@ -5083,11 +5069,11 @@ Object.assign( Euler.prototype, {
 
 
 		// WARNING: this discards revolution information -bhouston
 		// WARNING: this discards revolution information -bhouston
 
 
-		if ( _quaternion === undefined ) _quaternion = new Quaternion();
+		if ( _quaternion$1 === undefined ) _quaternion$1 = new Quaternion();
 
 
-		_quaternion.setFromEuler( this );
+		_quaternion$1.setFromEuler( this );
 
 
-		return this.setFromQuaternion( _quaternion, newOrder );
+		return this.setFromQuaternion( _quaternion$1, newOrder );
 
 
 	},
 	},
 
 
@@ -7875,7 +7861,7 @@ Object.assign( Triangle.prototype, {
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
+var _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
 	'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 	'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 	'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 	'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 	'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
 	'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
@@ -7900,6 +7886,9 @@ var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0
 	'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 	'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 	'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 	'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 
 
+var _hslA = { h: 0, s: 0, l: 0 };
+var _hslB = { h: 0, s: 0, l: 0 };
+
 function Color( r, g, b ) {
 function Color( r, g, b ) {
 
 
 	if ( g === undefined && b === undefined ) {
 	if ( g === undefined && b === undefined ) {
@@ -8130,7 +8119,7 @@ Object.assign( Color.prototype, {
 		if ( style && style.length > 0 ) {
 		if ( style && style.length > 0 ) {
 
 
 			// color keywords
 			// color keywords
-			var hex = ColorKeywords[ style ];
+			var hex = _colorKeywords[ style ];
 
 
 			if ( hex !== undefined ) {
 			if ( hex !== undefined ) {
 
 
@@ -8312,23 +8301,17 @@ Object.assign( Color.prototype, {
 
 
 	},
 	},
 
 
-	offsetHSL: function () {
-
-		var hsl = {};
+	offsetHSL: function ( h, s, l ) {
 
 
-		return function ( h, s, l ) {
+		this.getHSL( _hslA );
 
 
-			this.getHSL( hsl );
+		_hslA.h += h; _hslA.s += s; _hslA.l += l;
 
 
-			hsl.h += h; hsl.s += s; hsl.l += l;
+		this.setHSL( _hslA.h, _hslA.s, _hslA.l );
 
 
-			this.setHSL( hsl.h, hsl.s, hsl.l );
-
-			return this;
-
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	add: function ( color ) {
 	add: function ( color ) {
 
 
@@ -8400,27 +8383,20 @@ Object.assign( Color.prototype, {
 
 
 	},
 	},
 
 
-	lerpHSL: function () {
-
-		var hslA = { h: 0, s: 0, l: 0 };
-		var hslB = { h: 0, s: 0, l: 0 };
-
-		return function lerpHSL( color, alpha ) {
+	lerpHSL: function ( color, alpha ) {
 
 
-			this.getHSL( hslA );
-			color.getHSL( hslB );
+		this.getHSL( _hslA );
+		color.getHSL( _hslB );
 
 
-			var h = _Math.lerp( hslA.h, hslB.h, alpha );
-			var s = _Math.lerp( hslA.s, hslB.s, alpha );
-			var l = _Math.lerp( hslA.l, hslB.l, alpha );
+		var h = _Math.lerp( _hslA.h, _hslB.h, alpha );
+		var s = _Math.lerp( _hslA.s, _hslB.s, alpha );
+		var l = _Math.lerp( _hslA.l, _hslB.l, alpha );
 
 
-			this.setHSL( h, s, l );
+		this.setHSL( h, s, l );
 
 
-			return this;
-
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	equals: function ( c ) {
 	equals: function ( c ) {
 
 
@@ -13912,6 +13888,8 @@ DataTexture.prototype.isDataTexture = true;
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _vector1, _vector2, _normalMatrix;
+
 function Plane( normal, constant ) {
 function Plane( normal, constant ) {
 
 
 	// normal is assumed to be normalized
 	// normal is assumed to be normalized
@@ -13952,24 +13930,24 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	setFromCoplanarPoints: function () {
+	setFromCoplanarPoints: function ( a, b, c ) {
 
 
-		var v1 = new Vector3();
-		var v2 = new Vector3();
+		if ( _vector1 === undefined ) {
 
 
-		return function setFromCoplanarPoints( a, b, c ) {
+			_vector1 = new Vector3();
+			_vector2 = new Vector3();
 
 
-			var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+		}
 
 
-			// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+		var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();
 
 
-			this.setFromNormalAndCoplanarPoint( normal, a );
+		// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
 
 
-			return this;
+		this.setFromNormalAndCoplanarPoint( normal, a );
 
 
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	clone: function () {
 	clone: function () {
 
 
@@ -14032,50 +14010,46 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	intersectLine: function () {
-
-		var v1 = new Vector3();
-
-		return function intersectLine( line, target ) {
+	intersectLine: function ( line, target ) {
 
 
-			if ( target === undefined ) {
-
-				console.warn( 'THREE.Plane: .intersectLine() target is now required' );
-				target = new Vector3();
+		if ( _vector1 === undefined ) _vector1 = new Vector3();
 
 
-			}
+		if ( target === undefined ) {
 
 
-			var direction = line.delta( v1 );
+			console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+			target = new Vector3();
 
 
-			var denominator = this.normal.dot( direction );
+		}
 
 
-			if ( denominator === 0 ) {
+		var direction = line.delta( _vector1 );
 
 
-				// line is coplanar, return origin
-				if ( this.distanceToPoint( line.start ) === 0 ) {
+		var denominator = this.normal.dot( direction );
 
 
-					return target.copy( line.start );
+		if ( denominator === 0 ) {
 
 
-				}
+			// line is coplanar, return origin
+			if ( this.distanceToPoint( line.start ) === 0 ) {
 
 
-				// Unsure if this is the correct method to handle this case.
-				return undefined;
+				return target.copy( line.start );
 
 
 			}
 			}
 
 
-			var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+			// Unsure if this is the correct method to handle this case.
+			return undefined;
 
 
-			if ( t < 0 || t > 1 ) {
+		}
 
 
-				return undefined;
+		var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
 
 
-			}
+		if ( t < 0 || t > 1 ) {
 
 
-			return target.copy( direction ).multiplyScalar( t ).add( line.start );
+			return undefined;
 
 
-		};
+		}
 
 
-	}(),
+		return target.copy( direction ).multiplyScalar( t ).add( line.start );
+
+	},
 
 
 	intersectsLine: function ( line ) {
 	intersectsLine: function ( line ) {
 
 
@@ -14113,26 +14087,26 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	applyMatrix4: function () {
+	applyMatrix4: function ( matrix, optionalNormalMatrix ) {
 
 
-		var v1 = new Vector3();
-		var m1 = new Matrix3();
+		if ( _normalMatrix === undefined ) {
 
 
-		return function applyMatrix4( matrix, optionalNormalMatrix ) {
+			_normalMatrix = new Matrix3();
+			_vector1 = new Vector3();
 
 
-			var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+		}
 
 
-			var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+		var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );
 
 
-			var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+		var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );
 
 
-			this.constant = - referencePoint.dot( normal );
+		var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
 
 
-			return this;
+		this.constant = - referencePoint.dot( normal );
 
 
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	translate: function ( offset ) {
 	translate: function ( offset ) {
 
 
@@ -14156,6 +14130,9 @@ Object.assign( Plane.prototype, {
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _sphere;
+var _vector$2;
+
 function Frustum( p0, p1, p2, p3, p4, p5 ) {
 function Frustum( p0, p1, p2, p3, p4, p5 ) {
 
 
 	this.planes = [
 	this.planes = [
@@ -14228,41 +14205,29 @@ Object.assign( Frustum.prototype, {
 
 
 	},
 	},
 
 
-	intersectsObject: function () {
-
-		var sphere = new Sphere();
-
-		return function intersectsObject( object ) {
-
-			var geometry = object.geometry;
+	intersectsObject: function ( object ) {
 
 
-			if ( geometry.boundingSphere === null )
-				geometry.computeBoundingSphere();
+		if ( _sphere === undefined ) _sphere = new Sphere();
 
 
-			sphere.copy( geometry.boundingSphere )
-				.applyMatrix4( object.matrixWorld );
-
-			return this.intersectsSphere( sphere );
-
-		};
+		var geometry = object.geometry;
 
 
-	}(),
+		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-	intersectsSprite: function () {
+		_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
 
 
-		var sphere = new Sphere();
+		return this.intersectsSphere( _sphere );
 
 
-		return function intersectsSprite( sprite ) {
+	},
 
 
-			sphere.center.set( 0, 0, 0 );
-			sphere.radius = 0.7071067811865476;
-			sphere.applyMatrix4( sprite.matrixWorld );
+	intersectsSprite: function ( sprite ) {
 
 
-			return this.intersectsSphere( sphere );
+		_sphere.center.set( 0, 0, 0 );
+		_sphere.radius = 0.7071067811865476;
+		_sphere.applyMatrix4( sprite.matrixWorld );
 
 
-		};
+		return this.intersectsSphere( _sphere );
 
 
-	}(),
+	},
 
 
 	intersectsSphere: function ( sphere ) {
 	intersectsSphere: function ( sphere ) {
 
 
@@ -14286,37 +14251,33 @@ Object.assign( Frustum.prototype, {
 
 
 	},
 	},
 
 
-	intersectsBox: function () {
-
-		var p = new Vector3();
-
-		return function intersectsBox( box ) {
+	intersectsBox: function ( box ) {
 
 
-			var planes = this.planes;
+		if ( _vector$2 === undefined ) _vector$2 = new Vector3();
 
 
-			for ( var i = 0; i < 6; i ++ ) {
+		var planes = this.planes;
 
 
-				var plane = planes[ i ];
+		for ( var i = 0; i < 6; i ++ ) {
 
 
-				// corner at max distance
+			var plane = planes[ i ];
 
 
-				p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
-				p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
-				p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+			// corner at max distance
 
 
-				if ( plane.distanceToPoint( p ) < 0 ) {
+			_vector$2.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+			_vector$2.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+			_vector$2.z = plane.normal.z > 0 ? box.max.z : box.min.z;
 
 
-					return false;
+			if ( plane.distanceToPoint( _vector$2 ) < 0 ) {
 
 
-				}
+				return false;
 
 
 			}
 			}
 
 
-			return true;
+		}
 
 
-		};
+		return true;
 
 
-	}(),
+	},
 
 
 	containsPoint: function ( point ) {
 	containsPoint: function ( point ) {
 
 
@@ -44961,6 +44922,8 @@ Object.assign( Cylindrical.prototype, {
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _vector$3;
+
 function Box2( min, max ) {
 function Box2( min, max ) {
 
 
 	this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
 	this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
@@ -44993,21 +44956,17 @@ Object.assign( Box2.prototype, {
 
 
 	},
 	},
 
 
-	setFromCenterAndSize: function () {
-
-		var v1 = new Vector2();
-
-		return function setFromCenterAndSize( center, size ) {
+	setFromCenterAndSize: function ( center, size ) {
 
 
-			var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
-			this.min.copy( center ).sub( halfSize );
-			this.max.copy( center ).add( halfSize );
+		if ( _vector$3 === undefined ) _vector$3 = new Vector2();
 
 
-			return this;
+		var halfSize = _vector$3.copy( size ).multiplyScalar( 0.5 );
+		this.min.copy( center ).sub( halfSize );
+		this.max.copy( center ).add( halfSize );
 
 
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	clone: function () {
 	clone: function () {
 
 
@@ -45149,18 +45108,14 @@ Object.assign( Box2.prototype, {
 
 
 	},
 	},
 
 
-	distanceToPoint: function () {
-
-		var v1 = new Vector2();
+	distanceToPoint: function ( point ) {
 
 
-		return function distanceToPoint( point ) {
+		if ( _vector$3 === undefined ) _vector$3 = new Vector2();
 
 
-			var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
-			return clampedPoint.sub( point ).length();
+		var clampedPoint = _vector$3.copy( point ).clamp( this.min, this.max );
+		return clampedPoint.sub( point ).length();
 
 
-		};
-
-	}(),
+	},
 
 
 	intersect: function ( box ) {
 	intersect: function ( box ) {
 
 

+ 2 - 0
docs/list.js

@@ -24,6 +24,7 @@ var list = {
 				"How to update things": "manual/en/introduction/How-to-update-things",
 				"How to update things": "manual/en/introduction/How-to-update-things",
 				"How to dispose of objects": "manual/en/introduction/How-to-dispose-of-objects",
 				"How to dispose of objects": "manual/en/introduction/How-to-dispose-of-objects",
 				"How to create VR content": "manual/en/introduction/How-to-create-VR-content",
 				"How to create VR content": "manual/en/introduction/How-to-create-VR-content",
+				"How to use post-processing": "manual/en/introduction/How-to-use-post-processing",
 				"Matrix transformations": "manual/en/introduction/Matrix-transformations",
 				"Matrix transformations": "manual/en/introduction/Matrix-transformations",
 				"Animation system": "manual/en/introduction/Animation-system"
 				"Animation system": "manual/en/introduction/Animation-system"
 			},
 			},
@@ -461,6 +462,7 @@ var list = {
 				"如何更新场景": "manual/zh/introduction/How-to-update-things",
 				"如何更新场景": "manual/zh/introduction/How-to-update-things",
 				"如何废置对象": "manual/zh/introduction/How-to-dispose-of-objects",
 				"如何废置对象": "manual/zh/introduction/How-to-dispose-of-objects",
 				"如何创建VR内容": "manual/zh/introduction/How-to-create-VR-content",
 				"如何创建VR内容": "manual/zh/introduction/How-to-create-VR-content",
+				"How to use post-processing": "manual/zh/introduction/How-to-use-post-processing",
 				"矩阵变换": "manual/zh/introduction/Matrix-transformations",
 				"矩阵变换": "manual/zh/introduction/Matrix-transformations",
 				"动画系统": "manual/zh/introduction/Animation-system"
 				"动画系统": "manual/zh/introduction/Animation-system"
 			},
 			},

+ 112 - 0
docs/manual/en/introduction/How-to-use-post-processing.html

@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8">
+		<base href="../../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		<h1>How to use post-processing</h1>
+
+		<p>
+			Many three.js applications render their 3D objects directly to the screen. Sometimes, however, you want to apply one or more graphical
+			effects like Depth-Of-Field, Bloom, Film Grain or various types of Anti-aliasing. Post-processing is a widely used approach
+			to implement such effects. First, the scene is rendered to a render target which represents a buffer in the video card's memory.
+			In the next step one ore more post-processing passes apply filters and effects to the image buffer before it is eventually rendered to
+			the screen.
+		</p>
+		<p>
+			three.js provides a complete post-processing solution via [page:EffectComposer] to implement such a workflow.
+		</p>
+
+		<h2>Workflow</h2>
+
+		<p>
+			The first step in the process is to import all necessary files from the examples directory. The guide assumes your are using the official
+			[link:https://www.npmjs.com/package/three npm package] of three.js. For our basic demo in this guide we need the following files.
+		</p>
+
+		<code>
+		import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
+		import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
+		import { GlitchPass } from 'three/examples/jsm/postprocessing/GlitchPass.js';
+		</code>
+
+		<p>
+			After all files are successfully imported, we can create our composer by passing in an instance of [page:WebGLRenderer].
+		</p>
+
+		<code>
+		var composer = new EffectComposer( renderer );
+		</code>
+
+		<p>
+			When using a composer, it's necessary to change the application's animation loop. Instead of calling the render method of
+			[page:WebGLRenderer], we now use the respective counterpart of [page:EffectComposer].
+		</p>
+
+		<code>
+		function animate() {
+
+			requestAnimationFrame( animate );
+
+			composer.render();
+
+		}
+		</code>
+
+		<p>
+			Our composer is now ready so it's possible to configure the chain of post-processing passes. These passes are responsible for creating
+			the final visual output of the application. They are processed in order of their addition/insertion. In our example, the instance of *RenderPass*
+			is executed first and then the instance of *GlitchPass*. The last enabled pass in the chain is automatically rendered to the screen. The setup
+			of the passes looks like so:
+		</p>
+
+		<code>
+		var renderPass = new RenderPass( scene, camera );
+		composer.addPass( renderPass );
+
+		var glitchPass = new GlitchPass();
+		composer.addPass( glitchPass );
+		</code>
+
+		<p>
+			*RenderPass* is normally placed at the beginning of the chain in order to provide the rendered scene as an input for the next post-processing step. In our case,
+			*GlitchPass* is going to use these image data to apply a wild glitch effect. Check out this [link:https://threejs.org/examples/webgl_postprocessing_glitch live example]
+			to see it in action.
+		</p>
+
+		<h2>Built-in Passes</h2>
+
+		<p>
+			You can use a wide range of pre-defined post-processing passes provided by the engine. They are located in the
+			[link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/postprocessing postprocessing] directory.
+		</p>
+
+		<h2>Custom Passes</h2>
+
+		<p>
+			Sometimes you want to write a custom post-processing shader and include it into the chain of post-processing passes. For this scenario,
+			you can utilize *ShaderPass*. After importing the file and your custom shader, you can use the following code to setup the pass.
+		</p>
+
+		<code>
+		import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
+		import { LuminosityShader } from 'three/examples/jsm/shaders/LuminosityShader.js';
+
+		// later in your init routine
+
+		var luminosityPass = new ShaderPass( LuminosityShader );
+		composer.addPass( luminosityPass );
+		</code>
+
+		<p>
+			The repository provides a file called [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/shaders/CopyShader.js CopyShader] which is a
+			good starting code for your own custom shader. *CopyShader* just copies the image contents of the [page:EffectComposer]'s read buffer
+			to its write buffer without applying any effects.
+		</p>
+
+	</body>
+</html>

+ 112 - 0
docs/manual/zh/introduction/How-to-use-post-processing.html

@@ -0,0 +1,112 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8">
+		<base href="../../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		<h1>How to use post-processing</h1>
+
+		<p>
+			Many three.js applications render their 3D objects directly to the screen. Sometimes, however, you want to apply one or more graphical
+			effects like Depth-Of-Field, Bloom, Film Grain or various types of Anti-aliasing. Post-processing is a widely used approach
+			to implement such effects. First, the scene is rendered to a render target which represents a buffer in the video card's memory.
+			In the next step one ore more post-processing passes apply filters and effects to the image buffer before it is eventually rendered to
+			the screen.
+		</p>
+		<p>
+			three.js provides a complete post-processing solution via [page:EffectComposer] to implement such a workflow.
+		</p>
+
+		<h2>Workflow</h2>
+
+		<p>
+			The first step in the process is to import all necessary files from the examples directory. The guide assumes your are using the official
+			[link:https://www.npmjs.com/package/three npm package] of three.js. For our basic demo in this guide we need the following files.
+		</p>
+
+		<code>
+		import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js';
+		import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass.js';
+		import { GlitchPass } from 'three/examples/jsm/postprocessing/GlitchPass.js';
+		</code>
+
+		<p>
+			After all files are successfully imported, we can create our composer by passing in an instance of [page:WebGLRenderer].
+		</p>
+
+		<code>
+		var composer = new EffectComposer( renderer );
+		</code>
+
+		<p>
+			When using a composer, it's necessary to change the application's animation loop. Instead of calling the render method of
+			[page:WebGLRenderer], we now use the respective counterpart of [page:EffectComposer].
+		</p>
+
+		<code>
+		function animate() {
+
+			requestAnimationFrame( animate );
+
+			composer.render();
+
+		}
+		</code>
+
+		<p>
+			Our composer is now ready so it's possible to configure the chain of post-processing passes. These passes are responsible for creating
+			the final visual output of the application. They are processed in order of their addition/insertion. In our example, the instance of *RenderPass*
+			is executed first and then the instance of *GlitchPass*. The last enabled pass in the chain is automatically rendered to the screen. The setup
+			of the passes looks like so:
+		</p>
+
+		<code>
+		var renderPass = new RenderPass( scene, camera );
+		composer.addPass( renderPass );
+
+		var glitchPass = new GlitchPass();
+		composer.addPass( glitchPass );
+		</code>
+
+		<p>
+			*RenderPass* is normally placed at the beginning of the chain in order to provide the rendered scene as an input for the next post-processing step. In our case,
+			*GlitchPass* is going to use these image data to apply a wild glitch effect. Check out this [link:https://threejs.org/examples/webgl_postprocessing_glitch live example]
+			to see it in action.
+		</p>
+
+		<h2>Built-in Passes</h2>
+
+		<p>
+			You can use a wide range of pre-defined post-processing passes provided by the engine. They are located in the
+			[link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm/postprocessing postprocessing] directory.
+		</p>
+
+		<h2>Custom Passes</h2>
+
+		<p>
+			Sometimes you want to write a custom post-processing shader and include it into the chain of post-processing passes. For this scenario,
+			you can utilize *ShaderPass*. After importing the file and your custom shader, you can use the following code to setup the pass.
+		</p>
+
+		<code>
+		import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass.js';
+		import { LuminosityShader } from 'three/examples/jsm/shaders/LuminosityShader.js';
+
+		// later in your init routine
+
+		var luminosityPass = new ShaderPass( LuminosityShader );
+		composer.addPass( luminosityPass );
+		</code>
+
+		<p>
+			The repository provides a file called [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/shaders/CopyShader.js CopyShader] which is a
+			good starting code for your own custom shader. *CopyShader* just copies the image contents of the [page:EffectComposer]'s read buffer
+			to its write buffer without applying any effects.
+		</p>
+
+	</body>
+</html>

+ 14 - 20
src/math/Box2.js

@@ -4,6 +4,8 @@ import { Vector2 } from './Vector2.js';
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _vector;
+
 function Box2( min, max ) {
 function Box2( min, max ) {
 
 
 	this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
 	this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
@@ -36,21 +38,17 @@ Object.assign( Box2.prototype, {
 
 
 	},
 	},
 
 
-	setFromCenterAndSize: function () {
-
-		var v1 = new Vector2();
+	setFromCenterAndSize: function ( center, size ) {
 
 
-		return function setFromCenterAndSize( center, size ) {
+		if ( _vector === undefined ) _vector = new Vector2();
 
 
-			var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
-			this.min.copy( center ).sub( halfSize );
-			this.max.copy( center ).add( halfSize );
+		var halfSize = _vector.copy( size ).multiplyScalar( 0.5 );
+		this.min.copy( center ).sub( halfSize );
+		this.max.copy( center ).add( halfSize );
 
 
-			return this;
-
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	clone: function () {
 	clone: function () {
 
 
@@ -192,18 +190,14 @@ Object.assign( Box2.prototype, {
 
 
 	},
 	},
 
 
-	distanceToPoint: function () {
-
-		var v1 = new Vector2();
+	distanceToPoint: function ( point ) {
 
 
-		return function distanceToPoint( point ) {
+		if ( _vector === undefined ) _vector = new Vector2();
 
 
-			var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
-			return clampedPoint.sub( point ).length();
+		var clampedPoint = _vector.copy( point ).clamp( this.min, this.max );
+		return clampedPoint.sub( point ).length();
 
 
-		};
-
-	}(),
+	},
 
 
 	intersect: function ( box ) {
 	intersect: function ( box ) {
 
 

+ 20 - 30
src/math/Color.js

@@ -4,7 +4,7 @@ import { _Math } from './Math.js';
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
+var _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,
 	'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 	'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,
 	'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 	'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,
 	'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
 	'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,
@@ -29,6 +29,9 @@ var ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0
 	'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 	'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,
 	'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 	'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };
 
 
+var _hslA = { h: 0, s: 0, l: 0 };
+var _hslB = { h: 0, s: 0, l: 0 };
+
 function Color( r, g, b ) {
 function Color( r, g, b ) {
 
 
 	if ( g === undefined && b === undefined ) {
 	if ( g === undefined && b === undefined ) {
@@ -259,7 +262,7 @@ Object.assign( Color.prototype, {
 		if ( style && style.length > 0 ) {
 		if ( style && style.length > 0 ) {
 
 
 			// color keywords
 			// color keywords
-			var hex = ColorKeywords[ style ];
+			var hex = _colorKeywords[ style ];
 
 
 			if ( hex !== undefined ) {
 			if ( hex !== undefined ) {
 
 
@@ -441,23 +444,17 @@ Object.assign( Color.prototype, {
 
 
 	},
 	},
 
 
-	offsetHSL: function () {
-
-		var hsl = {};
-
-		return function ( h, s, l ) {
+	offsetHSL: function ( h, s, l ) {
 
 
-			this.getHSL( hsl );
+		this.getHSL( _hslA );
 
 
-			hsl.h += h; hsl.s += s; hsl.l += l;
+		_hslA.h += h; _hslA.s += s; _hslA.l += l;
 
 
-			this.setHSL( hsl.h, hsl.s, hsl.l );
+		this.setHSL( _hslA.h, _hslA.s, _hslA.l );
 
 
-			return this;
-
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	add: function ( color ) {
 	add: function ( color ) {
 
 
@@ -529,27 +526,20 @@ Object.assign( Color.prototype, {
 
 
 	},
 	},
 
 
-	lerpHSL: function () {
+	lerpHSL: function ( color, alpha ) {
 
 
-		var hslA = { h: 0, s: 0, l: 0 };
-		var hslB = { h: 0, s: 0, l: 0 };
+		this.getHSL( _hslA );
+		color.getHSL( _hslB );
 
 
-		return function lerpHSL( color, alpha ) {
+		var h = _Math.lerp( _hslA.h, _hslB.h, alpha );
+		var s = _Math.lerp( _hslA.s, _hslB.s, alpha );
+		var l = _Math.lerp( _hslA.l, _hslB.l, alpha );
 
 
-			this.getHSL( hslA );
-			color.getHSL( hslB );
+		this.setHSL( h, s, l );
 
 
-			var h = _Math.lerp( hslA.h, hslB.h, alpha );
-			var s = _Math.lerp( hslA.s, hslB.s, alpha );
-			var l = _Math.lerp( hslA.l, hslB.l, alpha );
-
-			this.setHSL( h, s, l );
-
-			return this;
-
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	equals: function ( c ) {
 	equals: function ( c ) {
 
 

+ 30 - 43
src/math/Frustum.js

@@ -8,6 +8,9 @@ import { Plane } from './Plane.js';
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _sphere;
+var _vector;
+
 function Frustum( p0, p1, p2, p3, p4, p5 ) {
 function Frustum( p0, p1, p2, p3, p4, p5 ) {
 
 
 	this.planes = [
 	this.planes = [
@@ -80,41 +83,29 @@ Object.assign( Frustum.prototype, {
 
 
 	},
 	},
 
 
-	intersectsObject: function () {
-
-		var sphere = new Sphere();
-
-		return function intersectsObject( object ) {
-
-			var geometry = object.geometry;
+	intersectsObject: function ( object ) {
 
 
-			if ( geometry.boundingSphere === null )
-				geometry.computeBoundingSphere();
+		if ( _sphere === undefined ) _sphere = new Sphere();
 
 
-			sphere.copy( geometry.boundingSphere )
-				.applyMatrix4( object.matrixWorld );
+		var geometry = object.geometry;
 
 
-			return this.intersectsSphere( sphere );
+		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
 
-		};
+		_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );
 
 
-	}(),
+		return this.intersectsSphere( _sphere );
 
 
-	intersectsSprite: function () {
-
-		var sphere = new Sphere();
-
-		return function intersectsSprite( sprite ) {
+	},
 
 
-			sphere.center.set( 0, 0, 0 );
-			sphere.radius = 0.7071067811865476;
-			sphere.applyMatrix4( sprite.matrixWorld );
+	intersectsSprite: function ( sprite ) {
 
 
-			return this.intersectsSphere( sphere );
+		_sphere.center.set( 0, 0, 0 );
+		_sphere.radius = 0.7071067811865476;
+		_sphere.applyMatrix4( sprite.matrixWorld );
 
 
-		};
+		return this.intersectsSphere( _sphere );
 
 
-	}(),
+	},
 
 
 	intersectsSphere: function ( sphere ) {
 	intersectsSphere: function ( sphere ) {
 
 
@@ -138,37 +129,33 @@ Object.assign( Frustum.prototype, {
 
 
 	},
 	},
 
 
-	intersectsBox: function () {
+	intersectsBox: function ( box ) {
 
 
-		var p = new Vector3();
+		if ( _vector === undefined ) _vector = new Vector3();
 
 
-		return function intersectsBox( box ) {
-
-			var planes = this.planes;
-
-			for ( var i = 0; i < 6; i ++ ) {
+		var planes = this.planes;
 
 
-				var plane = planes[ i ];
+		for ( var i = 0; i < 6; i ++ ) {
 
 
-				// corner at max distance
+			var plane = planes[ i ];
 
 
-				p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
-				p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
-				p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+			// corner at max distance
 
 
-				if ( plane.distanceToPoint( p ) < 0 ) {
+			_vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+			_vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+			_vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;
 
 
-					return false;
+			if ( plane.distanceToPoint( _vector ) < 0 ) {
 
 
-				}
+				return false;
 
 
 			}
 			}
 
 
-			return true;
+		}
 
 
-		};
+		return true;
 
 
-	}(),
+	},
 
 
 	containsPoint: function ( point ) {
 	containsPoint: function ( point ) {
 
 

+ 45 - 47
src/math/Plane.js

@@ -5,6 +5,8 @@ import { Vector3 } from './Vector3.js';
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
+var _vector1, _vector2, _normalMatrix;
+
 function Plane( normal, constant ) {
 function Plane( normal, constant ) {
 
 
 	// normal is assumed to be normalized
 	// normal is assumed to be normalized
@@ -45,24 +47,24 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	setFromCoplanarPoints: function () {
+	setFromCoplanarPoints: function ( a, b, c ) {
 
 
-		var v1 = new Vector3();
-		var v2 = new Vector3();
+		if ( _vector1 === undefined ) {
 
 
-		return function setFromCoplanarPoints( a, b, c ) {
+			_vector1 = new Vector3();
+			_vector2 = new Vector3();
 
 
-			var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+		}
 
 
-			// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+		var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();
 
 
-			this.setFromNormalAndCoplanarPoint( normal, a );
+		// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
 
 
-			return this;
+		this.setFromNormalAndCoplanarPoint( normal, a );
 
 
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	clone: function () {
 	clone: function () {
 
 
@@ -125,50 +127,46 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	intersectLine: function () {
-
-		var v1 = new Vector3();
+	intersectLine: function ( line, target ) {
 
 
-		return function intersectLine( line, target ) {
+		if ( _vector1 === undefined ) _vector1 = new Vector3();
 
 
-			if ( target === undefined ) {
-
-				console.warn( 'THREE.Plane: .intersectLine() target is now required' );
-				target = new Vector3();
-
-			}
+		if ( target === undefined ) {
 
 
-			var direction = line.delta( v1 );
+			console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+			target = new Vector3();
 
 
-			var denominator = this.normal.dot( direction );
+		}
 
 
-			if ( denominator === 0 ) {
+		var direction = line.delta( _vector1 );
 
 
-				// line is coplanar, return origin
-				if ( this.distanceToPoint( line.start ) === 0 ) {
+		var denominator = this.normal.dot( direction );
 
 
-					return target.copy( line.start );
+		if ( denominator === 0 ) {
 
 
-				}
+			// line is coplanar, return origin
+			if ( this.distanceToPoint( line.start ) === 0 ) {
 
 
-				// Unsure if this is the correct method to handle this case.
-				return undefined;
+				return target.copy( line.start );
 
 
 			}
 			}
 
 
-			var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+			// Unsure if this is the correct method to handle this case.
+			return undefined;
 
 
-			if ( t < 0 || t > 1 ) {
+		}
 
 
-				return undefined;
+		var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
 
 
-			}
+		if ( t < 0 || t > 1 ) {
 
 
-			return target.copy( direction ).multiplyScalar( t ).add( line.start );
+			return undefined;
 
 
-		};
+		}
 
 
-	}(),
+		return target.copy( direction ).multiplyScalar( t ).add( line.start );
+
+	},
 
 
 	intersectsLine: function ( line ) {
 	intersectsLine: function ( line ) {
 
 
@@ -206,26 +204,26 @@ Object.assign( Plane.prototype, {
 
 
 	},
 	},
 
 
-	applyMatrix4: function () {
+	applyMatrix4: function ( matrix, optionalNormalMatrix ) {
 
 
-		var v1 = new Vector3();
-		var m1 = new Matrix3();
+		if ( _normalMatrix === undefined ) {
 
 
-		return function applyMatrix4( matrix, optionalNormalMatrix ) {
+			_normalMatrix = new Matrix3();
+			_vector1 = new Vector3();
 
 
-			var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+		}
 
 
-			var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+		var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );
 
 
-			var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+		var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );
 
 
-			this.constant = - referencePoint.dot( normal );
+		var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
 
 
-			return this;
+		this.constant = - referencePoint.dot( normal );
 
 
-		};
+		return this;
 
 
-	}(),
+	},
 
 
 	translate: function ( offset ) {
 	translate: function ( offset ) {
 
 

+ 22 - 36
src/math/Vector3.js

@@ -10,6 +10,8 @@ import { Quaternion } from './Quaternion.js';
  * @author WestLangley / http://github.com/WestLangley
  * @author WestLangley / http://github.com/WestLangley
  */
  */
 
 
+var _vector, _quaternion;
+
 function Vector3( x, y, z ) {
 function Vector3( x, y, z ) {
 
 
 	this.x = x || 0;
 	this.x = x || 0;
@@ -231,35 +233,27 @@ Object.assign( Vector3.prototype, {
 
 
 	},
 	},
 
 
-	applyEuler: function () {
-
-		var quaternion = new Quaternion();
-
-		return function applyEuler( euler ) {
-
-			if ( ! ( euler && euler.isEuler ) ) {
+	applyEuler: function ( euler ) {
 
 
-				console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-			}
+		if ( ! ( euler && euler.isEuler ) ) {
 
 
-			return this.applyQuaternion( quaternion.setFromEuler( euler ) );
+			console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
 
 
-		};
-
-	}(),
+		}
 
 
-	applyAxisAngle: function () {
+		return this.applyQuaternion( _quaternion.setFromEuler( euler ) );
 
 
-		var quaternion = new Quaternion();
+	},
 
 
-		return function applyAxisAngle( axis, angle ) {
+	applyAxisAngle: function ( axis, angle ) {
 
 
-			return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+		if ( _quaternion === undefined ) _quaternion = new Quaternion();
 
 
-		};
+		return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );
 
 
-	}(),
+	},
 
 
 	applyMatrix3: function ( m ) {
 	applyMatrix3: function ( m ) {
 
 
@@ -543,34 +537,26 @@ Object.assign( Vector3.prototype, {
 
 
 	},
 	},
 
 
-	projectOnPlane: function () {
-
-		var v1 = new Vector3();
+	projectOnPlane: function ( planeNormal ) {
 
 
-		return function projectOnPlane( planeNormal ) {
+		if ( _vector === undefined ) _vector = new Vector3();
 
 
-			v1.copy( this ).projectOnVector( planeNormal );
+		_vector.copy( this ).projectOnVector( planeNormal );
 
 
-			return this.sub( v1 );
+		return this.sub( _vector );
 
 
-		};
+	},
 
 
-	}(),
+	reflect: function ( normal ) {
 
 
-	reflect: function () {
+		if ( _vector === undefined ) _vector = new Vector3();
 
 
 		// reflect incident vector off plane orthogonal to normal
 		// reflect incident vector off plane orthogonal to normal
 		// normal is assumed to have unit length
 		// normal is assumed to have unit length
 
 
-		var v1 = new Vector3();
-
-		return function reflect( normal ) {
+		return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
 
 
-			return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
-
-		};
-
-	}(),
+	},
 
 
 	angleTo: function ( v ) {
 	angleTo: function ( v ) {
 
 

+ 7 - 2
src/renderers/shaders/UniformsUtils.d.ts

@@ -1,4 +1,9 @@
+export function cloneUniforms( uniforms_src: any ): any;
+export function mergeUniforms( uniforms: any[] ): any;
+
 export namespace UniformsUtils {
 export namespace UniformsUtils {
-	export function merge( uniforms: any[] ): any;
-	export function clone( uniforms_src: any ): any;
+	export {
+		mergeUniforms as merge,
+		cloneUniforms as clone,
+	};
 }
 }

+ 12 - 0
src/renderers/webgl/WebGLMorphtargets.d.ts

@@ -0,0 +1,12 @@
+import { Object3D } from '../../core/Object3D';
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Material } from '../../materials/Material';
+import { WebGLProgram } from './WebGLProgram';
+
+export class WebGLMorphtargets {
+
+	constructor( gl: WebGLRenderingContext );
+
+	update( object: Object3D, geometry: BufferGeometry, material: Material, program: WebGLProgram ): void;
+
+}

+ 25 - 0
src/renderers/webgl/WebGLRenderStates.d.ts

@@ -0,0 +1,25 @@
+import { Scene } from '../../scenes/Scene';
+import { Camera } from '../../cameras/Camera';
+import { Light } from '../../lights/Light';
+import { WebGLLights } from './WebGLLights';
+
+interface WebGLRenderState {
+
+	init(): void;
+	state: {
+		lightsArray: Light[];
+		shadowsArray: Light[];
+		lights: WebGLLights;
+	};
+	setupLights( camera: Camera ): void;
+	pushLight( light: Light ): void;
+	pushShadow( shadowLight: Light ): void;
+
+}
+
+export class WebGLRenderStates {
+
+	get( scene: Scene, camera: Camera ): WebGLRenderState;
+	dispose(): void;
+
+}

+ 12 - 2
src/renderers/webvr/WebVRManager.d.ts

@@ -1,15 +1,25 @@
 import { Object3D } from '../../core/Object3D';
 import { Object3D } from '../../core/Object3D';
+import { Group } from '../../objects/Group';
 import { PerspectiveCamera } from '../../cameras/PerspectiveCamera';
 import { PerspectiveCamera } from '../../cameras/PerspectiveCamera';
 import { ArrayCamera } from '../../cameras/ArrayCamera';
 import { ArrayCamera } from '../../cameras/ArrayCamera';
 import { Matrix4 } from '../../math/Matrix4';
 import { Matrix4 } from '../../math/Matrix4';
 
 
-export interface WebVRManager {
+export class WebVRManager {
+
+	constructor( renderer: any );
+
 	enabled: boolean;
 	enabled: boolean;
+	getController( id: number ): Group;
 	getDevice(): VRDisplay | null;
 	getDevice(): VRDisplay | null;
 	setDevice( device: VRDisplay | null ): void;
 	setDevice( device: VRDisplay | null ): void;
+	setFramebufferScaleFactor( value: number ): void;
+	setReferenceSpaceType( value: string ): void;
 	setPoseTarget( object: Object3D | null ): void;
 	setPoseTarget( object: Object3D | null ): void;
 	getCamera( camera: PerspectiveCamera ): PerspectiveCamera | ArrayCamera;
 	getCamera( camera: PerspectiveCamera ): PerspectiveCamera | ArrayCamera;
+	getStandingMatrix(): Matrix4;
+	isPresenting: () => boolean;
+	setAnimationLoop( callback: Function ): void;
 	submitFrame(): void;
 	submitFrame(): void;
 	dispose(): void;
 	dispose(): void;
-	getStandingMatrix(): Matrix4;
+
 }
 }

+ 3 - 0
src/renderers/webvr/WebVRUtils.d.ts

@@ -0,0 +1,3 @@
+import { Camera } from '../../cameras/Camera';
+
+export function setProjectionFromUnion( camera: Camera, cameraL: Camera, cameraR: Camera ): void;

+ 19 - 0
src/renderers/webvr/WebXRManager.d.ts

@@ -0,0 +1,19 @@
+import { Group } from '../../objects/Group';
+import { Camera } from '../../cameras/Camera';
+
+export class WebXRManager {
+
+	constructor( renderer: any, gl: WebGLRenderingContext );
+
+	enabled: boolean;
+	getController( id: number ): Group;
+	setFramebufferScaleFactor( value: number ): void;
+	setReferenceSpaceType( value: string ): void;
+	getSession(): any;
+	setSession( value: any ): void;
+	getCamera( camera: Camera ): Camera;
+	isPresenting: () => boolean;
+	setAnimationLoop( callback: Function ): void;
+	dispose(): void;
+
+}

Some files were not shown because too many files changed in this diff