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

394
Views
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
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!