Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda