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

395
Visualizações
Uncaught TypeError: Cannot read properties of undefined (reading 'play'). I can't make my 3d object clickable

Faced an issue with adding action.play

Dear developers could you please help me to solve this issue?

I want my 3d object to be clickable so that when I click the object it will jump. But unfortunately, I see this error. However, when I looked at examples of other projects where this click function is implemented, I don't see any differences between those projects and my code.

here below I attached my code(Squirrel.js):

import React, { useRef, useState, useEffect } from 'react'
import { useGLTF} from '@react-three/drei/useGLTF';
import {useAnimations} from "@react-three/drei/useAnimations";

export default function Model(props) {
const [UpDown, setUpDown] = useState(false);
const group = useRef()
const { nodes, materials, animations } = useGLTF('/squirrel.glb')
const { actions } = useAnimations(animations, group);
console.log(actions);
useEffect(() => {
if (UpDown) {
  actions.UpDown.stop();
} else {
  actions.UpDown.play();
}
});
return (
<group ref={group} {...props} dispose={null}>
  <mesh 
      onClick={() => setUpDown(!UpDown)}
      geometry={nodes.Plane155.geometry} 
      material={materials['Material.010']} 
      position={[-10,32,25]} 
      name = "Squirrel"
      />
</group>
)
}

useGLTF.preload('/squirrel.glb')
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