Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = 0;
- if (numKeys > 0) {
- n = nearestKey(time).index;
- if (key(n).time > time) {
- n--;
- }
- }
- if (n == 0) {
- t = 0;
- } else {
- t = time - key(n).time;
- }
- dampedBounce = function(t, amp, freq, decay, damping=1.5) {
- return (amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t) * Math.exp(-damping * t));
- }
- markerTime = null;
- if (thisLayer.marker.numKeys > 0) {
- markerIndex = thisLayer.marker.nearestKey(time).index;
- if (thisLayer.marker.key(markerIndex).time <= time) {
- markerTime = thisLayer.marker.key(markerIndex).time;
- }
- }
- result = value;
- if (markerTime === null || time < markerTime) {
- if (n > 0) {
- v = velocityAtTime(key(n).time - thisComp.frameDuration / 10);
- amp = 1.5;
- freq = 2.0;
- decay = 5.0;
- result += (v / 100) * dampedBounce(t, amp, freq, decay);
- }
- for (i = n; i > 0; i--) {
- prevT = time - key(i).time;
- if (prevT < t) {
- result += dampedBounce(prevT, amp, freq, decay, damping) * key(i).value;
- }
- }
- }
- result;
Advertisement
Add Comment
Please, Sign In to add comment