Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Camera zoom fit to layer width

  • Camera zoom fit to layer width

    Posted by Ilya Sire on February 28, 2022 at 9:39 am

    Hi forum,

    I have a camera parented to 3d null as camera position driver to animate. Usually I use null zPosition to zoom layer and manually to fit the layer into camera view.

    What is the formula to calculate camera Zoom to zoom layer fit in the comp view without using zPosition?

    Thx!!

    Ilya Sire replied 4 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    February 28, 2022 at 1:04 pm

    If (and that’s an important if) the camera is already positioned exactly on top/in front of your layer and it only needs to zoom in:

    l=thisComp.layer("White Solid 1");
    d=length(
    thisLayer.toWorld([0,0,0]),
    l.toWorld(l.anchorPoint)
    );
    w = length(l.toWorld([0,0]),l.toWorld([l.width,0]));
    zoom = (thisComp.width/w) * d;

    I think I chucked enough toWorld()’s in there to make sure that parented camera’s and layer and scaled layers etc. should also work, but you might maybe still run into certain edge cases.

  • Ilya Sire

    February 28, 2022 at 4:00 pm

    Thank you, I actually ask a wrong question, and I found solutions on this line zoom = (thisComp.width/w) * distance;

    😅

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