Skip to content

Commit

Permalink
OrbitControls: Removed isMouseDown logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Aug 30, 2020
1 parent 2b477f0 commit f7455b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
17 changes: 7 additions & 10 deletions examples/js/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,6 @@ THREE.OrbitControls = function ( object, domElement ) {

}

var isMouseDown = false;

function onMouseDown( event ) {

// Prevent the browser from scrolling.
Expand Down Expand Up @@ -915,7 +913,8 @@ THREE.OrbitControls = function ( object, domElement ) {

if ( state !== STATE.NONE ) {

isMouseDown = true;
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp, false );

scope.dispatchEvent( startEvent );

Expand All @@ -925,7 +924,7 @@ THREE.OrbitControls = function ( object, domElement ) {

function onMouseMove( event ) {

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

event.preventDefault();

Expand Down Expand Up @@ -961,16 +960,17 @@ THREE.OrbitControls = function ( object, domElement ) {

function onMouseUp( event ) {

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

handleMouseUp( event );

scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp, false );

scope.dispatchEvent( endEvent );

state = STATE.NONE;

isMouseDown = false;

}

function onMouseWheel( event ) {
Expand Down Expand Up @@ -1170,9 +1170,6 @@ THREE.OrbitControls = function ( object, domElement ) {
scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
scope.domElement.addEventListener( 'touchmove', onTouchMove, false );

scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp, false );

scope.domElement.addEventListener( 'keydown', onKeyDown, false );

// make sure element can receive keys.
Expand Down
17 changes: 7 additions & 10 deletions examples/jsm/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,6 @@ var OrbitControls = function ( object, domElement ) {

}

var isMouseDown = false;

function onMouseDown( event ) {

// Prevent the browser from scrolling.
Expand Down Expand Up @@ -923,7 +921,8 @@ var OrbitControls = function ( object, domElement ) {

if ( state !== STATE.NONE ) {

isMouseDown = true;
scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp, false );

scope.dispatchEvent( startEvent );

Expand All @@ -933,7 +932,7 @@ var OrbitControls = function ( object, domElement ) {

function onMouseMove( event ) {

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

event.preventDefault();

Expand Down Expand Up @@ -969,16 +968,17 @@ var OrbitControls = function ( object, domElement ) {

function onMouseUp( event ) {

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

handleMouseUp( event );

scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp, false );

scope.dispatchEvent( endEvent );

state = STATE.NONE;

isMouseDown = false;

}

function onMouseWheel( event ) {
Expand Down Expand Up @@ -1178,9 +1178,6 @@ var OrbitControls = function ( object, domElement ) {
scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
scope.domElement.addEventListener( 'touchmove', onTouchMove, false );

scope.domElement.ownerDocument.addEventListener( 'pointermove', onPointerMove, false );
scope.domElement.ownerDocument.addEventListener( 'pointerup', onPointerUp, false );

scope.domElement.addEventListener( 'keydown', onKeyDown, false );

// make sure element can receive keys.
Expand Down

0 comments on commit f7455b8

Please sign in to comment.