How to correct the slider control for dragging plane in the direction of its normal

I am trying to pick meshes by pointer pick and then place a plane on the top of the mesh that I have picked. This is working well but apart from this I want to control the position of the added plane with a slider once the plane is locked to a surface.

Ideally, I want the plane to translate in the direction of its normal.

https://playground.babylonjs.com/#5B0900#12

But the slider logic is seemingly wrong as I am doing too many translations!
Can you suggest a better way for a more intuitive slider-based dragging of the locked plane?

Hello and welcome to the Babylon community! What do you mean by “too many translations”? Do you mean the plane is moving too far when you move the slider?

Thanks for welcoming :slight_smile: @carolhmj .
Yes exactly @carolhmj , that is correct.

You can decrease the translation distance in the translate function.

The slider gets an initial value of the ‘d’ of the plane. That is the rest configuration of the plane.
Now when I am translating the value of the slider along the direction of the plane, the translations are getting compounded!

Any suggestions for that?

Translate by a fixed distance instead of d?

Ok That makes sense. The sign of the fixed value say ‘0.01’ is a function of the sign of the value of the slider?

I’m not sure if a slider would be the best GUI element for your case? Moving a value on a slider implies increasing some value, but if you want the value to change a fixed time for each interaction, a button would make more sense.

You are correct , I actually want to drag the plane with scroll

That’s where I would use step on the slider control. You can have a fixed value for each step. Should do the trick, shouldn’t it?