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

120
Views
react-spring/three not working for mesh color

I am trying to add a color transition for my mesh but am unable to do so with react-spring

Scene.js

import { useSpring, animated } from '@react-spring/three'

const Cell = () => {
  const [hovered, hover] = useState(false);
  const springs = useSpring({ color: hovered ? 'hotpink' : 'orange'})

  <animated.mesh
   onPointerEnter={(e) => {
        e.stopPropagation();
        hover(true);
      }}
      onPointerLeave={(e) => {
        e.stopPropagation();
        hover(false);
      }}
   >
    <planeGeometry args={[1, 1, 1]} />
    <meshBasicMaterial color={springs.color} />
  </animated.mesh
}

This just leaves my mesh with a white/grey color.

In the example provided here they used it in a similar way and I am unsure why it does not work. I have tested this by changed scale on the mesh itself and it worked then.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

SpringValues can only be applied to animated components. You have three components there, mesh, planeGeometry and meshBasicMaterial. You've animated mesh but you're not applying SpringValues to it so that's redundant.

Because you want the meshBasicMaterial to handle the SpringValue you should write it like so:

const Cell = () => {
  const [hovered, hover] = useState(false);
  const springs = useSpring({ color: hovered ? 'hotpink' : 'orange'})

  return <mesh
   onPointerEnter={(e) => {
        e.stopPropagation();
        hover(true);
      }}
      onPointerLeave={(e) => {
        e.stopPropagation();
        hover(false);
      }}
   >
    <planeGeometry args={[1, 1, 1]} />
    <animated.meshBasicMaterial color={springs.color} />
  </animated.mesh
}

You can see this working here – https://codesandbox.io/s/react-spring-forked-6qgre?file=/src/App.js

about 4 years ago · Juan Pablo Isaza Report
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!