Skip to content

Instantly share code, notes, and snippets.

@eeropic
Last active June 12, 2024 10:23
Show Gist options
  • Select an option

  • Save eeropic/eea5c38887178b1756d99da453e4977f to your computer and use it in GitHub Desktop.

Select an option

Save eeropic/eea5c38887178b1756d99da453e4977f to your computer and use it in GitHub Desktop.
After effects expressions and scripts collected from various authors and myself.
//Position
L=thisComp.layer("Object center");
L.toWorld(L.effect(name)("3D Point"));
//Scale
L =thisComp.layer("Object center");
[L.transform.scale[0]/100*value[0],L.transform.scale[1]/100*value[1],L.transform.scale[2]/100*value[2]];
//Orientation
L = thisComp.layer("Object center");
u = fromWorldVec(L.toWorldVec([1,0,0]));
v = fromWorldVec(L.toWorldVec([0,1,0]));
w = normalize(fromWorldVec(L.toWorldVec([0,0,1])));
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);
c = 0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment