wip bike movement

This commit is contained in:
math-pixel
2026-05-17 12:30:40 +02:00
parent fbedb90bca
commit d13dd0fda0
3 changed files with 28 additions and 21 deletions
+21 -19
View File
@@ -17,7 +17,7 @@ interface CameraTransform {
const EBIKE_CAMERA_TRANSFORM: CameraTransform = { const EBIKE_CAMERA_TRANSFORM: CameraTransform = {
position: [-3, 8, 0], position: [-3, 8, 0],
rotation: [0, 90, 0], rotation: [90, 90, 90],
}; };
const EBIKE_DROP_PLAYER_TRANSFORM: CameraTransform = { const EBIKE_DROP_PLAYER_TRANSFORM: CameraTransform = {
@@ -33,7 +33,7 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
const groupRef = useRef<THREE.Group>(null); const groupRef = useRef<THREE.Group>(null);
const { scene } = useLoggedGLTF(EBIKE_MODEL_PATH, { const { scene } = useLoggedGLTF(EBIKE_MODEL_PATH, {
scope: "Ebike", scope: "Ebike",
position: [0, 0, 0], position: position,
}); });
const model = useClonedObject(scene); const model = useClonedObject(scene);
const movementMode = useGameStore((state) => state.player.movementMode); const movementMode = useGameStore((state) => state.player.movementMode);
@@ -94,22 +94,24 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
}; };
return ( return (
<group ref={groupRef} position={position}> <>
<primitive object={model} /> <group ref={groupRef} position={position}>
<InteractableObject <primitive object={model} />
kind="trigger" <InteractableObject
label={ kind="trigger"
movementMode === "walk" ? "Monter sur le bike" : "Descendre du bike" label={
} movementMode === "walk" ? "Monter sur le bike" : "Descendre du bike"
position={position} }
radius={10} position={position}
onPress={handleInteract} radius={10}
> onPress={handleInteract}
<mesh> >
<boxGeometry args={[1.5, 1.5, 1.5]} /> <mesh>
<meshStandardMaterial color="red" opacity={0.5} transparent /> <boxGeometry args={[1.5, 1.5, 1.5]} />
</mesh> <meshStandardMaterial color="red" opacity={0.5} transparent />
</InteractableObject> </mesh>
</InteractableObject>
</group>
{debugRef.current.showCameraPoints && ( {debugRef.current.showCameraPoints && (
<> <>
<mesh position={camPointPos}> <mesh position={camPointPos}>
@@ -130,6 +132,6 @@ export function Ebike({ position }: EbikeProps): React.JSX.Element {
</mesh> </mesh>
</> </>
)} )}
</group> </>
); );
} }
+1 -1
View File
@@ -57,7 +57,7 @@ export function GameStageContent(): React.JSX.Element {
{mainState === "intro" ? ( {mainState === "intro" ? (
<StageAnchor color="#7dd3fc" position={[0, 4, 0]} /> <StageAnchor color="#7dd3fc" position={[0, 4, 0]} />
) : null} ) : null}
<Ebike position={[0, 5, 0]} /> <Ebike position={[0, 10, 0]} />
{GAME_REPAIR_ZONES.map((zone) => ( {GAME_REPAIR_ZONES.map((zone) => (
<RepairGame <RepairGame
key={zone.mission} key={zone.mission}
+6 -1
View File
@@ -109,6 +109,11 @@ export function PlayerController({
const canMove = useGameStore((state) => state.missionFlow.canMove); const canMove = useGameStore((state) => state.missionFlow.canMove);
const currentSpeed = useGameStore((state) => state.player.currentSpeed); const currentSpeed = useGameStore((state) => state.player.currentSpeed);
const movementMode = useGameStore((state) => state.player.movementMode); const movementMode = useGameStore((state) => state.player.movementMode);
const movementModeRef = useRef(movementMode);
useEffect(() => {
movementModeRef.current = movementMode;
}, [movementMode]);
const capsule = useRef(createSpawnCapsule(spawnPosition)); const capsule = useRef(createSpawnCapsule(spawnPosition));
@@ -283,7 +288,7 @@ export function PlayerController({
} }
} }
if (movementMode !== "ebike") { if (movementModeRef.current !== "ebike") {
camera.position.copy(capsule.current.end); camera.position.copy(capsule.current.end);
} }
}); });