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

113
Views
React Three Fiber curve-based animation

I was just wondering if is it possible to use a library like tween or animejs to increment a value in a curve-based

With that I meant to increment a value from n to x using an easing curve.

My ultimate goal is to make like a acceleration animation to the camera so I would like to use like a "ease-in-out" CSS equivalent animation.

I tried to use anime.js to increment a property of an object and then update the position of the camera

const animRef = useRef(null);
let animValue = {
  value: 0,
}

useEffect(() => {
    animRef.current = anime({
      targets: animValue,
      value: 10,
      easing: 'easeInOutQuad',
      autoplay: false, // So I can use a custom RAF loop
      update: function (anim) {
        // animValue.value <- here the value is updated
      },
    });
})

useFrame(({clock}) => {
    // Using a custom RAF loop
    animRef.current.tick(clock.elapsedTime)
    // animValue.value <- Here the value is always 0
    cameraRef.current.position.z += animValue.value
})

but the value property wont be incremented, the tick call is working but it is not updating the object property outside the anime.update function.

If there's another way approach my goal I will gladly listen

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

0

you can use anime, gsap etc. react-spring would probably be better. gasp/anime, watch out how you store their handles and anim-objects. local state is always kept in useState(() => new Foo()). other than that, the easiest is lerp/damp, because they're inbuilt in threejs.

useFrame(() => {
  ref.current.opacity = THREE.MathUtils.lerp(ref.current.opacity, condition ? 1 : 0, 0.1)

as for your code, you will loose references. state inside the render function will be lost next render. use useref or usestate. i have never tried anime before but you have to take into consideration that a component re-renders, as in, it's called multiple times.

const x = useRef({ value: 0 })
useEffect(() => {
  anime({ targets: x.current, ... })
}, [])
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!