-
Using Layer Space Transforms Without a Layer?
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 componentIt 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?