How to move/scale objects only in the ground area?

Hello guys. Need some help from you. Here is my playground https://www.babylonjs-playground.com/#E3G5C7

As you can see I have a ground with one object on it - a sphere with bounding box. The object can be scaled and moved all directions around. But I’d like somehow to limit it, I mean the object is allowed to be moved only, let’s say, in the box - with the ground-side (a box with side length as ground length ground box :slight_smile: )
And scaled as well in the box - it should not be possible to scale the object above/below the box.

I realle appreciate any kind of help. Thank you in advance

Hi @mst_shav and welcome to the community.
As far as I can see it is a case of measuring the position and dimensions of the object against the position and size of the box.

Hi John
Do u mean minimum/minimumWorld things (as redSphere.getBoundingInfo().boundingBox.minimumWorld.y etc.)?

Yes so you want always want box.minimum.y < obj.minimum.y etc.

1 Like