-
How do I get the real coordinates of a 3D layer oriented along a path?
I’m using Element3D, (a 3D plugin for After Effects) and I have a model that uses the position and rotation of a 3D null object to move around in 3D space. It also means I can parent other 3D layers to this null object, and generally makes the whole affair a lot easier.
Anyway, I want to have this null object orient along a path, but because it doesn’t output rotation values the 3D object doesn’t rotate along with it. Now, I have found an expression to fix this and it works pretty much perfectly:
L = this_comp.layer(“LAYER”);
s = L.scale/100;
u = L.to_world_vec([s[0],0,0]);
v = L.to_world_vec([0,s[1],0]);
w = L.to_world_vec([0,0,s[2]]);
sinb = clamp(w[0],-1,1);
b = Math.asin(sinb/this_comp.pixel_aspect);
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 = Math.atan2(u[1],v[1]);
c = 0;
}
[radians_to_degrees(a),radians_to_degrees(b),radians_to_degrees(c)]However, it is extremely long and complicated. I never learned expressions, and I don’t have the foggiest idea of what most of it means. My current project requires, or would prefer, a simpler expression if that is at all possible.
If nothing else, from now on I think I’ll endeavour to learn expressions beyond wiggle, time and loopOut, rather than just using Google.