Simplify camera yaw calculation by setting yaw directly to target value, removing dampening logic
This commit is contained in:
@@ -37,7 +37,6 @@ const MIN_PITCH_RADIANS = -0.2;
|
||||
const MAX_PITCH_RADIANS = Math.PI * 0.45;
|
||||
export const THIRD_PERSON_CAMERA_COLLISION_RADIUS = 0.2;
|
||||
const CAMERA_PIVOT_EYE_HEIGHT_FACTOR = 0.85;
|
||||
const TARGET_ASSIST_YAW_SPEED = 2.2;
|
||||
const TARGET_ASSIST_VERTICAL_LOOK_SPEED = 3.4;
|
||||
const TARGET_ASSIST_VERTICAL_LOOK_LIMIT = 1.25;
|
||||
const TARGET_ASSIST_VERTICAL_COLLISION_FADE_START_RATIO = 0.28;
|
||||
@@ -63,24 +62,6 @@ function clampCameraDistance(distance: number): number {
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeAngleRadians(angle: number): number {
|
||||
return Math.atan2(Math.sin(angle), Math.cos(angle));
|
||||
}
|
||||
|
||||
function dampAngleRadians(
|
||||
current: number,
|
||||
target: number,
|
||||
strength: number,
|
||||
dt: number
|
||||
): number {
|
||||
if (dt <= 0 || strength <= 0) {
|
||||
return current;
|
||||
}
|
||||
|
||||
const alpha = 1 - Math.exp(-strength * dt);
|
||||
return current + normalizeAngleRadians(target - current) * alpha;
|
||||
}
|
||||
|
||||
function dampScalar(
|
||||
current: number,
|
||||
target: number,
|
||||
@@ -419,12 +400,7 @@ export class ThirdPersonNavigationController implements NavigationController {
|
||||
targetAssist.targetPosition.x - this.feetPosition.x,
|
||||
targetAssist.targetPosition.z - this.feetPosition.z
|
||||
);
|
||||
this.cameraYawRadians = dampAngleRadians(
|
||||
this.cameraYawRadians,
|
||||
targetYaw,
|
||||
TARGET_ASSIST_YAW_SPEED * targetAssist.strength,
|
||||
dt
|
||||
);
|
||||
this.cameraYawRadians = targetYaw;
|
||||
const eyeHeight = getFirstPersonPlayerEyeHeight(this.activePlayerShape);
|
||||
const pivotY =
|
||||
this.smoothedFeetY + eyeHeight * CAMERA_PIVOT_EYE_HEIGHT_FACTOR;
|
||||
|
||||
Reference in New Issue
Block a user