# Lerp is not a function

**URL:** <https://discourse.threejs.org/t/lerp-is-not-a-function/54957>\
**Category:** Questions\
**Tags:** animation, lerp\
**Created:** [August 15, 2023, 7:03am UTC](https://discourse.threejs.org/t/lerp-is-not-a-function/54957 "2023-08-15T07:03:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oldboy](https://avatars.discourse-cdn.com/v4/letter/o/aca169/32.png) [@oldboy](https://discourse.threejs.org/u/oldboy)\
**Post date:** [August 15, 2023, 7:03am UTC](https://discourse.threejs.org/t/lerp-is-not-a-function/54957/1 "2023-08-15T07:03:29Z")

</div>

```
const sectionHome = document.querySelector('#section-home')
let isScrolling = false
let targetRotation = new THREE.Euler(-4.75, 0, Math.PI / -2);
let transitionSpeed = 0.005; // Adjust this for the desired speed

function doSomething(){
  if (!isScrolling) {
    isScrolling = true
    const initialRotation = model.rotation.clone();
    let startTime = null;

    function updateRotation(timestamp) {
      if (!startTime) startTime = timestamp;
      const elapsedTime = timestamp - startTime;
      const progress = Math.min(elapsedTime / (1000 * transitionSpeed), 1);

      // Use lerp to interpolate rotation smoothly
      const newRotation = new THREE.Euler().copy(initialRotation).lerp(targetRotation, progress);
      model.rotation.copy(newRotation);

      if (progress < 1) {
        requestAnimationFrame(updateRotation);
      }
    }

    requestAnimationFrame(updateRotation);
  }
}
sectionHome.addEventListener('scroll', doSomething)

```

Console is throwing an error, `Uncaught TypeError: (intermediate value).copy(...).lerp is not a function`, and I have no idea why this is happening. Anybody have an idea?

---

<div class="post-metadata">

**Author:** ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)\
**Post date:** [August 15, 2023, 7:16am UTC](https://discourse.threejs.org/t/lerp-is-not-a-function/54957/2 "2023-08-15T07:16:44Z")

</div>

Euler most likely doesn’t have a lerp function, but either way, lerp looks pretty bad any way, prefer Unity damping

> **[GitHub - pmndrs/maath: 🪶 Math helpers for the rest of us](https://github.com/pmndrs/maath#easing)**
>
> 🪶 Math helpers for the rest of us. Contribute to pmndrs/maath development by creating an account on GitHub.

This supports all of threes constructs: vec Euler quat …

```
dampE(mesh.rotation, [Math.PI / 2, 0, 0], 0.25, delta)

```

Especially for scrolling you need interruptible damping with velocity and maxVelocity, or else it will feel jerky and skippy. A normal lerp wouldn’t be able to do that.

---

<div class="post-metadata">

**Author:** ![oldboy](https://avatars.discourse-cdn.com/v4/letter/o/aca169/32.png) [@oldboy](https://discourse.threejs.org/u/oldboy)\
**Post date:** [August 15, 2023, 7:26am UTC](https://discourse.threejs.org/t/lerp-is-not-a-function/54957/3 "2023-08-15T07:26:06Z")

</div>

ah i think youre right now that you mention it. i dont see `lerp` mentioned anywhere on the `Euler` documentation page 😕

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [August 15, 2023, 8:54am UTC](https://discourse.threejs.org/t/lerp-is-not-a-function/54957/4 "2023-08-15T08:54:42Z")

</div>

`lerp()` for Euler angles does not exist. The book _3D Math Primer for Graphics and Game Development_ explains in chapter 8.3.4 _Disadvantages of Euler Angles_ in detail why interpolating between two Euler angles is problematic.

I suggest you represent your orientations as quaternions and then use [Quaternion.slerp()](https://threejs.org/docs/index.html#api/en/math/Quaternion.slerp),
