• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

The behavior logic of the toWorld() and fromWorld() methods in Expression

Participant ,
Oct 13, 2022 Oct 13, 2022

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?

TOPICS
Expressions

Views

62

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2022 Oct 13, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 13, 2022 Oct 13, 2022

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????

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

Correct. The camera and solid need to be children of the Null.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

LATEST

It was obvious... lazy mind. Thank you Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines