diff --git a/src/App.tsx b/src/App.tsx
index a765911..15804bf 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -256,15 +256,39 @@ const Scene = () => {
}
interface Human3DSkeletonProps {
- index: number
+ startFrame?: number
jointRadius?: number
boneRadius?: number
showJoints?: boolean
showBones?: boolean
+ frameRate?: number
}
- const Human3DSkeleton = ({ index, jointRadius = 0.01, boneRadius = 0.005, showJoints = true, showBones = true }: Human3DSkeletonProps) => {
- const joints = POSE_3D[index]
+ const Human3DSkeleton = ({
+ startFrame = 0,
+ jointRadius = 0.01,
+ boneRadius = 0.005,
+ showJoints = true,
+ showBones = true,
+ frameRate = 30
+ }: Human3DSkeletonProps) => {
+ const [frameIndex, setFrameIndex] = useState(startFrame)
+ const totalFrames = POSE_3D.length
+
+ // Use frame to animate through the skeleton poses
+ useFrame((state, delta) => {
+ // Calculate next frame based on desired frame rate and delta time
+ setFrameIndex(prevFrame => {
+ // Calculate next frame
+ const nextFrame = prevFrame + frameRate * delta
+ // Loop back to start if we reach the end
+ return nextFrame >= totalFrames ? 0 : nextFrame
+ })
+ })
+
+ // Get the current frame joints - use Math.floor to get the nearest frame
+ const currentFrame = Math.floor(frameIndex) % totalFrames
+ const joints = POSE_3D[currentFrame]
// Function to get appropriate color for a joint index
const getJointColor = (idx: number) => {
@@ -370,16 +394,6 @@ const Scene = () => {
)
}
- interface JointsProps {
- index: number
- radius?: number
- }
-
- // Keep the old Joints component for compatibility
- const Joints = ({ index, radius }: JointsProps) => {
- return