Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
How to render animations with JSX components in Three.JS

I am trying to render some animations from my .glb file. There are 4 animations in the file. I am using Next.js paired with Three.js (and react-three-fiber), so I would like to use JSX components for this, instead of using the traditional HTML. This is the code I have so far:

function Scene() {
    const gltf = useLoader(GLTFLoader, '/drone1_spin.glb')
    const mesh = useRef()

    // This is where i'm having issues as I do not know how to render all 4 animations

    const [mixer] = useState(() => new THREE.AnimationMixer())
    useEffect(
        () => {
            void mixer.clipAction(gltf.animations[0], mesh.current).play()
            void mixer.clipAction(gltf.animations[1], mesh.current).play()
            void mixer.clipAction(gltf.animations[2], mesh.current).play()
            void mixer.clipAction(gltf.animations[3], mesh.current).play()
        },
        [gltf.animations, mixer]
    )

    // The return and stuff works all fine, but just displays a static model with no animations

    return (
        <Suspense fallback={null}>
            <primitive ref={mesh} object={gltf.scene} scale={0.5} />
        </Suspense>
    )
}

I have tried googling everything and I can't find any documentation for this so any help would be appreciated. Thank you.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!