vec3 damp and dampVectors#22720
Conversation
|
Interesting approach. When I saw your example on twitter I did wonder to myself why you just didn't create an animation clip which would play back exactly the same no matter what the framerate is. But I guess this is a different application. An alternative to the damp would be this: This would then be exact and equivalent to the animation clip example. I believe this damp is for a different application.... maybe it is best to explain why the two above approaches I suggest are not the best solution? |
|
MathUtils.damp() method has this reference: |
|
So damp is an easing function? const easeDamp = (lambda, t) => 1 - Math.exp(- lambda * t);It's quite similar to easeOutExpo: const easeOutExpo = (t) => -Math.pow(2, -10 * t) + 1;If you add the (lambda, d) => -Math.pow(Math.E, -lambda * t) + 1;Which can be written as: (lambda, t) => 1 - Math.exp(-lambda * t); |
|
Looking into this a bit more, it seems like there are two ways lerp is being used. To lerp/damp between
The second case will work well with the damp easing function On the other hand, if many people do think it's worth adding Note that the requirement to modify https://github.com/mrdoob/three.js/blob/master/src/math/MathUtils.js#L68-L80 It should probably be spelled out somewhere. There's no reason why you can't use |
|
Yeah... I don't think For these kind of use cases I'd rather rely on |
Interesting. There exist so many good JS animation libraries that adding this in three.js does seem a bit like reinventing the wheel. So we could remove all the damp stuff and recommend people to use another library for animation? Pretty much all JS animation libraries support custom easing functions so you can pass in damp easing to get this result with Tween.js or another library. @RenaudRohlinger what do you think about opening PRs to add damp easing to Tween.js/Popmotion/React-Spring etc. instead of three.js? |
|
I totally understand and agree @looeee. I will close this PR here and try to come back with this kind of feature somewhere else 👍 (most probably in the react sphere 😬 ) |
Description
Hello!
WebGL and XR performances can be pretty limited by the browser. When it comes to animations, that fps variation can generate unintentional behaviors. (Let's say you want to smooth a position from point A to point B in X ms if the fps drops the lerp function would increase the animation duration to that point).
Obviously damp is not always what you would need for your animations (let's say you don't care about the time spent to travel A -> B, and just want something very smooth).
By using damp to animate elements, we get rid of the delay generated from the frame rate fluctuation. For the time being, we added this feature only as Vector3.damp and Vector3.dampVectors. Next, we could add a smoothdamp-like slerp function to the quaternion too.
Also added a small demo
webgl_instancing_damping.htmlas a proposal.ScreenFlow.mp4
TODO: Update docs.
This contribution is funded by Utsubo.