I am attempting to set the parent of a child mesh, and my goal is to have the original “appearance” of the child mesh preserved. In other words, the global scale, position, and rotation of the child should not change.
Generally speaking, calling
child.setParent(parent) works, and the correct calculations are done to make the child’s scaling, position, and rotation relative to the parent, but this is not working when the parent is non-uniformly scaled AND rotated along some axis.
Note in this example, everything works as expected:
Despite the fact that the parent is non-uniformly scaled and rotated on the Y axis, the child mesh’s scaling, position, and rotation remain correct after the call to
setParent. (You can comment and uncomment line 30 in the playground to verify this.)
Now, consider this playground example, where the parent is rotated on X axis instead:
Now, the scaling and rotation of the child are not preserved properly and it is warped. Note that even in the first playground, you can get results like this by changing the rotation of either the child and the parent to certain values.
This seems like a common problem others would encounter. Is there some obvious or easy way to overcome it? Thank for any help that can be provided!