Best practice for one off animations #1704
-
Hey everyone, I am wondering if it is best practice to use react-spring rather than lerp and useFrame for conducting simple one off animations. For example I am working on some animations that change the positions of a model and the camera depending on ui state, just one position to another and the animation is done. I have it working with lerp and useFrame, but I have a feeling for animations of this kind, this approach might be a bit overkill. Does anyone know if it makes any difference performance wise to use Spring rather than Lerp in this case? Or maybe it doesn't matter? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
use frame+lerp is the lightest it can possibly get. use frame is nothing more than a function call inside the render loop and lerp is only this: v0*(1-t)+v1*t. springs are a lot more effort to calculate (but look better). you can also check out THREE.MathUtils.damp which is also super fast but might look better than lerp. |
Beta Was this translation helpful? Give feedback.
use frame+lerp is the lightest it can possibly get. use frame is nothing more than a function call inside the render loop and lerp is only this: v0*(1-t)+v1*t. springs are a lot more effort to calculate (but look better). you can also check out THREE.MathUtils.damp which is also super fast but might look better than lerp.