@@ -192,13 +192,12 @@ export class EnvironmentControls extends EventDispatcher {
192192 */
193193 this . useFallbackPlane = true ;
194194
195- // settings for GlobeControls
196- this . scaleZoomOrientationAtEdges = false ;
197- this . autoAdjustCameraRotation = true ;
198-
199195 // flight
200196 /**
201- * When true, WASD/QE keys move the camera freely through space. Default is false.
197+ * When true, enables keyboard flight: W/A/S/D and arrow keys move forward/back/strafe, Q/E move
198+ * up/down, and Shift multiplies speed by `flightSpeedMultiplier`. Right-click or Shift+left-click
199+ * enters free-look mode, rotating the camera in place without requiring a surface hit. Only
200+ * supported for perspective cameras. Default is false.
202201 * @type {boolean }
203202 */
204203 this . enableFlight = false ;
@@ -215,7 +214,10 @@ export class EnvironmentControls extends EventDispatcher {
215214 */
216215 this . flightSpeedMultiplier = 4 ;
217216
218- this . _keysDown = new Set ( ) ;
217+
218+ // settings for GlobeControls
219+ this . scaleZoomOrientationAtEdges = false ;
220+ this . autoAdjustCameraRotation = true ;
219221
220222 // internal state
221223 this . state = NONE ;
@@ -252,6 +254,8 @@ export class EnvironmentControls extends EventDispatcher {
252254 this . up = new Vector3 ( 0 , 1 , 0 ) ;
253255 this . _lastTime = performance . now ( ) ;
254256
257+ this . _keysDown = new Set ( ) ;
258+
255259 this . _detachCallback = null ;
256260 this . _upInitialized = false ;
257261 this . _lastUsedState = NONE ;
@@ -370,6 +374,8 @@ export class EnvironmentControls extends EventDispatcher {
370374 scene,
371375 pivotPoint,
372376 enabled,
377+ enableFlight,
378+ _keysDown,
373379 } = this ;
374380
375381 // init the pointer
@@ -411,12 +417,25 @@ export class EnvironmentControls extends EventDispatcher {
411417
412418 }
413419
414- // flight mode with shift held: free-look around the camera origin, skip raycasting
420+ // free-look around the camera origin when flight is active with any flight key held, or shift/right-click
421+ const anyFlightKey =
422+ _keysDown . has ( 'w' ) ||
423+ _keysDown . has ( 's' ) ||
424+ _keysDown . has ( 'a' ) ||
425+ _keysDown . has ( 'd' ) ||
426+ _keysDown . has ( 'q' ) ||
427+ _keysDown . has ( 'e' ) ||
428+ _keysDown . has ( 'arrowup' ) ||
429+ _keysDown . has ( 'arrowdown' ) ||
430+ _keysDown . has ( 'arrowleft' ) ||
431+ _keysDown . has ( 'arrowright' ) ||
432+ _keysDown . has ( 'shift' ) ;
433+
415434 if (
416- this . enableFlight &&
435+ enableFlight && anyFlightKey &&
417436 ! pointerTracker . isPointerTouch ( ) && (
418437 pointerTracker . isRightClicked ( ) ||
419- pointerTracker . isLeftClicked ( ) && e . shiftKey
438+ pointerTracker . isLeftClicked ( )
420439 )
421440 ) {
422441
@@ -661,7 +680,28 @@ export class EnvironmentControls extends EventDispatcher {
661680
662681 const keydownCallback = e => {
663682
664- this . _keysDown . add ( e . key . toLowerCase ( ) ) ;
683+ const { _keysDown, state } = this ;
684+
685+ _keysDown . add ( e . key . toLowerCase ( ) ) ;
686+
687+ const anyFlightKey =
688+ _keysDown . has ( 'w' ) ||
689+ _keysDown . has ( 's' ) ||
690+ _keysDown . has ( 'a' ) ||
691+ _keysDown . has ( 'd' ) ||
692+ _keysDown . has ( 'q' ) ||
693+ _keysDown . has ( 'e' ) ||
694+ _keysDown . has ( 'arrowup' ) ||
695+ _keysDown . has ( 'arrowdown' ) ||
696+ _keysDown . has ( 'arrowleft' ) ||
697+ _keysDown . has ( 'arrowright' ) ;
698+
699+ if ( anyFlightKey && state !== FREE_ROTATE ) {
700+
701+ this . resetState ( ) ;
702+
703+ }
704+
665705
666706 } ;
667707
@@ -1129,6 +1169,12 @@ export class EnvironmentControls extends EventDispatcher {
11291169
11301170 }
11311171
1172+ _getFlightSpeedScale ( ) {
1173+
1174+ return 1 ;
1175+
1176+ }
1177+
11321178 _updateFlight ( deltaTime ) {
11331179
11341180 const {
@@ -1139,7 +1185,7 @@ export class EnvironmentControls extends EventDispatcher {
11391185 _keysDown,
11401186 } = this ;
11411187
1142- if ( ! enableFlight ) {
1188+ if ( ! enableFlight || camera . isOrthographicCamera ) {
11431189
11441190 return false ;
11451191
@@ -1155,7 +1201,7 @@ export class EnvironmentControls extends EventDispatcher {
11551201
11561202 // calculate speed
11571203 const mult = _keysDown . has ( 'shift' ) ? flightSpeedMultiplier : 1 ;
1158- const speed = mult * flightSpeed * deltaTime ;
1204+ const speed = mult * flightSpeed * this . _getFlightSpeedScale ( ) * deltaTime ;
11591205
11601206 // calculate direction
11611207 _flightDir . set (
0 commit comments