Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Keeping 3D layer square with camera

  • Keeping 3D layer square with camera

    Posted by Navarro Parker on April 10, 2015 at 8:42 pm

    I need a 3D layer to always be absolutely square to the camera. “Orient to Camera” still twists and rotates the layer as it approaches the edge of the comp.

    Any ideas how to do this? (I vaguely feel like I’ve asked this before)

    Here’s what I’m talking about:

    Navarro Parker replied 11 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 10, 2015 at 9:00 pm

    I think this orientation expression does what you want:


    L = thisComp.layer("Camera 1");
    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)]

    Dan

  • Navarro Parker

    April 10, 2015 at 9:39 pm

    Amazing, per usual, Dan! Thank you!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy