fixed player controller fps problem

This commit is contained in:
azykov@mail.ru
2026-06-13 17:35:30 +03:00
parent 936db7ee0f
commit 004ec827d3
+3 -2
View File
@@ -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);