Hi, I am trying to make the camera (angle) adjustable by both mouse dragging and some UI controls.
However it seems the camera bounce off to inital value whenever I display the value.
I am using react-babylonjs and I suspect this to related to some react update race condition but I couldn’t sort it out.
Whenever you call setNum, you update the state on the Component, and with that, the camera’s position and target are reset to the values you specified. You can “save” the values you need by using refs: codesandbox-react-tsx (forked) - CodeSandbox
Didn’t realized I have to keep setTarget as a var/ref, because strangely the camera can rotate if the setNum is commented out.
Now I think about it, it was working becase the babylon camera control is independent from React update loop, and the setNum causes an React update and flushes the value back to declarated value lol.