-
Dan’s Elastic Expression, but in 3D
Hey I found Dan’s cool elastic expression, but I believe it only works in 2D space.
Is there a way to make this work in 3D space? I want some layers to elastically follow a 3D null.
restLength = 20;
damp = .95;
leader = thisComp.layer("leader");fDur = thisComp.frameDuration;
currFrame = Math.round(time / fDur);p2 = position.valueAtTime(0);
v2 = 0;
for (f = 0; f <= currFrame; f++){
t = f*fDur;
p1 = leader.transform.position.valueAtTime(t);
delta = p2 - p1;
nDelta = normalize(delta);
a = 2 * nDelta * (length(delta) - restLength) * fDur;
v2 = (v2 - a) * damp;
p2 += v2;
}
p2