@@ -210,24 +210,45 @@ ControllerCamera.mousewheel = (event: WheelEvent) => {
210210 // console.log(vector.toString());
211211 // // return false;
212212 // }
213-
214- // 滚轮纵向滚动是缩放
215- if ( event . deltaY > 0 ) {
216- Camera . targetScale *= 0.8 ;
217- } else if ( event . deltaY < 0 ) {
218- Camera . targetScale *= 1.2 ;
213+ if ( Controller . pressingKeySet . has ( "shift" ) ) {
214+ if ( Camera . mouseWheelWithShiftMode === "zoom" ) {
215+ zoomCameraByMouseWheel ( event ) ;
216+ } else {
217+ moveCameraByMouseWheel ( event ) ;
218+ }
219+ } else {
220+ if ( Camera . mouseWheelMode === "zoom" ) {
221+ zoomCameraByMouseWheel ( event ) ;
222+ } else {
223+ moveCameraByMouseWheel ( event ) ;
224+ }
219225 }
220226
221227 // 滚轮横向滚动是水平移动
222228 if ( event . deltaX > 0 ) {
223229 // 左移动
224- Camera . location = Camera . location . add ( new Vector ( ( - Camera . moveAmplitude * 100 ) / Camera . currentScale , 0 ) ) ;
230+ Camera . location = Camera . location . add ( new Vector ( ( - Camera . moveAmplitude * 50 ) / Camera . currentScale , 0 ) ) ;
225231 } else if ( event . deltaX < 0 ) {
226232 // 右移动
227- Camera . location = Camera . location . add ( new Vector ( ( Camera . moveAmplitude * 100 ) / Camera . currentScale , 0 ) ) ;
233+ Camera . location = Camera . location . add ( new Vector ( ( Camera . moveAmplitude * 50 ) / Camera . currentScale , 0 ) ) ;
228234 }
229235} ;
230-
236+ function zoomCameraByMouseWheel ( event : WheelEvent ) {
237+ if ( event . deltaY > 0 ) {
238+ Camera . targetScale *= 0.8 ;
239+ } else if ( event . deltaY < 0 ) {
240+ Camera . targetScale *= 1.2 ;
241+ }
242+ }
243+ function moveCameraByMouseWheel ( event : WheelEvent ) {
244+ if ( event . deltaY > 0 ) {
245+ // 向上滚动是上移
246+ Camera . location = Camera . location . add ( new Vector ( 0 , ( Camera . moveAmplitude * 50 ) / Camera . currentScale ) ) ;
247+ } else if ( event . deltaY < 0 ) {
248+ // 向下滚动是下移
249+ Camera . location = Camera . location . subtract ( new Vector ( 0 , ( Camera . moveAmplitude * 50 ) / Camera . currentScale ) ) ;
250+ }
251+ }
231252/**
232253 * 如果使用了鼠标滚轮,则x或y的滚动必有一个接近100
233254 * @param event
0 commit comments