fix: archi player

This commit is contained in:
2026-04-16 11:00:08 +02:00
parent 7769959135
commit 1eed905e8b
4 changed files with 63 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
import { useEffect } from "react";
import { PointerLockControls } from "@react-three/drei";
import { useThree } from "@react-three/fiber";
import * as THREE from "three";
export const PLAYER_EYE_HEIGHT = 1.75;
const PLAYER_SPAWN_POSITION = new THREE.Vector3(0, PLAYER_EYE_HEIGHT, 6);
const PLAYER_LOOK_AT = new THREE.Vector3(0, PLAYER_EYE_HEIGHT, 0);
export function PlayerCamera(): React.JSX.Element {
const camera = useThree((state) => state.camera);
useEffect(() => {
camera.position.copy(PLAYER_SPAWN_POSITION);
camera.lookAt(PLAYER_LOOK_AT);
camera.updateProjectionMatrix();
return () => {
document.exitPointerLock?.();
};
}, [camera]);
return <PointerLockControls />;
}