diff --git a/webclient/src/components/CharacterView.tsx b/webclient/src/components/CharacterView.tsx index bea6ae6..742b955 100644 --- a/webclient/src/components/CharacterView.tsx +++ b/webclient/src/components/CharacterView.tsx @@ -1,7 +1,7 @@ import { observer } from "mobx-react-lite"; import type { ObjectType, RuntimeGameObjectInstance } from "../types"; import { ObjectViewInternal, type ObjectViewInternalHandle } from "./ObjectViewInternal"; -import { useEffect, useMemo, useRef } from "react"; +import { useEffect, useLayoutEffect, useMemo, useRef } from "react"; import { Euler, Quaternion, Vector3 } from "three"; import { useFrame, useThree } from "@react-three/fiber"; import { useKeyboardControls } from "@react-three/drei"; @@ -48,7 +48,8 @@ export const PlayerObjectView = observer(function ({ object, objectType }: Playe }; }, [object.cache.boundingBox]); - const yawRef = useRef(object.rotation[1]); + const yawRef = useRef(0); + useLayoutEffect(() => { yawRef.current = object.rotation[1]; }, []); // eslint-disable-line react-hooks/exhaustive-deps const pitchRef = useRef(0); const mouseRef = useRef({ x: 0, y: 0 }); const jumpPressedRef = useRef(false);