three-base 2.0.123 → 2.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FPScontrol.d.ts +1 -0
- package/FPScontrol.js +13 -0
- package/package.json +1 -1
package/FPScontrol.d.ts
CHANGED
package/FPScontrol.js
CHANGED
|
@@ -31,6 +31,8 @@ export default class FPScontrol extends EventDispatcher {
|
|
|
31
31
|
STEPS_PER_FRAME = 5; // 每帧碰撞计算的次数
|
|
32
32
|
speed = 1; // 速度
|
|
33
33
|
camera;
|
|
34
|
+
// 移动时是否保持惯性 由外部来配置
|
|
35
|
+
inertia = true;
|
|
34
36
|
// 八叉树数组
|
|
35
37
|
octreeMap = new Map();
|
|
36
38
|
octree = (() => {
|
|
@@ -119,6 +121,7 @@ export default class FPScontrol extends EventDispatcher {
|
|
|
119
121
|
// 玩家移动控制器
|
|
120
122
|
controls = (deltaTime) => {
|
|
121
123
|
const speedDelta = deltaTime * (this.playerOnFloor ? 25 : 8) * this.speed;
|
|
124
|
+
// const speedDelta = this.speed;
|
|
122
125
|
if (this.keyStates["KeyW"]) {
|
|
123
126
|
this.playerVelocity.add(this.getForwardVector().multiplyScalar(speedDelta));
|
|
124
127
|
}
|
|
@@ -131,6 +134,16 @@ export default class FPScontrol extends EventDispatcher {
|
|
|
131
134
|
if (this.keyStates["KeyD"]) {
|
|
132
135
|
this.playerVelocity.add(this.getSideVector().multiplyScalar(speedDelta));
|
|
133
136
|
}
|
|
137
|
+
if (this.playerOnFloor &&
|
|
138
|
+
!this.keyStates["KeyW"] &&
|
|
139
|
+
!this.keyStates["KeyS"] &&
|
|
140
|
+
!this.keyStates["KeyA"] &&
|
|
141
|
+
!this.keyStates["KeyD"]) {
|
|
142
|
+
if (!this.inertia) { // 关闭惯性时就大幅增加动能的衰减
|
|
143
|
+
this.playerVelocity.x *= 0.85;
|
|
144
|
+
this.playerVelocity.z *= 0.85;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
134
147
|
if (this.playerOnFloor) {
|
|
135
148
|
if (this.keyStates["Space"]) {
|
|
136
149
|
this.playerVelocity.y = 15;
|