@@ -174,7 +174,7 @@ class GlobeControls extends THREE.EventDispatcher {
174
174
this . camera = view . camera . camera3D ;
175
175
176
176
// State control
177
- this . states = new StateControl ( ) ;
177
+ this . states = new StateControl ( this . view ) ;
178
178
this . state = this . states . NONE ;
179
179
180
180
// Set to false to disable this control
@@ -242,7 +242,7 @@ class GlobeControls extends THREE.EventDispatcher {
242
242
this . _onMouseDown = this . onMouseDown . bind ( this ) ;
243
243
this . _onMouseWheel = this . onMouseWheel . bind ( this ) ;
244
244
this . _onContextMenuListener = this . onContextMenuListener . bind ( this ) ;
245
- this . _ondblclick = this . ondblclick . bind ( this ) ;
245
+ this . _onTravel = this . travel . bind ( this ) ;
246
246
this . _onTouchStart = this . onTouchStart . bind ( this ) ;
247
247
this . _update = this . update . bind ( this ) ;
248
248
this . _onTouchMove = this . onTouchMove . bind ( this ) ;
@@ -253,12 +253,13 @@ class GlobeControls extends THREE.EventDispatcher {
253
253
this . view . domElement . addEventListener ( 'contextmenu' , this . _onContextMenuListener , false ) ;
254
254
this . view . domElement . addEventListener ( 'mousedown' , this . _onMouseDown , false ) ;
255
255
this . view . domElement . addEventListener ( 'mousewheel' , this . _onMouseWheel , false ) ;
256
- this . view . domElement . addEventListener ( 'dblclick' , this . _ondblclick , false ) ;
257
256
this . view . domElement . addEventListener ( 'DOMMouseScroll' , this . _onMouseWheel , false ) ; // firefox
258
257
this . view . domElement . addEventListener ( 'touchstart' , this . _onTouchStart , false ) ;
259
258
this . view . domElement . addEventListener ( 'touchend' , this . _onMouseUp , false ) ;
260
259
this . view . domElement . addEventListener ( 'touchmove' , this . _onTouchMove , false ) ;
261
260
261
+ this . states . addEventListener ( 'travel_in' , this . _onTravel , false ) ;
262
+
262
263
// refresh control for each animation's frame
263
264
this . player . addEventListener ( 'animation-frame' , this . _update ) ;
264
265
@@ -675,10 +676,10 @@ class GlobeControls extends THREE.EventDispatcher {
675
676
}
676
677
}
677
678
678
- ondblclick ( event ) {
679
- if ( this . enabled === false || currentKey ) { return ; }
679
+ travel ( event ) {
680
+ if ( this . enabled === false ) { return ; }
680
681
this . player . stop ( ) ;
681
- const point = this . view . getPickingPositionFromDepth ( this . view . eventToViewCoords ( event ) ) ;
682
+ const point = this . view . getPickingPositionFromDepth ( event . viewCoords ) ;
682
683
const range = this . getRange ( point ) ;
683
684
if ( point && range > this . minDistance ) {
684
685
return this . lookAtCoordinate ( {
@@ -910,12 +911,14 @@ class GlobeControls extends THREE.EventDispatcher {
910
911
this . view . domElement . removeEventListener ( 'DOMMouseScroll' , this . _onMouseWheel , false ) ; // firefox
911
912
this . view . domElement . removeEventListener ( 'mouseup' , this . _onMouseUp , false ) ;
912
913
this . view . domElement . removeEventListener ( 'mouseleave' , this . _onMouseUp , false ) ;
913
- this . view . domElement . removeEventListener ( 'dblclick' , this . _ondblclick , false ) ;
914
914
915
915
this . view . domElement . removeEventListener ( 'touchstart' , this . _onTouchStart , false ) ;
916
916
this . view . domElement . removeEventListener ( 'touchend' , this . _onMouseUp , false ) ;
917
917
this . view . domElement . removeEventListener ( 'touchmove' , this . _onTouchMove , false ) ;
918
918
919
+ this . states . dispose ( ) ;
920
+ this . states . removeEventListener ( 'travel_in' , this . _onTravel , false ) ;
921
+
919
922
this . player . removeEventListener ( 'animation-frame' , this . _onKeyUp ) ;
920
923
921
924
window . removeEventListener ( 'keydown' , this . _onKeyDown , false ) ;
0 commit comments