I have some background elements that I want to wander around, and because I’m lazy I don’t want to hand animate them, so they just have a wiggle expression applied to their position channel and auto-orient switched on. Instant crowd scene!
But I want them to have a drop shadow. Normally to keep the drop shadow of a rotating element correctly aligned I use this on the direction property:
value - thisLayer.transform.rotation
simple enough, it compensates for the layer’s rotation by substracting it from the desired value. But for layers that have parents or that are auto-oriented this won’t work. So we have to find their orientation in comp-space. That’s where the slightly mystifying toCompVec expression comes in.
What toCompVec does is to give you the composition equivalent for a given vector on your layer. So it translates an arbitrary layer vector into comp space.
If the vector you give it is the unit vector along the x axis of the layer (i.e the vector [1, 0]) the result can be fed into the atan2 function to return the rotation of the layer in relation to the world.
This is expressed in radians, so to make it useful for the drop-shadow direction control we use radiansToDegrees to turn it into degrees. Put it all together and you get this rather ugly looking thing:
TL;DR copy and paste the above expression on the drop shadow effect’s direction property.