fix?: try to fix camera snapping to rnd angles
This commit is contained in:
@@ -70,11 +70,23 @@ export default function Player() {
|
||||
camera.position.x += direction.x;
|
||||
camera.position.z += direction.z;
|
||||
|
||||
const minX = -fearState.currentWidth / 2 + FEAR_SETTINGS.WALL_BUFFER;
|
||||
const maxX = fearState.currentWidth / 2 - FEAR_SETTINGS.WALL_BUFFER;
|
||||
|
||||
if (camera.position.x < minX) camera.position.x = minX;
|
||||
if (camera.position.x > maxX) camera.position.x = maxX;
|
||||
|
||||
let bobX = 0;
|
||||
let bobY = 0;
|
||||
|
||||
const isMoving = controls.Forward || controls.Backward || controls.Left || controls.Right;
|
||||
if (isMoving) {
|
||||
movementCounter.current += delta * 10;
|
||||
camera.position.y = FEAR_SETTINGS.PLAYER_HEIGHT + Math.sin(movementCounter.current) * 0.08;
|
||||
camera.position.x += Math.cos(movementCounter.current / 2) * 0.006;
|
||||
bobY = Math.sin(movementCounter.current) * 0.08;
|
||||
bobX = Math.cos(movementCounter.current / 2) * 0.006;
|
||||
|
||||
camera.position.y = FEAR_SETTINGS.PLAYER_HEIGHT + bobY;
|
||||
camera.position.addScaledVector(side, bobX);
|
||||
} else {
|
||||
const breatheTime = state.clock.elapsedTime * 1.5;
|
||||
const breatheY = FEAR_SETTINGS.PLAYER_HEIGHT + Math.sin(breatheTime) * 0.1;
|
||||
@@ -95,12 +107,6 @@ export default function Player() {
|
||||
flashlightRef.current.intensity = FEAR_SETTINGS.FLASHLIGHT_INTENSITY_BASE + Math.sin(state.clock.elapsedTime * 30) * 0.3;
|
||||
}
|
||||
|
||||
const minX = -fearState.currentWidth / 2 + FEAR_SETTINGS.WALL_BUFFER;
|
||||
const maxX = fearState.currentWidth / 2 - FEAR_SETTINGS.WALL_BUFFER;
|
||||
|
||||
if (camera.position.x < minX) camera.position.x = minX;
|
||||
if (camera.position.x > maxX) camera.position.x = maxX;
|
||||
|
||||
const length = FEAR_SETTINGS.HALLWAY_LENGTH;
|
||||
const absoluteZ = -camera.position.z;
|
||||
const rawSegmentIndex = Math.floor(absoluteZ / length);
|
||||
@@ -139,4 +145,4 @@ export default function Player() {
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user