How to synchronize the transformation of objects of different hierarchy levels?

I have an object “A” in world space, and the parent of another object “B” is group. Now “B” object needs to move with the object “A” and the location are consistent.I use the following methods:

B.parent.updateMatrixWorld( true );
var localPos= B.parent.worldToLocal( A.position );
B.position.copy( localPos );

But the location is still inconsistent
or use getWorldPosition()If there are multiple levels, the returned world position is not correct

Any chances to create a live example that shows what you are trying to achieve? In this way, it’s easier to provide feedback.

I wrote a demo in
Please help!,thank you

Are you looking for something like that?

thank you very much!

sorry!:grinning: rotation and scale how to synchronize?

Read something like this, chapter “1.3 Invert transformations” in order to understand the code.