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
+17 -24
View File
@@ -129,12 +129,6 @@ export function Ebike({
// State for debug visualization (synced from refs during useFrame) // State for debug visualization (synced from refs during useFrame)
const [showCameraPoints, setShowCameraPoints] = useState(true); 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 // Keep movementModeRef in sync — useFrame closures capture React state at
// render time and can become stale between renders. // 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) // Sync debug visualization state (throttled to avoid excessive re-renders)
if (showCameraPoints) { // Debug visualization positions are derived elsewhere when needed.
setDebugRestingPosition([...restingPositionRef.current]);
}
} else { } else {
updateEbikeSounds({ mounted: false, driving: false, breakdown: false }); updateEbikeSounds({ mounted: false, driving: false, breakdown: false });
groupRef.current.position.set(...restingPositionRef.current); 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 = const interactionLabel =
mainState === "ebike" mainState === "ebike"
? "Lancer le repair game" ? "Lancer le repair game"
@@ -409,9 +390,15 @@ export function Ebike({
EBIKE_CAMERA_TRANSFORM.rotation[2], EBIKE_CAMERA_TRANSFORM.rotation[2],
]; ];
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => { animateCameraTransformTransition(
targetCamPos,
targetRotation,
1,
() => {
useGameStore.getState().setPlayerMovementMode("ebike"); useGameStore.getState().setPlayerMovementMode("ebike");
}); },
{ lockInput: false },
);
} else { } else {
const currentPos = new THREE.Vector3(); const currentPos = new THREE.Vector3();
if (groupRef.current) { if (groupRef.current) {
@@ -437,9 +424,15 @@ export function Ebike({
THREE.MathUtils.radToDeg(currentEuler.z), THREE.MathUtils.radToDeg(currentEuler.z),
]; ];
animateCameraTransformTransition(targetCamPos, targetRotation, 1, () => { animateCameraTransformTransition(
targetCamPos,
targetRotation,
1,
() => {
useGameStore.getState().setPlayerMovementMode("walk"); useGameStore.getState().setPlayerMovementMode("walk");
}); },
{ lockInput: false },
);
} }
}, [movementMode, mainState, ebikeStep, setMissionStep, camera, position]); }, [movementMode, mainState, ebikeStep, setMissionStep, camera, position]);
+7
View File
@@ -242,7 +242,10 @@ export function animateCameraTransformTransition(
targetRotation: Vector3Tuple, targetRotation: Vector3Tuple,
duration: number = 1, duration: number = 1,
onComplete?: () => void, onComplete?: () => void,
options: { lockInput?: boolean } = {},
): void { ): void {
const { lockInput = true } = options;
if (!globalCamera) { if (!globalCamera) {
logger.warn("GameCinematics", "Camera not found for transition"); logger.warn("GameCinematics", "Camera not found for transition");
onComplete?.(); onComplete?.();
@@ -252,7 +255,9 @@ export function animateCameraTransformTransition(
const camera = globalCamera; const camera = globalCamera;
cameraTransitionTimeline?.kill(); cameraTransitionTimeline?.kill();
if (lockInput) {
useGameStore.getState().setCinematicPlaying(true); useGameStore.getState().setCinematicPlaying(true);
}
// Convert target rotation in degrees to quaternion // Convert target rotation in degrees to quaternion
const targetEuler = new THREE.Euler( const targetEuler = new THREE.Euler(
@@ -274,7 +279,9 @@ export function animateCameraTransformTransition(
}, },
onComplete: () => { onComplete: () => {
cameraTransitionTimeline = null; cameraTransitionTimeline = null;
if (lockInput) {
useGameStore.getState().setCinematicPlaying(false); useGameStore.getState().setCinematicPlaying(false);
}
onComplete?.(); onComplete?.();
}, },
}); });