Dragging of floor

Hi all,

Can anyone help me in the scenario where I want to restrict the user to drag the floor by using bounding box gizmo if its reached below threshhold level of floor length and floor width?

Thanks in advance :slight_smile:

(you need to define variables)

let allowFloorDrag = true;

scene.registerBeforeRender(function () {
	if (floorLength < lengthThreshold || floorWidth < widthThreshold) {
		allowFloorDrag = false;
	}
});

Then add in your dragging function the bool check: if (allowFloorDrag) and so on.

1 Like

Thanks @labris but Can you please provide any playground example so that it will be easy to understand?

Have a look - https://playground.babylonjs.com/#SG9ZZB#13

xLowerThreshold = 0.8;
xUpperThreshold = 1.3;

scene.registerBeforeRender(function () {
	
    if (sphere.scaling.x < xLowerThreshold) {
        sphere.scaling.x = xLowerThreshold;
        console.log("xLowerThreshold");
    }
    if (sphere.scaling.x > xUpperThreshold) {
        sphere.scaling.x = xUpperThreshold;
        console.log("xUpperThreshold");
    }
 
});
2 Likes

Thanks @labris I will look into that.