How can we find the position of an object relative to some ancestor? This would be sort of like decomposing matrixWorld, but instead of being relative to the root node (Scene) I’m looking to have it be relative to some ancestor that isn’t the root node.
Maybe, I can temporarily place the ancestor node in another non-rendered Scene, update world matrices, then once I have that I can place it back into the original Scene. I haven’t tried it yet, but I can imagine a downs side of this approach would be that it will calculate world transforms of all nodes that are under the ancestor node.
Is there another way that is more efficient that only involves the single branch from ancestor to object of interest?
How can we do this?
Assume that the object has also arbitrary rotation in any of it’s ancestors all the way up to the target ancestor. So all the rotations affect the object’s final position. For example, suppose we have this branch:
o ancestor \ \ o / o \ o object whose position we want relative to ancestor \ / \ / o
If there’s no rotation in any nodes of the branch, obviously we just add the positions and we’ll get the final result. How do we take into account rotation?