Skip to content

Commit 05caff1

Browse files
fix: ecctrl export type
1 parent 3189919 commit 05caff1

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ecctrl",
3-
"version": "1.0.72",
3+
"version": "1.0.73",
44
"author": "Erdong Chen",
55
"license": "MIT",
66
"description": "A floating rigibody character controller for R3F",

src/Ecctrl.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type RigidBodyProps,
1010
CylinderCollider,
1111
} 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";
1313
import * as THREE from "three";
1414
import { useControls } from "leva";
1515
import { useFollowCam } from "./hooks/useFollowCam";
@@ -45,7 +45,7 @@ const getMovingDirection = (forward: boolean,
4545
if (forward) return pivot.rotation.y;
4646
};
4747

48-
const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({
48+
const Ecctrl: ForwardRefRenderFunction<RapierRigidBody, EcctrlProps> = ({
4949
children,
5050
debug = false,
5151
capsuleHalfHeight = 0.35,
@@ -966,6 +966,8 @@ const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({
966966
}, [])
967967

968968
useFrame((state, delta) => {
969+
if (delta > 1) delta %= 1;
970+
969971
// Character current position
970972
if (characterRef.current) {
971973
currentPos.copy(characterRef.current.translation() as THREE.Vector3);
@@ -1427,9 +1429,9 @@ const Ecctrl = forwardRef<RapierRigidBody, EcctrlProps>(({
14271429
</group>
14281430
</RigidBody>
14291431
);
1430-
})
1432+
}
14311433

1432-
export default Ecctrl
1434+
export default forwardRef(Ecctrl);
14331435

14341436
export interface EcctrlProps extends RigidBodyProps {
14351437
children?: ReactNode;

0 commit comments

Comments
 (0)