@@ -266,7 +266,11 @@ export class MainView extends React.Component<IProps, IStates> {
266
266
this . _onPointerMove . bind ( this )
267
267
) ;
268
268
this . _renderer . domElement . addEventListener ( 'mouseup' , e => {
269
- this . _onClick . bind ( this ) ( e ) ;
269
+ if ( ! this . _disabledNextClick ) {
270
+ this . _onClick ( e ) ;
271
+ }
272
+
273
+ this . _disabledNextClick = false ;
270
274
} ) ;
271
275
272
276
this . _renderer . domElement . addEventListener ( 'contextmenu' , e => {
@@ -276,24 +280,35 @@ export class MainView extends React.Component<IProps, IStates> {
276
280
} ) ;
277
281
278
282
document . addEventListener ( 'keydown' , e => {
279
- this . _onKeyDown . bind ( this ) ( e ) ;
283
+ this . _onKeyDown ( e ) ;
280
284
} ) ;
281
285
282
- const controls = new OrbitControls (
286
+ this . _controls = new OrbitControls (
283
287
this . _camera ,
284
288
this . _renderer . domElement
285
289
) ;
286
290
287
- controls . target . set (
291
+ this . _controls . target . set (
288
292
this . _scene . position . x ,
289
293
this . _scene . position . y ,
290
294
this . _scene . position . z
291
295
) ;
292
- this . _controls = controls ;
293
- controls . enableDamping = true ;
294
- controls . dampingFactor = 0.15 ;
296
+ this . _controls . enableDamping = true ;
297
+ this . _controls . dampingFactor = 0.15 ;
295
298
299
+ this . _controls . addEventListener ( 'start' , ( ) => {
300
+ this . _hasOrbited = false ;
301
+ } ) ;
302
+ this . _controls . addEventListener ( 'end' , ( ) => {
303
+ // This "change" event here happens before the "mouseup" event on the renderer,
304
+ // we need to disable that next "mouseup" event that's coming to not deselect
305
+ // any currently selected mesh un-intentionally
306
+ if ( this . _hasOrbited ) {
307
+ this . _disabledNextClick = true ;
308
+ }
309
+ } ) ;
296
310
this . _controls . addEventListener ( 'change' , ( ) => {
311
+ this . _hasOrbited = true ;
297
312
this . _updateAnnotation ( ) ;
298
313
} ) ;
299
314
this . _controls . addEventListener (
@@ -644,6 +659,9 @@ export class MainView extends React.Component<IProps, IStates> {
644
659
}
645
660
this . _updateSelected ( newSelection ) ;
646
661
this . _model . syncSelected ( newSelection , this . _mainViewModel . id ) ;
662
+ } else {
663
+ this . _updateSelected ( { } ) ;
664
+ this . _model . syncSelected ( { } , this . _mainViewModel . id ) ;
647
665
}
648
666
}
649
667
@@ -1575,6 +1593,8 @@ export class MainView extends React.Component<IProps, IStates> {
1575
1593
private _refLength : number | null = null ; // Length of bounding box of current object
1576
1594
private _sceneAxe : THREE . Object3D | null ; // Array of X, Y and Z axe
1577
1595
private _controls : OrbitControls ; // Mouse controls
1596
+ private _hasOrbited = false ; // Whether the last orbit control run has actually orbited
1597
+ private _disabledNextClick = false ; // We set this when we stop orbiting, to prevent the next click event
1578
1598
private _transformControls : TransformControls ; // Mesh position/rotation controls
1579
1599
private _pointer3D : IPointer | null = null ;
1580
1600
private _clock : THREE . Clock ;
0 commit comments