Просмотр исходного кода

fix DragControls events when buttons are disabled (#31612)

Co-authored-by: user <merowinger>
Adrian Hänsler 8 месяцев назад
Родитель
Сommit
07987ea5f0
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      examples/jsm/controls/DragControls.js

+ 6 - 6
examples/jsm/controls/DragControls.js

@@ -305,6 +305,7 @@ function onPointerMove( event ) {
 			if ( raycaster.ray.intersectPlane( _plane, _intersection ) ) {
 
 				_selected.position.copy( _intersection.sub( _offset ).applyMatrix4( _inverseMatrix ) );
+				this.dispatchEvent( { type: 'drag', object: _selected } );
 
 			}
 
@@ -313,11 +314,10 @@ function onPointerMove( event ) {
 			_diff.subVectors( _pointer, _previousPointer ).multiplyScalar( this.rotateSpeed );
 			_selected.rotateOnWorldAxis( _up, _diff.x );
 			_selected.rotateOnWorldAxis( _right.normalize(), - _diff.y );
+			this.dispatchEvent( { type: 'drag', object: _selected } );
 
 		}
 
-		this.dispatchEvent( { type: 'drag', object: _selected } );
-
 		_previousPointer.copy( _pointer );
 
 	} else {
@@ -414,21 +414,21 @@ function onPointerDown( event ) {
 
 				_inverseMatrix.copy( _selected.parent.matrixWorld ).invert();
 				_offset.copy( _intersection ).sub( _worldPosition.setFromMatrixPosition( _selected.matrixWorld ) );
+				domElement.style.cursor = 'move';
+				this.dispatchEvent( { type: 'dragstart', object: _selected } );
 
 			} else if ( this.state === STATE.ROTATE ) {
 
 				// the controls only support Y+ up
 				_up.set( 0, 1, 0 ).applyQuaternion( camera.quaternion ).normalize();
 				_right.set( 1, 0, 0 ).applyQuaternion( camera.quaternion ).normalize();
+				domElement.style.cursor = 'move';
+				this.dispatchEvent( { type: 'dragstart', object: _selected } );
 
 			}
 
 		}
 
-		domElement.style.cursor = 'move';
-
-		this.dispatchEvent( { type: 'dragstart', object: _selected } );
-
 	}
 
 	_previousPointer.copy( _pointer );

粤ICP备19079148号