Skip to content
Snippets Groups Projects
three.js 1000 KiB
Newer Older
  • Learn to ignore specific revisions
  • amandaghassaei's avatar
    amandaghassaei committed
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
    (function (global, factory) {
    	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    	typeof define === 'function' && define.amd ? define(['exports'], factory) :
    	(factory((global.THREE = global.THREE || {})));
    }(this, (function (exports) { 'use strict';
    
    	// Polyfills
    
    	if ( Number.EPSILON === undefined ) {
    
    		Number.EPSILON = Math.pow( 2, - 52 );
    
    	}
    
    	//
    
    	if ( Math.sign === undefined ) {
    
    		// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
    
    		Math.sign = function ( x ) {
    
    			return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
    
    		};
    
    	}
    
    	if ( Function.prototype.name === undefined ) {
    
    		// Missing in IE9-11.
    		// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
    
    		Object.defineProperty( Function.prototype, 'name', {
    
    			get: function () {
    
    				return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ];
    
    			}
    
    		} );
    
    	}
    
    	if ( Object.assign === undefined ) {
    
    		// Missing in IE.
    		// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
    
    		( function () {
    
    			Object.assign = function ( target ) {
    
    				'use strict';
    
    				if ( target === undefined || target === null ) {
    
    					throw new TypeError( 'Cannot convert undefined or null to object' );
    
    				}
    
    				var output = Object( target );
    
    				for ( var index = 1; index < arguments.length; index ++ ) {
    
    					var source = arguments[ index ];
    
    					if ( source !== undefined && source !== null ) {
    
    						for ( var nextKey in source ) {
    
    							if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
    
    								output[ nextKey ] = source[ nextKey ];
    
    							}
    
    						}
    
    					}
    
    				}
    
    				return output;
    
    			};
    
    		} )();
    
    	}
    
    	/**
    	 * https://github.com/mrdoob/eventdispatcher.js/
    	 */
    
    	function EventDispatcher() {}
    
    	EventDispatcher.prototype = {
    
    		addEventListener: function ( type, listener ) {
    
    			if ( this._listeners === undefined ) this._listeners = {};
    
    			var listeners = this._listeners;
    
    			if ( listeners[ type ] === undefined ) {
    
    				listeners[ type ] = [];
    
    			}
    
    			if ( listeners[ type ].indexOf( listener ) === - 1 ) {
    
    				listeners[ type ].push( listener );
    
    			}
    
    		},
    
    		hasEventListener: function ( type, listener ) {
    
    			if ( this._listeners === undefined ) return false;
    
    			var listeners = this._listeners;
    
    			return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;
    
    		},
    
    		removeEventListener: function ( type, listener ) {
    
    			if ( this._listeners === undefined ) return;
    
    			var listeners = this._listeners;
    			var listenerArray = listeners[ type ];
    
    			if ( listenerArray !== undefined ) {
    
    				var index = listenerArray.indexOf( listener );
    
    				if ( index !== - 1 ) {
    
    					listenerArray.splice( index, 1 );
    
    				}
    
    			}
    
    		},
    
    		dispatchEvent: function ( event ) {
    
    			if ( this._listeners === undefined ) return;
    
    			var listeners = this._listeners;
    			var listenerArray = listeners[ event.type ];
    
    			if ( listenerArray !== undefined ) {
    
    				event.target = this;
    
    				var array = [], i = 0;
    				var length = listenerArray.length;
    
    				for ( i = 0; i < length; i ++ ) {
    
    					array[ i ] = listenerArray[ i ];
    
    				}
    
    				for ( i = 0; i < length; i ++ ) {
    
    					array[ i ].call( this, event );
    
    				}
    
    			}
    
    		}
    
    	};
    
    	var REVISION = '84';
    	var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
    	var CullFaceNone = 0;
    	var CullFaceBack = 1;
    	var CullFaceFront = 2;
    	var CullFaceFrontBack = 3;
    	var FrontFaceDirectionCW = 0;
    	var FrontFaceDirectionCCW = 1;
    	var BasicShadowMap = 0;
    	var PCFShadowMap = 1;
    	var PCFSoftShadowMap = 2;
    	var FrontSide = 0;
    	var BackSide = 1;
    	var DoubleSide = 2;
    	var FlatShading = 1;
    	var SmoothShading = 2;
    	var NoColors = 0;
    	var FaceColors = 1;
    	var VertexColors = 2;
    	var NoBlending = 0;
    	var NormalBlending = 1;
    	var AdditiveBlending = 2;
    	var SubtractiveBlending = 3;
    	var MultiplyBlending = 4;
    	var CustomBlending = 5;
    	var AddEquation = 100;
    	var SubtractEquation = 101;
    	var ReverseSubtractEquation = 102;
    	var MinEquation = 103;
    	var MaxEquation = 104;
    	var ZeroFactor = 200;
    	var OneFactor = 201;
    	var SrcColorFactor = 202;
    	var OneMinusSrcColorFactor = 203;
    	var SrcAlphaFactor = 204;
    	var OneMinusSrcAlphaFactor = 205;
    	var DstAlphaFactor = 206;
    	var OneMinusDstAlphaFactor = 207;
    	var DstColorFactor = 208;
    	var OneMinusDstColorFactor = 209;
    	var SrcAlphaSaturateFactor = 210;
    	var NeverDepth = 0;
    	var AlwaysDepth = 1;
    	var LessDepth = 2;
    	var LessEqualDepth = 3;
    	var EqualDepth = 4;
    	var GreaterEqualDepth = 5;
    	var GreaterDepth = 6;
    	var NotEqualDepth = 7;
    	var MultiplyOperation = 0;
    	var MixOperation = 1;
    	var AddOperation = 2;
    	var NoToneMapping = 0;
    	var LinearToneMapping = 1;
    	var ReinhardToneMapping = 2;
    	var Uncharted2ToneMapping = 3;
    	var CineonToneMapping = 4;
    	var UVMapping = 300;
    	var CubeReflectionMapping = 301;
    	var CubeRefractionMapping = 302;
    	var EquirectangularReflectionMapping = 303;
    	var EquirectangularRefractionMapping = 304;
    	var SphericalReflectionMapping = 305;
    	var CubeUVReflectionMapping = 306;
    	var CubeUVRefractionMapping = 307;
    	var RepeatWrapping = 1000;
    	var ClampToEdgeWrapping = 1001;
    	var MirroredRepeatWrapping = 1002;
    	var NearestFilter = 1003;
    	var NearestMipMapNearestFilter = 1004;
    	var NearestMipMapLinearFilter = 1005;
    	var LinearFilter = 1006;
    	var LinearMipMapNearestFilter = 1007;
    	var LinearMipMapLinearFilter = 1008;
    	var UnsignedByteType = 1009;
    	var ByteType = 1010;
    	var ShortType = 1011;
    	var UnsignedShortType = 1012;
    	var IntType = 1013;
    	var UnsignedIntType = 1014;
    	var FloatType = 1015;
    	var HalfFloatType = 1016;
    	var UnsignedShort4444Type = 1017;
    	var UnsignedShort5551Type = 1018;
    	var UnsignedShort565Type = 1019;
    	var UnsignedInt248Type = 1020;
    	var AlphaFormat = 1021;
    	var RGBFormat = 1022;
    	var RGBAFormat = 1023;
    	var LuminanceFormat = 1024;
    	var LuminanceAlphaFormat = 1025;
    	var RGBEFormat = RGBAFormat;
    	var DepthFormat = 1026;
    	var DepthStencilFormat = 1027;
    	var RGB_S3TC_DXT1_Format = 2001;
    	var RGBA_S3TC_DXT1_Format = 2002;
    	var RGBA_S3TC_DXT3_Format = 2003;
    	var RGBA_S3TC_DXT5_Format = 2004;
    	var RGB_PVRTC_4BPPV1_Format = 2100;
    	var RGB_PVRTC_2BPPV1_Format = 2101;
    	var RGBA_PVRTC_4BPPV1_Format = 2102;
    	var RGBA_PVRTC_2BPPV1_Format = 2103;
    	var RGB_ETC1_Format = 2151;
    	var LoopOnce = 2200;
    	var LoopRepeat = 2201;
    	var LoopPingPong = 2202;
    	var InterpolateDiscrete = 2300;
    	var InterpolateLinear = 2301;
    	var InterpolateSmooth = 2302;
    	var ZeroCurvatureEnding = 2400;
    	var ZeroSlopeEnding = 2401;
    	var WrapAroundEnding = 2402;
    	var TrianglesDrawMode = 0;
    	var TriangleStripDrawMode = 1;
    	var TriangleFanDrawMode = 2;
    	var LinearEncoding = 3000;
    	var sRGBEncoding = 3001;
    	var GammaEncoding = 3007;
    	var RGBEEncoding = 3002;
    	var LogLuvEncoding = 3003;
    	var RGBM7Encoding = 3004;
    	var RGBM16Encoding = 3005;
    	var RGBDEncoding = 3006;
    	var BasicDepthPacking = 3200;
    	var RGBADepthPacking = 3201;
    
    	/**
    	 * @author alteredq / http://alteredqualia.com/
    	 * @author mrdoob / http://mrdoob.com/
    	 */
    
    	var _Math = {
    
    		DEG2RAD: Math.PI / 180,
    		RAD2DEG: 180 / Math.PI,
    
    		generateUUID: function () {
    
    			// http://www.broofa.com/Tools/Math.uuid.htm
    
    			var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( '' );
    			var uuid = new Array( 36 );
    			var rnd = 0, r;
    
    			return function generateUUID() {
    
    				for ( var i = 0; i < 36; i ++ ) {
    
    					if ( i === 8 || i === 13 || i === 18 || i === 23 ) {
    
    						uuid[ i ] = '-';
    
    					} else if ( i === 14 ) {
    
    						uuid[ i ] = '4';
    
    					} else {
    
    						if ( rnd <= 0x02 ) rnd = 0x2000000 + ( Math.random() * 0x1000000 ) | 0;
    						r = rnd & 0xf;
    						rnd = rnd >> 4;
    						uuid[ i ] = chars[ ( i === 19 ) ? ( r & 0x3 ) | 0x8 : r ];
    
    					}
    
    				}
    
    				return uuid.join( '' );
    
    			};
    
    		}(),
    
    		clamp: function ( value, min, max ) {
    
    			return Math.max( min, Math.min( max, value ) );
    
    		},
    
    		// compute euclidian modulo of m % n
    		// https://en.wikipedia.org/wiki/Modulo_operation
    
    		euclideanModulo: function ( n, m ) {
    
    			return ( ( n % m ) + m ) % m;
    
    		},
    
    		// Linear mapping from range <a1, a2> to range <b1, b2>
    
    		mapLinear: function ( x, a1, a2, b1, b2 ) {
    
    			return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
    
    		},
    
    		// https://en.wikipedia.org/wiki/Linear_interpolation
    
    		lerp: function ( x, y, t ) {
    
    			return ( 1 - t ) * x + t * y;
    
    		},
    
    		// http://en.wikipedia.org/wiki/Smoothstep
    
    		smoothstep: function ( x, min, max ) {
    
    			if ( x <= min ) return 0;
    			if ( x >= max ) return 1;
    
    			x = ( x - min ) / ( max - min );
    
    			return x * x * ( 3 - 2 * x );
    
    		},
    
    		smootherstep: function ( x, min, max ) {
    
    			if ( x <= min ) return 0;
    			if ( x >= max ) return 1;
    
    			x = ( x - min ) / ( max - min );
    
    			return x * x * x * ( x * ( x * 6 - 15 ) + 10 );
    
    		},
    
    		// Random integer from <low, high> interval
    
    		randInt: function ( low, high ) {
    
    			return low + Math.floor( Math.random() * ( high - low + 1 ) );
    
    		},
    
    		// Random float from <low, high> interval
    
    		randFloat: function ( low, high ) {
    
    			return low + Math.random() * ( high - low );
    
    		},
    
    		// Random float from <-range/2, range/2> interval
    
    		randFloatSpread: function ( range ) {
    
    			return range * ( 0.5 - Math.random() );
    
    		},
    
    		degToRad: function ( degrees ) {
    
    			return degrees * _Math.DEG2RAD;
    
    		},
    
    		radToDeg: function ( radians ) {
    
    			return radians * _Math.RAD2DEG;
    
    		},
    
    		isPowerOfTwo: function ( value ) {
    
    			return ( value & ( value - 1 ) ) === 0 && value !== 0;
    
    		},
    
    		nearestPowerOfTwo: function ( value ) {
    
    			return Math.pow( 2, Math.round( Math.log( value ) / Math.LN2 ) );
    
    		},
    
    		nextPowerOfTwo: function ( value ) {
    
    			value --;
    			value |= value >> 1;
    			value |= value >> 2;
    			value |= value >> 4;
    			value |= value >> 8;
    			value |= value >> 16;
    			value ++;
    
    			return value;
    
    		}
    
    	};
    
    	/**
    	 * @author mrdoob / http://mrdoob.com/
    	 * @author philogb / http://blog.thejit.org/
    	 * @author egraether / http://egraether.com/
    	 * @author zz85 / http://www.lab4games.net/zz85/blog
    	 */
    
    	function Vector2( x, y ) {
    
    		this.x = x || 0;
    		this.y = y || 0;
    
    	}
    
    	Vector2.prototype = {
    
    		constructor: Vector2,
    
    		isVector2: true,
    
    		get width() {
    
    			return this.x;
    
    		},
    
    		set width( value ) {
    
    			this.x = value;
    
    		},
    
    		get height() {
    
    			return this.y;
    
    		},
    
    		set height( value ) {
    
    			this.y = value;
    
    		},
    
    		//
    
    		set: function ( x, y ) {
    
    			this.x = x;
    			this.y = y;
    
    			return this;
    
    		},
    
    		setScalar: function ( scalar ) {
    
    			this.x = scalar;
    			this.y = scalar;
    
    			return this;
    
    		},
    
    		setX: function ( x ) {
    
    			this.x = x;
    
    			return this;
    
    		},
    
    		setY: function ( y ) {
    
    			this.y = y;
    
    			return this;
    
    		},
    
    		setComponent: function ( index, value ) {
    
    			switch ( index ) {
    
    				case 0: this.x = value; break;
    				case 1: this.y = value; break;
    				default: throw new Error( 'index is out of range: ' + index );
    
    			}
    
    			return this;
    
    		},
    
    		getComponent: function ( index ) {
    
    			switch ( index ) {
    
    				case 0: return this.x;
    				case 1: return this.y;
    				default: throw new Error( 'index is out of range: ' + index );
    
    			}
    
    		},
    
    		clone: function () {
    
    			return new this.constructor( this.x, this.y );
    
    		},
    
    		copy: function ( v ) {
    
    			this.x = v.x;
    			this.y = v.y;
    
    			return this;
    
    		},
    
    		add: function ( v, w ) {
    
    			if ( w !== undefined ) {
    
    				console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
    				return this.addVectors( v, w );
    
    			}
    
    			this.x += v.x;
    			this.y += v.y;
    
    			return this;
    
    		},
    
    		addScalar: function ( s ) {
    
    			this.x += s;
    			this.y += s;
    
    			return this;
    
    		},
    
    		addVectors: function ( a, b ) {
    
    			this.x = a.x + b.x;
    			this.y = a.y + b.y;
    
    			return this;
    
    		},
    
    		addScaledVector: function ( v, s ) {
    
    			this.x += v.x * s;
    			this.y += v.y * s;
    
    			return this;
    
    		},
    
    		sub: function ( v, w ) {
    
    			if ( w !== undefined ) {
    
    				console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
    				return this.subVectors( v, w );
    
    			}
    
    			this.x -= v.x;
    			this.y -= v.y;
    
    			return this;
    
    		},
    
    		subScalar: function ( s ) {
    
    			this.x -= s;
    			this.y -= s;
    
    			return this;
    
    		},
    
    		subVectors: function ( a, b ) {
    
    			this.x = a.x - b.x;
    			this.y = a.y - b.y;
    
    			return this;
    
    		},
    
    		multiply: function ( v ) {
    
    			this.x *= v.x;
    			this.y *= v.y;
    
    			return this;
    
    		},
    
    		multiplyScalar: function ( scalar ) {
    
    			if ( isFinite( scalar ) ) {
    
    				this.x *= scalar;
    				this.y *= scalar;
    
    			} else {
    
    				this.x = 0;
    				this.y = 0;
    
    			}
    
    			return this;
    
    		},
    
    		divide: function ( v ) {
    
    			this.x /= v.x;
    			this.y /= v.y;
    
    			return this;
    
    		},
    
    		divideScalar: function ( scalar ) {
    
    			return this.multiplyScalar( 1 / scalar );
    
    		},
    
    		min: function ( v ) {
    
    			this.x = Math.min( this.x, v.x );
    			this.y = Math.min( this.y, v.y );
    
    			return this;
    
    		},
    
    		max: function ( v ) {
    
    			this.x = Math.max( this.x, v.x );
    			this.y = Math.max( this.y, v.y );
    
    			return this;
    
    		},
    
    		clamp: function ( min, max ) {
    
    			// This function assumes min < max, if this assumption isn't true it will not operate correctly
    
    			this.x = Math.max( min.x, Math.min( max.x, this.x ) );
    			this.y = Math.max( min.y, Math.min( max.y, this.y ) );
    
    			return this;
    
    		},
    
    		clampScalar: function () {
    
    			var min, max;
    
    			return function clampScalar( minVal, maxVal ) {
    
    				if ( min === undefined ) {
    
    					min = new Vector2();
    					max = new Vector2();
    
    				}
    
    				min.set( minVal, minVal );
    				max.set( maxVal, maxVal );
    
    				return this.clamp( min, max );
    
    			};
    
    		}(),
    
    		clampLength: function ( min, max ) {
    
    			var length = this.length();
    
    			return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
    
    		},
    
    		floor: function () {
    
    			this.x = Math.floor( this.x );
    			this.y = Math.floor( this.y );
    
    			return this;
    
    		},
    
    		ceil: function () {
    
    			this.x = Math.ceil( this.x );
    			this.y = Math.ceil( this.y );
    
    			return this;
    
    		},
    
    		round: function () {
    
    			this.x = Math.round( this.x );
    			this.y = Math.round( this.y );
    
    			return this;
    
    		},
    
    		roundToZero: function () {
    
    			this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
    			this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
    
    			return this;
    
    		},
    
    		negate: function () {
    
    			this.x = - this.x;
    			this.y = - this.y;
    
    			return this;
    
    		},
    
    		dot: function ( v ) {
    
    			return this.x * v.x + this.y * v.y;
    
    		},
    
    		lengthSq: function () {
    
    			return this.x * this.x + this.y * this.y;
    
    		},
    
    		length: function () {
    
    			return Math.sqrt( this.x * this.x + this.y * this.y );
    
    		},
    
    		lengthManhattan: function() {
    
    			return Math.abs( this.x ) + Math.abs( this.y );
    
    		},
    
    		normalize: function () {
    
    			return this.divideScalar( this.length() );
    
    		},
    
    		angle: function () {
    
    			// computes the angle in radians with respect to the positive x-axis
    
    			var angle = Math.atan2( this.y, this.x );
    
    			if ( angle < 0 ) angle += 2 * Math.PI;
    
    			return angle;
    
    		},
    
    		distanceTo: function ( v ) {
    
    			return Math.sqrt( this.distanceToSquared( v ) );
    
    		},
    
    		distanceToSquared: function ( v ) {
    
    			var dx = this.x - v.x, dy = this.y - v.y;
    			return dx * dx + dy * dy;
    
    		},
    
    		distanceToManhattan: function ( v ) {
    
    			return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );
    
    		},
    
    		setLength: function ( length ) {
    
    			return this.multiplyScalar( length / this.length() );
    
    		},
    
    		lerp: function ( v, alpha ) {
    
    			this.x += ( v.x - this.x ) * alpha;
    			this.y += ( v.y - this.y ) * alpha;
    
    			return this;
    
    		},
    
    		lerpVectors: function ( v1, v2, alpha ) {
    
    			return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
    
    		},
    
    		equals: function ( v ) {
    
    			return ( ( v.x === this.x ) && ( v.y === this.y ) );
    
    		},
    
    		fromArray: function ( array, offset ) {
    
    			if ( offset === undefined ) offset = 0;
    
    			this.x = array[ offset ];
    			this.y = array[ offset + 1 ];
    
    			return this;
    
    		},
    
    		toArray: function ( array, offset ) {
    
    			if ( array === undefined ) array = [];
    			if ( offset === undefined ) offset = 0;
    
    			array[ offset ] = this.x;
    			array[ offset + 1 ] = this.y;
    
    			return array;
    
    		},
    
    		fromBufferAttribute: function ( attribute, index, offset ) {
    
    			if ( offset !== undefined ) {
    
    				console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );
    
    			}
    
    			this.x = attribute.getX( index );
    			this.y = attribute.getY( index );
    
    			return this;
    
    		},
    
    		rotateAround: function ( center, angle ) {
    
    			var c = Math.cos( angle ), s = Math.sin( angle );
    
    			var x = this.x - center.x;
    			var y = this.y - center.y;
    
    			this.x = x * c - y * s + center.x;
    			this.y = x * s + y * c + center.y;
    
    			return this;
    
    		}
    
    	};
    
    	/**
    	 * @author mrdoob / http://mrdoob.com/
    	 * @author alteredq / http://alteredqualia.com/
    	 * @author szimek / https://github.com/szimek/
    	 */
    
    	var textureId = 0;
    
    	function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
    
    		Object.defineProperty( this, 'id', { value: textureId ++ } );
    
    		this.uuid = _Math.generateUUID();
    
    		this.name = '';
    
    		this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;
    		this.mipmaps = [];
    
    		this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;
    
    		this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;
    		this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;
    
    		this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
    		this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;
    
    		this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
    
    		this.format = format !== undefined ? format : RGBAFormat;
    		this.type = type !== undefined ? type : UnsignedByteType;
    
    		this.offset = new Vector2( 0, 0 );
    		this.repeat = new Vector2( 1, 1 );
    
    		this.generateMipmaps = true;
    		this.premultiplyAlpha = false;
    		this.flipY = true;
    		this.unpackAlignment = 4;	// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)