Calculate angle of 3D-layer relative to camera

Used for the Rotation parameter.

X, Y, Z this is the axes, the angle of which will be calculated. The value 1 includes the required axis, the other axes must be set to 0 (zero). For example, to calculate the angle along the Y axis, set X = 0; Y = 1; Z = 0.

target = thisComp.layer("Target Null"); // 3D layer for which the angle will be calculated
X = 1;
Y = 0;
Z = 0;
fix1 = target.toComp([0,0,0]);
fix2 = target.toComp([X,Y,Z]);
delta=sub(fix1, fix2);
angle=Math.atan2(delta[1], delta[0]);
radiansToDegrees(angle);
Recommended Posts

Start typing and press Enter to search