Copy link to clipboard
Copied
Hi all...
Can anyone explain the behavior logic of the toWorld() and fromWorld() methods in the provided scene.
https://drive.google.com/file/d/1VkAHg3bGehuDQlTyQpphz63yhwYpn6-0/view?usp=sharing
When the "Yellow Solid" layer does not have an ancestor, the behavior of the expression written for the Position property of the "Red Solid" layer is clear.
----------------------------------------------------------------
var targetLayer = thisComp.layer(2);
targetLayer.fromWorld(targetLayer.toWorld(targetLayer.position));
--------------------------------------------------------------
The position of the "Red Solid" layer is equal to the position of the "Yellow Solid" layer.
But when the layer "Camera 1" is assigned as the ancestor of the "Yellow Solid" layer, the algorithm for calculating the position of the "Red Solid" layer is not clear. The toWorld() method, as far as I understand, is designed to calculate the position of the child layer, which is the "Yellow Solid" layer???
And what should be the expression for the Position property of the "Red Solid" layer, when the ancestor of the "Yellow Solid" layer is the "Camera 1" layer, so that the position of the "Red Solid" layer matches the position of the "Yellow Solid" layer?
Copy link to clipboard
Copied
They are generic matrix methods not specifically tied to parents or children. the camera is a special use case, since it's assumed as the world projection. What you have in your project therefore won't work. The proper way to do it would be to parent the camera and solid to a Null.
Mylenium
Copy link to clipboard
Copied
What does "it would be to parent the camera and solid to a Null." ??? The ancestor of the created Null Object will be the "Camera 1" layer????
Copy link to clipboard
Copied
Correct. The camera and solid need to be children of the Null.
Mylenium
Copy link to clipboard
Copied
It was obvious... lazy mind. Thank you Mylenium