From 004ec827d3ec3bc55143e4005cb673d29cecdccb Mon Sep 17 00:00:00 2001 From: "azykov@mail.ru" Date: Sat, 13 Jun 2026 17:35:30 +0300 Subject: [PATCH] fixed player controller fps problem --- webclient/src/components/CharacterView.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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);