Scaling mesh with slider does not work

Hi @ryantrem
I use this example:

I want to scale my mesh:

  function setScalePictures(value: number) {
    setScale(value);
console.log(value);
  }


      <SafeAreaView style={{flex: 1, backgroundColor: "white"}} ref={childRef} >
        <EngineView style={{flex: 1}} camera={camera} onInitialized={onInitialized} />
        <Slider value={defaultScale} onValueChange={setScalePictures} />
      </SafeAreaView>

Hi,
my problem: when I move the Slider, the value is correct e.g. 1.55. As soon as I leave it, the value jumps back to default:

1.55
1.55
1
1
1
1,3
1.3
1
1
1

This would mean setScalePictures is called again with the value 1 I do not think it is a Babylon issue here.

1 Like

That is more of a react question

1 Like

How about using react’s useState and binding it to the slider?
I don’t know how to use your Slider… So just take a look at the logic :smiley:

const [scaleValue, setScaleValue] = useState(defaultScale)

const handleSliderValueChange = (event) => {
  setScaleValue(event.target.value)
}

<Slider value={scaleValue} onValueChange={handleSliderValueChange} />
1 Like

Hey @igorroman777 - the Babylon React Native playground uses a slider to change the scale of the object, so you can take a look at that for a working example: BabylonReactNative/App.tsx at master · BabylonJS/BabylonReactNative · GitHub

1 Like