Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using Layer Space Transforms Without a Layer?

  • Using Layer Space Transforms Without a Layer?

    Posted by Fad Almeida on March 21, 2021 at 2:50 am

    Sometimes I want to use layer space transforms without a layer. Here’s an example of a case where this would be useful:
    – I want to project an arbitrary point (that’s not the position of a 3D layer) from world space to composition space.

    For this specific case, I’ve gone about it by creating an “Origin” layer and utilising it as such:

    var origin = thisComp.layer("Origin"); // a 3d layer whose position, rotation, anchor point are set to [0, 0, 0] and scale to [100, 100, 100]
    var point3D = [100, 200, 300]; // the point to convert to comp space
    var converted = origin.toComp(point3D); // convert point3D's position relative to the Origin layer's position to comp space, which with how that layer is set up, is also just point3D's position in world space
    var point2D = [converted[0], converted[1]]; // discarding z component

    It works perfectly, however it requires work “outside” just the expression because I have to create that origin layer. Another case would be rotating an arbitrary point about the origin an arbitrary amount, without having to set up external layers.

    I know this work can be done manually, but in my experience it is much faster to let After Effects handle the math than making it run my own code to do the math.

    Is there a way to do this kind of stuff using layer space transforms without creating any extra layers, that is, solely within the expression?

    Filip Vandueren replied 5 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    March 22, 2021 at 3:21 pm

    doesn’t toWorld() and fromWorld() work for this ?

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