-
Calculate angle between Object and Camera in 3D
C = thisComp.layer("Camera 1"); v1 = normalize(position - C.position) v2 = C.toWorldVec([0,0,1]); radiansToDegrees(Math.acos(dot(v1,v2)))Hi people.
I have a comp with a camera, and a layer positioned in 3D. What I would like to do is to move the camera around, and calculate the angle of the object relative to the camera.After some googling I found this piece of code on CreativeCow. But I’m not sure if this works, because currently the value depends on the xy position of the object in zspace. So not only the angle.
Basically what I am looking for is to change the object’s opacity depending on its angle and distance to the camera. And also not show at all once the came sees the object’s backside. Could someone help me out in the right direction?
Thanks!