未验证 提交 aed5e2e8 编写于 作者: M Michael Herzog 提交者: GitHub

Merge pull request #16997 from Mugen87/dev34

TrackballControls: Fix key states.
......@@ -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 ) );
......
......@@ -51,7 +51,7 @@ var TrackballControls = function ( object, domElement ) {
var lastPosition = new Vector3();
var _state = STATE.NONE,
_prevState = STATE.NONE,
_keyState = STATE.NONE,
_eye = new Vector3(),
......@@ -331,7 +331,7 @@ var 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 );
......@@ -355,33 +355,31 @@ var 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 );
......@@ -400,17 +398,19 @@ var 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 );
......@@ -431,16 +431,18 @@ var 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 ) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册