working bike

This commit is contained in:
math-pixel
2026-05-17 08:15:16 +02:00
parent cff7744ad9
commit fbedb90bca
5 changed files with 77 additions and 15 deletions
+1 -1
View File
@@ -181,7 +181,7 @@ function playCinematic(
let cameraTransitionTimeline: gsap.core.Timeline | null = null;
let globalCamera: THREE.Camera | null = null;
export function setGlobalCamera(camera: THREE.Camera): void {
export function setGlobalCamera(camera: THREE.Camera | null): void {
globalCamera = camera;
}
-2
View File
@@ -51,14 +51,12 @@ function StageAnchor({
export function GameStageContent(): React.JSX.Element {
const mainState = useGameStore((state) => state.mainState);
const isBikeUnlocked = useGameStore((state) => state.intro.isBikeUnlocked);
return (
<>
{mainState === "intro" ? (
<StageAnchor color="#7dd3fc" position={[0, 4, 0]} />
) : null}
{/* {isBikeUnlocked ? <Ebike position={[0, 15, 0]} /> : null} */}
<Ebike position={[0, 5, 0]} />
{GAME_REPAIR_ZONES.map((zone) => (
<RepairGame
+7 -1
View File
@@ -1,12 +1,18 @@
import { useEffect } from "react";
import { useThree } from "@react-three/fiber";
import { PointerLockControls } from "@react-three/drei";
import { setGlobalCamera } from "@/world/GameCinematics";
export function PlayerCamera(): React.JSX.Element {
const camera = useThree((state) => state.camera);
useEffect(() => {
setGlobalCamera(camera);
return () => {
setGlobalCamera(null);
document.exitPointerLock();
};
}, []);
}, [camera]);
return <PointerLockControls />;
}
+4 -1
View File
@@ -108,6 +108,7 @@ export function PlayerController({
const initializedRef = useRef(false);
const canMove = useGameStore((state) => state.missionFlow.canMove);
const currentSpeed = useGameStore((state) => state.player.currentSpeed);
const movementMode = useGameStore((state) => state.player.movementMode);
const capsule = useRef(createSpawnCapsule(spawnPosition));
@@ -282,7 +283,9 @@ export function PlayerController({
}
}
camera.position.copy(capsule.current.end);
if (movementMode !== "ebike") {
camera.position.copy(capsule.current.end);
}
});
return null;