动效特工队 加入小组

325个成员 7个话题 创建时间:2016-04-19

AE 弹性表达式

发表于2016-07-03 7403次查看

Keyframe Overshoot

freq = 3;

decay = 5;

n = 0;

if (numKeys > 0){

  n = nearestKey(time).index;

  if (key(n).time > time) n--;

}

if (n > 0){

  t = time - key(n).time;

  amp = velocityAtTime(key(n).time - .001);

  w = freq*Math.PI*2;

  value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);

}else

  value

 

Keyframe Bounce Back

e = .7;

g = 5000;

nMax = 9;

n = 0;

if (numKeys > 0){

  n = nearestKey(time).index;

  if (key(n).time > time) n--;

}

if (n > 0){

  t = time - key(n).time;

  v = -velocityAtTime(key(n).time - .001)*e;

  vl = length(v);

  if (value instanceof Array){

    vu = (vl > 0) ? normalize(v) : [0,0,0];

  }else{

    vu = (v < 0) ? -1 : 1;

  }

  tCur = 0;

  segDur = 2*vl/g;

  tNext = segDur;

  nb = 1; // number of bounces

  while (tNext < t && nb <= nMax){

    vl *= e;

    segDur *= e;

    tCur = tNext;

    tNext += segDur;

    nb++

  }

  if(nb <= nMax){

    delta = t - tCur;

    value +  vu*delta*(vl - g*delta/2);

  }else{

    value

  }

}else  value

 

3回复
发表回复
你还没有登录,请先登录注册