Skip to content

Commit ed0ee60

Browse files
committed
🔥 去掉shift键快速移动的功能,因为会导致一些输入法切换设置为shift的用户出现严重问题
1 parent 6d5ff86 commit ed0ee60

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

app/src/core/service/controlService/controller/concrete/ControllerCamera.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,12 @@ export class ControllerCameraClass extends ControllerClass {
4848
}
4949

5050
let addAccelerate = ControllerCameraClass.keyMap[key];
51-
let accelerateSize = 1;
52-
if (Controller.pressingKeySet.has("shift")) {
53-
accelerateSize = 10;
54-
}
55-
addAccelerate = addAccelerate.multiply(accelerateSize);
51+
5652
if (Camera.cameraKeyboardMoveReverse) {
5753
addAccelerate = addAccelerate.multiply(-1);
5854
}
5955
// 当按下某一个方向的时候,相当于朝着某个方向赋予一次加速度
60-
Camera.accelerateCommander = Camera.accelerateCommander
61-
.add(addAccelerate)
62-
.limitX(-accelerateSize, accelerateSize)
63-
.limitY(-accelerateSize, accelerateSize);
56+
Camera.accelerateCommander = Camera.accelerateCommander.add(addAccelerate).limitX(-1, 1).limitY(-1, 1);
6457
}
6558
if (key === " ") {
6659
if (!isPreGrabbingWhenSpace) {
@@ -94,20 +87,12 @@ export class ControllerCameraClass extends ControllerClass {
9487
return;
9588
}
9689
let addAccelerate = ControllerCameraClass.keyMap[key];
97-
let accelerateSize = 1;
98-
if (Controller.pressingKeySet.has("shift")) {
99-
accelerateSize = 10;
100-
}
101-
addAccelerate = addAccelerate.multiply(accelerateSize);
10290

10391
if (Camera.cameraKeyboardMoveReverse) {
10492
addAccelerate = addAccelerate.multiply(-1);
10593
}
10694
// 当松开某一个方向的时候,相当于停止加速度
107-
Camera.accelerateCommander = Camera.accelerateCommander
108-
.subtract(addAccelerate)
109-
.limitX(-accelerateSize, accelerateSize)
110-
.limitY(-accelerateSize, accelerateSize);
95+
Camera.accelerateCommander = Camera.accelerateCommander.subtract(addAccelerate).limitX(-1, 1).limitY(-1, 1);
11196
}
11297
if (key === " ") {
11398
if (isPreGrabbingWhenSpace) {

app/src/core/stage/Camera.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ export namespace Camera {
3333
* 指数越大,速度衰减越快
3434
*/
3535
export const frictionExponent = 1.5;
36+
37+
// /**
38+
// * 是否正在快速移动模式
39+
// */
40+
// let isFastMovingMode = false;
41+
// export function changeToFastMode() {
42+
// Stage.effectMachine.addEffect(TextRiseEffect.default("快速移动开启"));
43+
// isFastMovingMode = true;
44+
// }
45+
// export function changeToSlowMode() {
46+
// Stage.effectMachine.addEffect(TextRiseEffect.default("快速移动关闭"));
47+
// isFastMovingMode = false;
48+
// }
3649
/**
3750
* 摄像机的位置(世界坐标)
3851
* 实际上代表的是 currentLocation
@@ -103,7 +116,7 @@ export namespace Camera {
103116
// 实测只有把摩擦力和动力都拉满时才会瞬间触发NaN,当玩家正常数据状态下有意识地向远处飞时反而不会触发
104117
// 因此这个彩蛋可能是个bug。先暂时改成正常的提示语
105118
// Stage.effectMachine.addEffect(new TextRiseEffect("派蒙:前面的区域以后再来探索吧?"));
106-
Stage.effectMachine.addEffect(new TextRiseEffect("出现错误:摄像机位置为NaN"));
119+
Stage.effectMachine.addEffect(new TextRiseEffect("摄像机位置为NaN,自动重置视野"));
107120
speed = Vector.getZero();
108121
reset();
109122
return;
@@ -139,25 +152,29 @@ export namespace Camera {
139152
});
140153
}
141154

155+
// 计算摩擦力
142156
let friction = Vector.getZero();
143157

144158
if (!speed.isZero()) {
145159
const speedSize = speed.magnitude();
146-
// 计算摩擦力
160+
147161
friction = speed
148162
.normalize()
149163
.multiply(-1)
150164
.multiply(Camera.frictionCoefficient * speedSize ** Camera.frictionExponent);
151165
}
152166

153-
// 速度 = 速度 + 加速度(各个方向的力之和)
154-
speed = speed
155-
.add(
156-
accelerateCommander
157-
/** 摄像机 >1放大 <1缩小,为了让放大的时候移动速度慢,所以取倒数 */
158-
.multiply(Camera.moveAmplitude * (1 / currentScale)),
159-
)
160-
.add(friction);
167+
// 计算动力
168+
const power = accelerateCommander
169+
/** 摄像机 >1放大 <1缩小,为了让放大的时候移动速度慢,所以取倒数 */
170+
.multiply(Camera.moveAmplitude * (1 / currentScale));
171+
172+
// if (isFastMovingMode) {
173+
// power = power.multiply(10);
174+
// }
175+
176+
// 速度 = 速度 + 加速度(动力+摩擦力)
177+
speed = speed.add(power).add(friction);
161178
location = location.add(speed);
162179

163180
// 处理缩放

0 commit comments

Comments
 (0)