Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Maintain Scale of object with Z camera move

  • Maintain Scale of object with Z camera move

    Posted by Naoko Hara on March 23, 2018 at 1:20 pm

    I have a camera parented to a 3D null doing all the position moves. I need to keep the scale of my shapes constant as the camera pulls back.
    I’ve found expressions what work when all the positioning is done on the camera layer, but not when it’s attached to a 3D null.

    Help. Thanks!

    Naoko Hara replied 8 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Steve Bentley

    March 23, 2018 at 2:24 pm

    I take it you don’t want to parent the shapes to the camera (or the null) – this would keep them the same size as you pull back but they would also travel with the camera so they wouldn’t move relative to the camera. (although you could animate them)

    In the expressions the only difference should be that a null will have an anchor point and the camera wouldn’t.
    You didn’t include any expressions but in things like a=nullLayer.toWorld(nullLayer.anchorPoint); you have to reference the anchor point of the null. But in your original camera code you probably had a=camera.toWorld([0,0,0]); Since cameras (and lights) don’t have anchorpoints you just use their origins.

    I imagine using vectors would be the easiest. You could normalize the distance the camera is going to travel (or the distance to the shapes) and then you can use that as a scalar function on the shapes (or at least a multiplier) because that vector would go from zero to one. That way if all the shapes are at different scales or sizes they would all scale the same amount to keep up with the camera’s distance.

    I don’t think there is a “width” transform where you could tell the shapes to stay at a constant width relative to the 2D viewport.

  • Naoko Hara

    March 23, 2018 at 3:30 pm

    I ended up figuring it out moments after, but thanks for your response.
    Used this expression:

    nominalDist = 400;

    C = thisComp.activeCamera;
    v1 = toWorld(anchorPoint) - C.toWorld([0,0,0]);
    v2 = C.toWorldVec([0,0,1]);
    d = dot(v1,v2);

    value*(d/nominalDist)

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