fix(ebike): allow player input during mount/dismount camera transition

Add lockInput option (default true) to animateCameraTransformTransition
so ebike mount/dismount can keep player input active during the 1s
camera tween instead of locking via setCinematicPlaying.

Also drop the unused camPointPos/dropPointPos debug vars and the
matching debugRestingPosition state — the consuming JSX has been
commented out for a while.
This commit is contained in:
Tom Boullay
2026-06-03 00:03:29 +02:00
parent 918ee49d7c
commit 83194df14f
2 changed files with 28 additions and 28 deletions
+19 -26
View File
@@ -129,12 +129,6 @@ export function Ebike({
// State for debug visualization (synced from refs during useFrame)
const [showCameraPoints, setShowCameraPoints] = useState(true);
const [debugRestingPosition, setDebugRestingPosition] =
useState<Vector3Tuple>([
parkedPosition[0],
parkedPosition[1],
parkedPosition[2],
]);
// Keep movementModeRef in sync — useFrame closures capture React state at
// render time and can become stale between renders.
@@ -321,9 +315,7 @@ export function Ebike({
}
// Sync debug visualization state (throttled to avoid excessive re-renders)
if (showCameraPoints) {
setDebugRestingPosition([...restingPositionRef.current]);
}
// Debug visualization positions are derived elsewhere when needed.
} else {
updateEbikeSounds({ mounted: false, driving: false, breakdown: false });
groupRef.current.position.set(...restingPositionRef.current);
@@ -340,17 +332,6 @@ export function Ebike({
}
});
// Debug visualization positions computed from state (not refs)
const camPointPos: Vector3Tuple = [
debugRestingPosition[0] + EBIKE_CAMERA_TRANSFORM.position[0],
debugRestingPosition[1] + EBIKE_CAMERA_TRANSFORM.position[1],
debugRestingPosition[2] + EBIKE_CAMERA_TRANSFORM.position[2],
];
const dropPointPos: Vector3Tuple = [
debugRestingPosition[0] + EBIKE_DROP_PLAYER_TRANSFORM.position[0],
debugRestingPosition[1] + EBIKE_DROP_PLAYER_TRANSFORM.position[1],
debugRestingPosition[2] + EBIKE_DROP_PLAYER_TRANSFORM.position[2],
];
const interactionLabel =
mainState === "ebike"
? "Lancer le repair game"
@@ -409,9 +390,15 @@ export function Ebike({
EBIKE_CAMERA_TRANSFORM.rotation[2],
];
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => {
useGameStore.getState().setPlayerMovementMode("ebike");
});
animateCameraTransformTransition(
targetCamPos,
targetRotation,
1,
() => {
useGameStore.getState().setPlayerMovementMode("ebike");
},
{ lockInput: false },
);
} else {
const currentPos = new THREE.Vector3();
if (groupRef.current) {
@@ -437,9 +424,15 @@ export function Ebike({
THREE.MathUtils.radToDeg(currentEuler.z),
];
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => {
useGameStore.getState().setPlayerMovementMode("walk");
});
animateCameraTransformTransition(
targetCamPos,
targetRotation,
1,
() => {
useGameStore.getState().setPlayerMovementMode("walk");
},
{ lockInput: false },
);
}
}, [movementMode, mainState, ebikeStep, setMissionStep, camera, position]);
+9 -2
View File
@@ -242,7 +242,10 @@ export function animateCameraTransformTransition(
targetRotation: Vector3Tuple,
duration: number = 1,
onComplete?: () => void,
options: { lockInput?: boolean } = {},
): void {
const { lockInput = true } = options;
if (!globalCamera) {
logger.warn("GameCinematics", "Camera not found for transition");
onComplete?.();
@@ -252,7 +255,9 @@ export function animateCameraTransformTransition(
const camera = globalCamera;
cameraTransitionTimeline?.kill();
useGameStore.getState().setCinematicPlaying(true);
if (lockInput) {
useGameStore.getState().setCinematicPlaying(true);
}
// Convert target rotation in degrees to quaternion
const targetEuler = new THREE.Euler(
@@ -274,7 +279,9 @@ export function animateCameraTransformTransition(
},
onComplete: () => {
cameraTransitionTimeline = null;
useGameStore.getState().setCinematicPlaying(false);
if (lockInput) {
useGameStore.getState().setCinematicPlaying(false);
}
onComplete?.();
},
});