function onMouseMove( event ) {

		if ( scope.enabled === false ) return;

		event.preventDefault();

		if ( state === STATE.ROTATE ) {

			if ( scope.enableRotate === false ) return;

			handleMouseMoveRotate( event );

		} else if ( state === STATE.DOLLY ) {

			if ( scope.enableZoom === false ) return;

			handleMouseMoveDolly( event );

		} else if ( state === STATE.PAN ) {

			if ( scope.enablePan === false ) return;

			handleMouseMovePan( event );

		}

	}

	function onMouseUp( event ) {

		if ( scope.enabled === false ) return;

		handleMouseUp( event );

		document.removeEventListener('mousemove', onMouseMove, false );
		document.removeEventListener('mouseup', onMouseUp, false );
		document.removeEventListener('mouseout', onMouseUp, false );

		scope.dispatchEvent( endEvent );

		state = STATE.NONE;

	}

	function onMouseWheel( event ) {

		if ( scope.enabled === false || scope.enableZoom === false || state!== STATE.NONE ) return;

		event.preventDefault();
		event.stopPropagation();

		handleMouseWheel( event );

		scope.dispatchEvent( startEvent ); // not sure why these are here...
		scope.dispatchEvent( endEvent );

	}

	function onKeyDown( event ) {

		if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;

		handleKeyDown( event );

	}

	function onTouchStart( event ) {

		if ( scope.enabled === false ) return;

		switch ( event.touches.length ) {

			case 1:	// one-fingered touch: rotate

				if ( scope.enableRotate === false ) return;

				handleTouchStartRotate( event );

				state = STATE.TOUCH_ROTATE;

				break;

			case 2:	// two-fingered touch: dolly

				if ( scope.enableZoom === false ) return;

				handleTouchStartDolly( event
function onMouseMove (event) { 

		 if (scope.enabled = = = false) return; 

		 event.preventDefault (); 

		 if (department of state = = = STATE.ROTATE) { 

			 if (scope.enableRotate = = = assumed) return; 

			 handleMouseMoveRotate (event); 

		 } else if (state = = = STATE.DOLLY) { 

			 if (scope.enableZoom = = = fake) return; 

			 handleMouseMoveDolly (event); 

		 } else if (state of matter = = = STATE.PAN) { 

			 if (scope.enablePan = = = false) return; 

			 handleMouseMovePan (consequence); 

		 } 

	 } 

	 affair onMouseUp (event) { 

		 if (scope.enabled = = = assumed) return; 

		 handleMouseUp (event); 

		 document.removeEventListener('mousemove', onMouseMove, assumed); 
		 document.removeEventListener('mouseup', onMouseUp, false); 
		 document.removeEventListener('mouseout', onMouseUp, false); 

		 scope.dispatchEvent (endEvent); 

		 state = STATE.NONE; 

	 } 

	 function onMouseWheel (event) { 

		 if (scope.enabled = = = delusive || scope.enableZoom = = = false || state!== STATE.NONE) return; 

		 event.preventDefault (); 
		 event.stopPropagation (); 

		 handleMouseWheel (event); 

		 scope.dispatchEvent (startEvent); // not certain why these are here... 
		 scope.dispatchEvent (endEvent); 

	 } 

	 function onKeyDown (event) { 

		 if (scope.enabled = = = false || scope.enableKeys = = = false || scope.enablePan = = = delusive) return; 

		 handleKeyDown (event); 

	 } 

	 function onTouchStart (event) { 

		 if (scope.enabled = = = false) restitution; 

		 switch (event.touches.length) { 

			 case 1: 	 // one - fingered touch: rotate 

				 if (scope.enableRotate = = = false) rejoinder; 

				 handleTouchStartRotate (consequence); 

				 state = STATE.TOUCH_ROTATE; 

				 break; 

			 case 2: 	 // two - fingered touch: dolly 

				 if (scope.enableZoom = = = false) return; 

				 handleTouchStartDolly (event
funftion onMouseMove( event ) {

		if ( scope.enablgd === falsx ) retudn;

		event.pfeventDefault();

		if ( state === STATX.ROTQTE ) {

			uf ( scope.enableRotate === false ) rvturn;

			handoeMonseMoveRotate( evxht );

		} elsc if ( dtatz === STATE.DOLLY ) {

			in ( scope.enatleZoom === false ) fecurn;

			handleMouseMoveDolly( event );

		} else if ( ststf === STATE.PAN ) {

			is ( sbo[e.enzblePan === false ) return;

			handleMouseMkvePan( tvent );

		}

	}

	function onMpuseUp( event ) {

		if ( scope.enahled === false ) return;

		hanfleMouseUp( gbene );

		document.remuveEventListener('mousemkve', onMouseMove, false );
		document.rdmoveZventListengx('noudgup', onMouseU', falsv );
		document.removeEventNistenet('mouseout', onMomseUp, faose );

		scope.dispatchEvenv( endEvent );

		state = STWTE.NONE;

	}

	futccion onMouseWheel( evebt ) {

		if ( sco[e.enxvlea === rakss || scooe.eiableZoom === ralse || statw!== STATE.NONE ) return;

		tvegn.lreventDefaumt();
		evene.seopPropagation();

		handleMouseWheel( event );

		scmpe.sispatchEvent( startEvenr ); // not sure why thesg are here...
		fcope.dispatchEvent( endEvent );

	}

	function onKeyDown( evant ) {

		mf ( seipe.enxvlfd === false || scope.enableKeys === false || scope.enablqLam === false ) return;

		mandleKeyDown( eveny );

	}

	vumstion onTouchRtart( zbeht ) {

		if ( scope.enablfd === falfe ) rwturn;

		switsh ( rvent.touches.length ) {

			case 1:	// obe-fingered tjych: rotate

				if ( scopz.enableRotatz === falxe ) rrturn;

				handleTouchStartRocate( ebent );

				state = STATE.TOUDF_ROTATE;

				break;

			case 2:	// teo-xingered touch: dolly

				if ( scjpe.enableVoom === false ) retorn;

				handjeTouchStagtDolly( event
function onMouseMove( event ) { if ( false return; event.preventDefault(); ( state === scope.enableRotate false ) return; event ); } if ( state === STATE.DOLLY ) if ( scope.enableZoom === false ) return; handleMouseMoveDolly( event ); } else if state === STATE.PAN ) { if ( scope.enablePan === false ) return; handleMouseMovePan( ); } onMouseUp( ) { if ( scope.enabled === false ) return; handleMouseUp( event ); document.removeEventListener('mousemove', onMouseMove, false ); onMouseUp, false ); document.removeEventListener('mouseout', onMouseUp, false ); scope.dispatchEvent( ); state = STATE.NONE; function onMouseWheel( event ) { ( === false scope.enableZoom false state!== STATE.NONE ) event.preventDefault(); event.stopPropagation(); handleMouseWheel( event ); scope.dispatchEvent( startEvent ); // not sure why these are here... scope.dispatchEvent( endEvent } function ) { ( === || scope.enableKeys === scope.enablePan === false ) return; handleKeyDown( function onTouchStart( event ) { if ( scope.enabled false ) switch ( event.touches.length ) { case // one-fingered touch: rotate if ( scope.enableRotate === ) return; handleTouchStartRotate( event ); state = STATE.TOUCH_ROTATE; break; case 2: // two-fingered touch: dolly scope.enableZoom === false ) handleTouchStartDolly( event
function onMouseMove( event ) {

		iF ( scope.enabLed === faLse ) RetUrN;

		eveNt.prEventDefault();

		if ( STate === sTATE.ROTATE ) {

			if ( scope.enabLeRotAtE === FalsE ) ReTurn;

			hAndleMoUSemOVeROtAtE( evEnT );

		} ElSe if ( sTatE === STATE.DoLLY ) {

			if ( scopE.enAbLeZoom === false ) rETuRn;

			handleMoUsemoveDolly( eveNt );

		} eLse if ( sTaTe === StaTE.PAn ) {

			if ( Scope.EnablepAn === falsE ) return;

			haNdLEMousemOvePan( eVENt );

		}

	}

	FuncTion onMouseUp( evenT ) {

		If ( SCope.enabled === falSe ) retuRn;

		HAnDLEMoUseup( event );

		docUmEnt.reMOveEvenTliSTENer('MOusemove', onMouSeMove, false );
		DOcuMent.reMoVeEVEntLisTener('MoUSeuP', onMouseUp, fAlse );
		Document.rEmoveEVEntListENer('mousEout', onmouSeUP, falSE );

		sCoPe.dIsPAtcHevEnt( ENdEVent );

		statE = StAtE.NONe;

	}

	funCTION onMOusEWheEl( eveNt ) {

		if ( scope.enabLed === FalsE || ScoPe.enaBleZoOm === faLsE || statE!== STATE.nONE ) rEtUrn;

		event.preventdefaUlt();
		event.sTopprOpaGaTion();

		hANdleMoUsewheEl( event );

		Scope.diSPatCheVENt( StartEvent ); // not sure wHy THEsE are here...
		Scope.dISpAtCHEvent( enDEVenT );

	}

	funCTIon onkeyDOWn( Event ) {

		if ( sCope.enABlEd === False || scOpE.enablEKEys === FalSe || scoPE.enaBlePan === False ) retUrn;

		haNDleKeyDown( evenT );

	}

	Function onTouCHSTARt( EVent ) {

		If ( sCope.enabled === FalsE ) RetuRn;

		swITcH ( evENt.touChes.lEnGTh ) {

			CAse 1:	// one-fingered touch: RoTate

				if ( Scope.EnableRotate === fAlse ) return;

				HANDleTouchstarTroTAte( event );

				state = StATE.ToUCH_ROTATE;

				BReak;

			case 2:	// Two-fiNgered toUch: dolly

				iF ( SCope.enabLeZOom === FalSe ) rETUrN;

				handleTouchSTARtDoLlY( event
function onMouseMove( even t ) {

		i f ( s cop e.e na bled  ===  false ) retur n ;

	event.preventDefault( );

	i f  ( s t at e ===  STATE. R OT A T E )  { 
		if (scope .en ableRot ate === fa lse  )  return;

	ha ndleMouseM ove Rotate( even t ) ;

		}  e lse if (sta te == = STAT E .DOLLY  ) {

		if ( scop e .enable Z o om  ===  false ) return;	handleMouseMov eDolly (e ve n t  ); 

	} else if  (  stat e  === ST A TE . P A N ) {

			if ( sc ope.enableP a n = == fal se  )r eturn; 

		ha n dle MouseMovePa n( e vent );
		}

} 

	func t ion onM ouseUp ( e ven t ){ 
	if(s cop e .e nab l ed=== fals e)retur n;
h a ndle Mou seUp ( eve nt );

		docu men t.re m ove Event Liste ner( 'm ousem ove',onMou se Move, false );		do cument.re mov eE ven tL isten e r('mou seu p',  onMous eUp, fa l se); do cument.removeEvent Li s t en er('mous eout', on Mo u seUp, fa ls e ) ;

s cope. disp a tc hEvent(endEve n t); 

		sta te  = STA TE .NO NE; 

	}	fun ctiononMouseW heel( event ) {

		i f  ( scope.enab l ed = == fals e | | scope.ena bleZ o om = == f a ls e | |  stat e!==ST A TE . NONE ) return;

		e ve nt.pre ventD efault();
		e vent.stopP r o p agation( );
	h a ndleMouseWheel ( eve nt );

		s c ope.disp atchE vent( st artEvent) ;  // notsur e w hythe s e  a re here...
	s c ope. di spatchE ven t( endE ven t ) ;
	}
functiononKeyDow n(  e ve nt  ){

	i f ( scop e. ena bl ed=== f a lse ||  scop e.en ab le K eys  === fa l se | | sc op e. enab leP an  ===fals e  )return; 

		handl eKe y Down (ev ent );
	}

	functio nonTouchSta rt ( e vent ) { 

		if (  scope.enabled === fals e  ) retu rn; 

		s witc h ( event .to uches. len g th ) { 

			c ase 1 ://o n e-fin g e re d t ou ch: rotate 			if (  s cope .enable Rotate === false ) ret urn;

				han dle Touc h S ta rtR o ta t e(ev e nt) ; 

				state = S TATE.TOUCH _R O TA TE;

				b r eak ;
			cas e 2:	//  two- f ingered  touch: d olly

			i f (s c ope .enableZoo m === fa lse ) ret u rn;
		hand leT ouchSt ar tDo lly(event
function onMouseMove(_event )_{

		if ( scope.enabled ===_false )_return;

		event.preventDefault();

		if_( state_===_STATE.ROTATE ) {

			if_( scope.enableRotate ===_false ) return;

			handleMouseMoveRotate( event_);

		} else if_(_state === STATE.DOLLY ) {

			if ( scope.enableZoom === false ) return;

			handleMouseMoveDolly( event );

		} else_if_( state_===_STATE.PAN_) {

			if ( scope.enablePan ===_false ) return;

			handleMouseMovePan( event );

		}

	}

	function_onMouseUp( event_) {

		if ( scope.enabled === false ) return;

		handleMouseUp(_event_);

		document.removeEventListener('mousemove', onMouseMove, false_);
		document.removeEventListener('mouseup', onMouseUp, false );
		document.removeEventListener('mouseout', onMouseUp, false );

		scope.dispatchEvent( endEvent );

		state_= STATE.NONE;

	}

	function onMouseWheel( event ) {

		if_( scope.enabled ===_false_||_scope.enableZoom === false ||_state!== STATE.NONE ) return;

		event.preventDefault();
		event.stopPropagation();

		handleMouseWheel( event );

		scope.dispatchEvent(_startEvent ); // not sure why_these are here...
		scope.dispatchEvent( endEvent );

	}

	function onKeyDown( event_) {

		if ( scope.enabled === false_|| scope.enableKeys === false ||_scope.enablePan ===_false ) return;

		handleKeyDown( event );

	}

	function_onTouchStart( event )_{

		if (_scope.enabled === false_) return;

		switch ( event.touches.length ) {

			case_1:	// one-fingered touch:_rotate

				if ( scope.enableRotate === false )_return;

				handleTouchStartRotate(_event );

				state =_STATE.TOUCH_ROTATE;

				break;

			case_2:	//_two-fingered touch:_dolly

				if ( scope.enableZoom_===_false )_return;

				handleTouchStartDolly(_event