TiagoCavalcante / r3f-native-orbitcontrols

OrbitControls for React Three Fiber in React Native
MIT License
72 stars 10 forks source link

Reset of target on rerender #46

Open Valentin-Rault opened 6 months ago

Valentin-Rault commented 6 months ago

I am using the orbit control in my app and I have a gesture detector wrapped around it to detect tap gestures to add points onto an avatar. When setting my location based on the value of the tap gesture, I trigger a rerender by storing the selected vector in a state. This causes the scope.target to be reset to a new Vector3. Therefore the camera jumps back to position (0, 0, 0) if I had done a pan gesture prior to it.

I am not sure of the extends of changing this behavior, but storing the target as a ref seems to be solving my issue without creating any unwanted behaviour