Best approach for scaling an object with a fixed position

Hi!
I am looking for the best approach regarding scaling an object relative to a specific position of another object. To illustrate this, I have the following image:

The tilted object with the square hole represents the parent object. The smaller object is the child object. In this image, the smaller object is positioned correctly (Fixed to the top of the square hole)

However, it is possible to tilt the bigger object even further, by changing a slider value:

To have the smaller object always aligned perfectly (fixed to the top of the square hole), I am right now gradually:

  • Scaling the y axis
  • Bringing the y position back (since scaling in babylon apparently moves its position?)
  • Adjusting the z pose gradually (since the position of the top of the open hole is not always on the same z axis when adjusting the tilt)

I am looking for a better approach, the current solution imo is a bit too fragile on certain tilt degrees:

Hi @mehdielbouzidi!

Try this PG:

The main thing is to define the Axis of the object in your modeling software

Hope it helps

2 Likes

Hi @DRLeria! Thank you for your solution. Looks promising!

Will try this out tomorrow, thanks in advance!

:+1:

Else, you can still reset the pivot in BJS (but the solution above is easier and most recommendable)

1 Like