@@ -4,7 +4,7 @@ import mitt, { Emitter } from 'mitt'
4
4
5
5
import { Keys , keyState } from './keys'
6
6
import { EcsEntity } from './EcsEntity'
7
- import { RIGHT_BUTTON } from './mouse-utils'
7
+ import { LEFT_BUTTON , RIGHT_BUTTON } from './mouse-utils'
8
8
import { fitSphereIntoCameraFrustum } from '../../logic/math'
9
9
import { PARCEL_SIZE } from '../../utils/scene'
10
10
@@ -140,7 +140,7 @@ export class CameraManager {
140
140
const mouseInput = camera . inputs . attached . mouse as BABYLON . FreeCameraMouseInput
141
141
camera . target = center
142
142
143
- mouseInput . buttons = [ RIGHT_BUTTON ] // disable all buttons except right mouse button
143
+ mouseInput . buttons = [ RIGHT_BUTTON ] // disable all mouse buttons to move camera except for right mouse button
144
144
145
145
camera . inertia = 0
146
146
camera . speed = this . speeds [ this . speedIndex ]
@@ -163,18 +163,30 @@ export class CameraManager {
163
163
return false
164
164
}
165
165
166
- let holdingMouseButton = false
166
+ scene . onPreKeyboardObservable . add ( ( ev ) => {
167
+ const isAltKeyDown = ev . type === BABYLON . KeyboardEventTypes . KEYDOWN && ev . event . inputIndex === Keys . KEY_ALT
168
+
169
+ if ( isAltKeyDown ) {
170
+ mouseInput . buttons = [ LEFT_BUTTON , RIGHT_BUTTON ] // move camera with left/right mouse buttons
171
+ } else {
172
+ mouseInput . buttons = [ RIGHT_BUTTON ] // move camera with right mouse button
173
+ // reattach control to avoid camera sticking to the pointer bug...
174
+ this . reattachControl ( )
175
+ }
176
+ } )
177
+
178
+ let holdingRightMouseButton = false
167
179
scene . onPointerObservable . add ( ( ev ) => {
168
180
if ( ev . type === BABYLON . PointerEventTypes . POINTERDOWN && ev . event . button === RIGHT_BUTTON ) {
169
- holdingMouseButton = true
181
+ holdingRightMouseButton = true
170
182
}
171
183
if ( ev . type === BABYLON . PointerEventTypes . POINTERUP && ev . event . button === RIGHT_BUTTON ) {
172
- holdingMouseButton = false
184
+ holdingRightMouseButton = false
173
185
}
174
186
if ( ev . type === BABYLON . PointerEventTypes . POINTERWHEEL ) {
175
187
const browserEvent = ev . event as BABYLON . IWheelEvent
176
188
177
- if ( holdingMouseButton || isCameraMoving ( ) ) {
189
+ if ( holdingRightMouseButton || isCameraMoving ( ) ) {
178
190
if ( browserEvent . deltaY < 0 ) this . changeSpeed ( SpeedIncrement . FASTER )
179
191
else if ( browserEvent . deltaY > 0 ) this . changeSpeed ( SpeedIncrement . SLOWER )
180
192
} else {
0 commit comments