Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda