0

enter image description here

I added inseam inch value 31.8 as default value but it show 32. This is my code.

var params = { Inseam: 0, inseamarea:31.8, }; var gui = new GUI(); var folder = gui.addFolder( 'Morph Targets' );

          folder.add( params, 'Inseam', -1, 1 ).step( 0.1 ).onChange( function ( value ) {                    
              params.inseamarea = 31.8 +(1.4 * value);                    
          } );
          folder.add(params, "inseamarea", 31.8).name("Inseam Inch ").listen();

I want value in float but it show in integer. I found a link which i followed. https://jsfiddle.net/prisoner849/514d4kmy/ and this is my fiddel link where i added my code in same place. https://jsfiddle.net/kwdphca0/

M -
  • 26,908
  • 11
  • 49
  • 81
Deepak3301086
  • 447
  • 2
  • 23

1 Answers1

2

You should simply use step(), e.g. :

folder.add(params, "inseamarea", 31.8).step(0.1).name("Inseam Inch ").listen();

https://github.com/dataarts/dat.gui/blob/master/API.md#numbercontroller--datcontrollerscontroller :

if minimum and maximum specified increment is 1% of the difference otherwise stepValue is 1

EDIT : If you want to disable this controller :

let ctrl = folder.add(params, "inseamarea", 31.8).step(0.1).name("Inseam Inch ").listen();
ctrl.domElement.style.pointerEvents = "none";
soju
  • 25,111
  • 3
  • 68
  • 70
  • I tried according to you. but issue comes, that i want to display the calculated value here, not the value which is increase according to step – Deepak3301086 Dec 06 '19 at 10:17
  • I don't understand your comment... `inseamarea` will be updated depending on `Inseam` value as intended. – soju Dec 06 '19 at 10:26
  • Sorry for misunderstanding. Yes it's working for me. Thanks you so much. – Deepak3301086 Dec 06 '19 at 10:36
  • Is it possible that user can't change value of inseamarea box manually. I means, can we disable this textbox. – Deepak3301086 Dec 06 '19 at 10:52
  • https://stackoverflow.com/questions/38602189/dat-gui-looking-for-a-way-to-lock-slider-and-prevent-updating-of-values-with-m/38776709 – soju Dec 06 '19 at 11:02