Guest User

Untitled

a guest
Jun 8th, 2024
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.08 KB | Source Code | 0 0
  1. n = 0;
  2. if (numKeys > 0) {
  3.     n = nearestKey(time).index;
  4.     if (key(n).time > time) {
  5.         n--;
  6.     }
  7. }
  8. if (n == 0) {
  9.     t = 0;
  10. } else {
  11.     t = time - key(n).time;
  12. }
  13.  
  14. dampedBounce = function(t, amp, freq, decay, damping=1.5) {
  15.     return (amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t) * Math.exp(-damping * t));
  16. }
  17.  
  18. markerTime = null;
  19. if (thisLayer.marker.numKeys > 0) {
  20.     markerIndex = thisLayer.marker.nearestKey(time).index;
  21.     if (thisLayer.marker.key(markerIndex).time <= time) {
  22.         markerTime = thisLayer.marker.key(markerIndex).time;
  23.     }
  24. }
  25.  
  26. result = value;
  27. if (markerTime === null || time < markerTime) {
  28.     if (n > 0) {
  29.         v = velocityAtTime(key(n).time - thisComp.frameDuration / 10);
  30.         amp = 1.5;
  31.         freq = 2.0;
  32.         decay = 5.0;
  33.         result += (v / 100) * dampedBounce(t, amp, freq, decay);
  34.     }
  35.  
  36.     for (i = n; i > 0; i--) {
  37.         prevT = time - key(i).time;
  38.         if (prevT < t) {
  39.             result += dampedBounce(prevT, amp, freq, decay, damping) * key(i).value;
  40.         }
  41.     }
  42. }
  43.  
  44. result;
  45.  
Advertisement
Add Comment
Please, Sign In to add comment