@@ -48,7 +48,8 @@ import {
48
48
SELECTION_BOUNDING_BOX ,
49
49
buildShape ,
50
50
computeExplodedState ,
51
- projectVector
51
+ projectVector ,
52
+ IMouseDrag
52
53
} from './helpers' ;
53
54
import { MainViewModel } from './mainviewmodel' ;
54
55
import { Spinner } from './spinner' ;
@@ -293,14 +294,12 @@ export class MainView extends React.Component<IProps, IStates> {
293
294
this . _controls . dampingFactor = 0.15 ;
294
295
295
296
this . _renderer . domElement . addEventListener ( 'mousedown' , e => {
296
- this . _startMousePosition . set ( e . clientX , e . clientY ) ;
297
+ this . _mouseDrag . start . set ( e . clientX , e . clientY ) ;
297
298
} ) ;
298
299
299
300
this . _renderer . domElement . addEventListener ( 'mouseup' , e => {
300
- this . _endMousePosition . set ( e . clientX , e . clientY ) ;
301
- const distance = this . _endMousePosition . distanceTo (
302
- this . _startMousePosition
303
- ) ;
301
+ this . _mouseDrag . end . set ( e . clientX , e . clientY ) ;
302
+ const distance = this . _mouseDrag . end . distanceTo ( this . _mouseDrag . start ) ;
304
303
305
304
if ( distance <= CLICK_THRESHOLD ) {
306
305
this . _onClick ( e ) ;
@@ -1713,8 +1712,10 @@ export class MainView extends React.Component<IProps, IStates> {
1713
1712
private _refLength : number | null = null ; // Length of bounding box of current object
1714
1713
private _sceneAxe : THREE . Object3D | null ; // Array of X, Y and Z axe
1715
1714
private _controls : OrbitControls ; // Camera controls
1716
- private _startMousePosition = new THREE . Vector2 ( ) ; // Start mouse position when dragging the camera controls
1717
- private _endMousePosition = new THREE . Vector2 ( ) ; // End mouse position when dragging the camera controls
1715
+ private _mouseDrag : IMouseDrag = {
1716
+ start : new THREE . Vector2 ( ) ,
1717
+ end : new THREE . Vector2 ( )
1718
+ } ; // Current mouse drag
1718
1719
private _clipPlaneTransformControls : TransformControls ; // Clip plane position/rotation controls
1719
1720
private _transformControls : TransformControls ; // Mesh position controls
1720
1721
private _pointer3D : IPointer | null = null ;
0 commit comments