pmndrs / use-cannon

👋💣 physics based hooks for @react-three/fiber
https://cannon.pmnd.rs
2.74k stars 154 forks source link

Replace useEffect with useLayoutEffect #299

Closed alexandernanberg closed 2 years ago

alexandernanberg commented 2 years ago

useEffect wont run before rendering the scene, so there is a flash of content without physics. This is particularly visible when using useRaycastVehicle (wheels have wrong placement/rotation for a second).

Is there a reason to not use useLayoutEffect instead? If not I can create a PR

drcmda commented 2 years ago

where? i thought its already using uLE. go ahead and then let's review the pr.

alexandernanberg commented 2 years ago

hmm replaced all uE with uLE locally and saw the same issue, plus that other things broke. So not related I guess, will keep investigating a bit but closing this issue