0

I'm animating a camera in my scene and have been playing with Quaternion.slerp() and Vector3.lerpVectors().

With lerpVectors, I have a function that takes in a Vector3 to look at, and a duration to animate across, e.g.

rotateCameraToDestination(new Vector(1,1,1), 3);

With slerp, I have an identical function that takes in a Quaternion to orient to, and also a duration to animate across, e.g.

rotateCameraToDestination(new Quaternion().setFromRotationMatrix(m), 3);

Both durations are 3 seconds (both using delta time to animate during render loop) yet when I test the slerp function, I generally have to increase the duration to something like 30 or 300.

Do the two methods interpolate at different rates?

Any explanation would be appreciated, I need to leave appropriate documentation on any functions I develop, cheers

EDIT

As mentioned in my comment, I think that because I was updating the start position for my lerp function, it starts quickly, then ends slow, the slerp was just consistent rate, as I wasn't changing the start quaternion each frame.

So they just appeared to run at different rates.

Crudely represented like this:

LERP:
l-------l-------l-----l----l----l---l---l--l--l--l-l-llll

SLERP:

l---l---l---l---l---l---l---l---l---l---l---l---l---l---l

Sorry for hassle guys :(

HazeyAce
  • 361
  • 3
  • 12
  • 1
    We need to see how each function is implemented to see what's actually going on. How are you performing the interpolations? Just showing us the functions being called isn't very helpful. – M - Aug 23 '18 at 18:17
  • I agree. The name of a function tells us very little, it’s the code inside the function that matters. – pailhead Aug 24 '18 at 04:01
  • Possible duplicate of [How do you performance test JavaScript code?](https://stackoverflow.com/questions/111368/how-do-you-performance-test-javascript-code) – pailhead Aug 24 '18 at 04:04
  • I realised why, with the lerp, I was changing it's starting vector each frame, so they were technically running at the same rate, just the lerps change in position was very minimal towards the end of the duration. I'll try to represent what I mean in EDIT. – HazeyAce Aug 29 '18 at 14:52
  • Yes they do interpolate at different rates, so to speak explanation here: https://www.youtube.com/watch?v=x1aCcyD0hqE&list=PLW3Zl3wyJwWOpdhYedlD-yCB7WQoHf-My&index=37&t=18s – eds Sep 03 '19 at 14:19

0 Answers0