|
9 | 9 | type RigidBodyProps,
|
10 | 10 | CylinderCollider,
|
11 | 11 | } from "@react-three/rapier";
|
12 |
| -import { useEffect, useRef, useMemo, type ReactNode, forwardRef, type RefObject } from "react"; |
| 12 | +import { useEffect, useRef, useMemo, type ReactNode, forwardRef, type ForwardRefRenderFunction, type RefObject } from "react"; |
13 | 13 | import * as THREE from "three";
|
14 | 14 | import { useControls } from "leva";
|
15 | 15 | import { useFollowCam } from "./hooks/useFollowCam";
|
@@ -45,7 +45,7 @@ const getMovingDirection = (forward: boolean,
|
45 | 45 | if (forward) return pivot.rotation.y;
|
46 | 46 | };
|
47 | 47 |
|
48 |
| -const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({ |
| 48 | +const Ecctrl: ForwardRefRenderFunction<RapierRigidBody, EcctrlProps> = ({ |
49 | 49 | children,
|
50 | 50 | debug = false,
|
51 | 51 | capsuleHalfHeight = 0.35,
|
@@ -966,6 +966,8 @@ const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({
|
966 | 966 | }, [])
|
967 | 967 |
|
968 | 968 | useFrame((state, delta) => {
|
| 969 | + if (delta > 1) delta %= 1; |
| 970 | + |
969 | 971 | // Character current position
|
970 | 972 | if (characterRef.current) {
|
971 | 973 | currentPos.copy(characterRef.current.translation() as THREE.Vector3);
|
@@ -1427,9 +1429,9 @@ const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({
|
1427 | 1429 | </group>
|
1428 | 1430 | </RigidBody>
|
1429 | 1431 | );
|
1430 |
| -}) |
| 1432 | +} |
1431 | 1433 |
|
1432 |
| -export default Ecctrl |
| 1434 | +export default forwardRef(Ecctrl); |
1433 | 1435 |
|
1434 | 1436 | export interface EcctrlProps extends RigidBodyProps {
|
1435 | 1437 | children?: ReactNode;
|
|
0 commit comments