import { useEffect } from "react"; import { useFrame } from "@react-three/fiber"; import { useAnimations, useGLTF } from "@react-three/drei"; export default function Bird({ speed, factor, url, ...props }) { const { nodes, animations } = useGLTF(url); const { ref, mixer } = useAnimations(animations); useEffect( () => void mixer.clipAction(animations[0], ref.current).play(), [mixer, animations, ref], ); useFrame((state, delta) => { ref.current.rotation.y += Math.sin((delta * factor) / 2) * Math.cos((delta * factor) / 2) * 1.5; mixer.update(delta * speed); }); return ( ); }