Child mesh distorts and stretches to match parent scaling after rotation

  • Steps to reproduce:

    • Create a mesh
    • Scale it to an uneven proportion (for example: (10,1,1))
    • Create another mesh and set the previous mesh as a parent
    • Rotate the child mesh in an axis perpendicular to the previous scaling (so, for example, rotate in ANYTHING BUT the (1,0,0) axis for a (10,1,1) scaling)
  • I have done some testing and built this playground:
    Babylon.js Playground

As you can see, the cone mesh maintains the right proportions if left without rotation, but after rotating it, it warps and stretches out to match the parents scaling, reaching the maximum level of distortion at 90 degrees. (Rotating it in the (0,1,0) axis doesn’t distort it as the x and z scaling is the same.)

  • Using rotationQuaternion, rotate() or directly assigning values to the rotation vector doesn’t seem to make a difference.

  • Checking the inspector shows no changes in the child’s scaling property, but logging the “mesh.absoluteScaling” property, it reports that the absolutescaling is being modified.

  • I have also tried setting the mesh’s parent to null, rotating, then setting it back to the other mesh, but the result is that the child mesh starts scaling up exponentially up to infinity, as illustrated in this other playground (i have changed it to rotate every time a left click is performed on the scene, instead of every frame, to make it possible to see what is happening):

Hi and welcome to the Community,
I’m not sure what you are expecting just exactly but I can try answer the title of your post.
In short, the answer is ‘YES’. When parenting to a mesh or a node (abstract or transform) any change made to the parent after parenting will be affecting all children. This is an expected behavior. Now (again I’m not sure what you are trying to achieve), but there are a number of ways around this. The one I personally (with my small ‘designer’ brain :wink:) use the more often, is that I create a transformNode or an abstractMesh to rule the mesh or hierarchy. Means I’m using an imbrication of parented nodes and I scale only the parent where I want my children to scale (or rotate or position).
I’d leave the first parent (transform or abstract) at normal scaling and then for each object or group of objects within this parent, I create a new parent node and apply my rotation, scaling, position,etc… for this parent and all its children.

As I said, there are other methods. I’ll let someone else tell you about those (since as I said, I don’t know what you want to achieve). Still hope this helps (else, let us know).
Meanwhile again, welcome to the Community and have a great day :sunglasses:

The issue is not that the child inherits the parent scaling and rotation. Look at what happens:

  • I scale the parent before parenting the child mesh.

  • I use the .setParent() method so the child keeps the original position, scaling and rotation after being parented with the object.

  • I start rotating the child object, not the parent, and after rotating it distorts itself, depending on which direction it is facing.

Yes, depending on the situation, you can do a workaround by parenting both objects to a different object, but that would defeat the purpose since the object then becomes a sibling of the original parent object, instead of the child, and it would screw up the hierarchy for me.

I posted this on bug reports since this doesn’t seem to be the intended behaviour.

P.S: Thanks for the help anyways.

It seems it’s the same problem than in Rotation and scaling of child not preserved properly when parent is non-uniformly scaled and rotated or Distortion occurs when the mesh is moved from the world coordinate system to another non-uniformly scaled mesh - #2 by Evgeni_Popov.

The outcome is that we would probably need to support shear deformation in our transformations, but this is not something we plan to do, as it would represent a huge change in the code base. Handling non-uniform scaling is always a problem and should be avoided if possible…


Thanks. I didn’t realize there was a similar topic open already, i searched for “mesh distortion/warping” and similar wording but didn’t see anything related at first glance.

P.S: I “think” i have some sort of workaround… but it doesn’t cover up for rotating the parent mesh before adding the children (like in the example you have mentioned)

Making a new transformNode, placing it in the childs position, then parenting the child to the anchor, and the anchor to the node seems to work somehow. Rotating the child seems to work fine, rotating the anchor warps the shape as usual.

P.S 2: I tried resetting the parent rotation to zero, then adding the children, then setting it back to its original state. It seems to work.

1 Like