pmndrs/leva

Number decimal values

cptSwing opened this issue · 2 comments

I am trying to display more than two decimal values in a number input field (three would be enough), would I have to create my own plugin or am I missing something?

My schema is as follows:

roughness: {
                    label: 'Roughness',
                    value: materialOrig.roughness,
                    min: 0,
                    max: 1,
                    step: 0.001, // TODO how to show more decimal values?
                    onChange: (val: number) => {
                        materialClone.roughness = val;
                        advanceFrame(1);
                    },
                    transient: false,
                },

Naively I thought maybe a number's decimal display would be dependant on the step value, but well it isn't :)
I'm not a fully accomplished dev by any means, so writing a plugin seems to be a little overwhelming to me. Cheers for any clarification!

I was just running into a similar issue myself and this worked for me:

Try using the pad property. E.g.

property: {
      value: 0.85,
      min: 0.02,
      max: 0.1,
      step: 0.005,
      pad: 3,
    }

I was just running into a similar issue myself and this worked for me:

Try using the pad property. E.g.

property: {
      value: 0.85,
      min: 0.02,
      max: 0.1,
      step: 0.005,
      pad: 3,
    }

Lovely, worked exactly as advertised - cheers!