Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Absolute Camera Position, Orientation, and Rotation

  • Absolute Camera Position, Orientation, and Rotation

    Posted by Nate Vander plas on December 7, 2020 at 8:16 pm

    I have a 3D model rendered with Superluminal’s Stardust plugin (works kind of like Element 3D). The problem is I need to precomp this layer, but I want to link the camera in the precomp to the camera in the main comp, so as I move the main comp camera, the model moves accordingly. One more twist is that my main comp camera is parented to a null, which is parented to another null (for separate X and Y orbit moves). I can’t seem to find the correct expressions, especially for the Orientation and Rotation properties. Ideally I’d like to have the camera in the precomp not be parented to anything, so the expression just references the active camera in the main comp which may not have this parented structure. Right now I’m using “One-Node” cameras.

    Nate Vander plas replied 5 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 7, 2020 at 8:33 pm

    Try this for the precomp camera’s orientation:

    L = comp("Main Comp").layer("Camera 1");

    u = (L.toWorldVec([1,0,0]));

    v = (L.toWorldVec([0,1,0]));

    w = normalize(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)]

  • Nate Vander plas

    December 8, 2020 at 3:31 pm

    Thank you, Dan! This works great! I initially thought I still needed to have the X, Y, and Z Rotation properties of the cameras linked, but that is not the case! The Orientation expression takes care of it all ?

    If anyone else is trying to do this, here is my simple expression for the Position:

    comp("Main Comp").layer("Camera 1").toWorld([0,0,0])

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