|
@@ -44,7 +44,7 @@ THREE.TrackballControls = function ( object, domElement ) {
|
|
|
var lastPosition = new THREE.Vector3();
|
|
|
|
|
|
var _state = STATE.NONE,
|
|
|
- _prevState = STATE.NONE,
|
|
|
+ _keyState = STATE.NONE,
|
|
|
|
|
|
_eye = new THREE.Vector3(),
|
|
|
|
|
@@ -324,7 +324,7 @@ THREE.TrackballControls = function ( object, domElement ) {
|
|
|
this.reset = function () {
|
|
|
|
|
|
_state = STATE.NONE;
|
|
|
- _prevState = STATE.NONE;
|
|
|
+ _keyState = STATE.NONE;
|
|
|
|
|
|
_this.target.copy( _this.target0 );
|
|
|
_this.object.position.copy( _this.position0 );
|
|
@@ -348,33 +348,31 @@ THREE.TrackballControls = function ( object, domElement ) {
|
|
|
|
|
|
window.removeEventListener( 'keydown', keydown );
|
|
|
|
|
|
- _prevState = _state;
|
|
|
-
|
|
|
- if ( _state !== STATE.NONE ) {
|
|
|
+ if ( _keyState !== STATE.NONE ) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
|
|
|
|
|
|
- _state = STATE.ROTATE;
|
|
|
+ _keyState = STATE.ROTATE;
|
|
|
|
|
|
} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
|
|
|
|
|
|
- _state = STATE.ZOOM;
|
|
|
+ _keyState = STATE.ZOOM;
|
|
|
|
|
|
} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
|
|
|
|
|
|
- _state = STATE.PAN;
|
|
|
+ _keyState = STATE.PAN;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- function keyup( event ) {
|
|
|
+ function keyup() {
|
|
|
|
|
|
if ( _this.enabled === false ) return;
|
|
|
|
|
|
- _state = _prevState;
|
|
|
+ _keyState = STATE.NONE;
|
|
|
|
|
|
window.addEventListener( 'keydown', keydown, false );
|
|
|
|
|
@@ -393,17 +391,19 @@ THREE.TrackballControls = function ( object, domElement ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
|
|
+ var state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
|
|
+
|
|
|
+ if ( state === STATE.ROTATE && ! _this.noRotate ) {
|
|
|
|
|
|
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
|
_movePrev.copy( _moveCurr );
|
|
|
|
|
|
- } else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
|
|
+ } else if ( state === STATE.ZOOM && ! _this.noZoom ) {
|
|
|
|
|
|
_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
|
_zoomEnd.copy( _zoomStart );
|
|
|
|
|
|
- } else if ( _state === STATE.PAN && ! _this.noPan ) {
|
|
|
+ } else if ( state === STATE.PAN && ! _this.noPan ) {
|
|
|
|
|
|
_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
|
_panEnd.copy( _panStart );
|
|
@@ -424,16 +424,18 @@ THREE.TrackballControls = function ( object, domElement ) {
|
|
|
event.preventDefault();
|
|
|
event.stopPropagation();
|
|
|
|
|
|
- if ( _state === STATE.ROTATE && ! _this.noRotate ) {
|
|
|
+ var state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
|
|
|
+
|
|
|
+ if ( state === STATE.ROTATE && ! _this.noRotate ) {
|
|
|
|
|
|
_movePrev.copy( _moveCurr );
|
|
|
_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
|
|
|
|
|
|
- } else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
|
|
|
+ } else if ( state === STATE.ZOOM && ! _this.noZoom ) {
|
|
|
|
|
|
_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
|
|
|
|
- } else if ( _state === STATE.PAN && ! _this.noPan ) {
|
|
|
+ } else if ( state === STATE.PAN && ! _this.noPan ) {
|
|
|
|
|
|
_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
|
|
|
|