pmndrs / use-cannon

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

Lessen the jittering of the blocks #240

Open Theonlyhamstertoh opened 3 years ago

Theonlyhamstertoh commented 3 years ago

This issue is connected with #177.

According to this issue on cannonjs , this jittering of objects also exists in cannonjs. I examine the jenga example in cannon-es and after some time, the jenga example will fall, so also exists in cannon-es.

I did a test in this demo sandbox using use-cannon and cannon-es and you can see that the use-cannon blocks are still jittering after landing on ground. I increase gravity to -100 to make it more apparent on the movement. The result is that both are moving with close inspection of the blocks but the blocks in use-cannon are much more strong than the movement in cannon-es.

If you were to subscribe to the use-cannon block with api, velocity never reaches zero.

If the vibration of the blocks exists in all three packages, then is it possible to lessen the jittering in use-cannon?

calvind777 commented 3 years ago

I'm not super familiar with this project so I'm not sure why this happens, but this exact same issue happened to me when upgrading to 2.6.0 from 2.2.0. For a quick fix, you could try downgrading to 2.2.0.

danfmn commented 2 years ago

I'm also experiencing this issue. I've noticed that depending on the force of gravity, that will determine how jittery or shaky the objects will be. Setting the gravity to 0 removes the jitter, however is not ideal in most cases. I've attempted adjusting properties related to sleeping, however none seem to have an impact. I've also attempted to downgrade to 2.2.0 and the issue persists. Is there any follow up in regards to this issue?

Here's a video https://streamable.com/9gw04z Notice how there is no shaky when there is no collision, however as soon as the boxes hit the plane, the boxes shake. ( The movement is intentional steering behavior, however it's being poorly effected by the bouncing. )

drcmda commented 2 years ago

@bjornstar @codynova this was also reported on discord,

Hello everyone! 👋

I'm facing weird performance issues when updating packages: react-three-fiber -> @react-three/fiber use-cannon -> @react-three/cannon older version of @react-three/drei

It's happening when changing camera position and rotation same time.

Expected (first part of the video): Smooth render without stuttering.. This is the case when using "react-three-fiber": "^6.0.13", "use-cannon": "^0.5.3" and "@react-three/drei": "^3.8.6" Application: (https://codesandbox.io/s/minecraft-forked-qrjq5)

Result (second part of the video): With new updated packages changing camera position and rotation same time renders with weird stuttering. It's using latest packages: "@react-three/cannon": "4.0.1", "@react-three/fiber": "7.0.17" and "@react-three/drei": "7.3.1" Application: (https://codesandbox.io/s/minecraft-new-packages-b5efn)

Any idea what would cause this? Code-wise nothing has changed.. Only packages updated.

https://codesandbox.io/s/minecraft-forked-qrjq5 (no vibration) https://codesandbox.io/s/minecraft-new-packages-b5efn (vibration) found it! it's in cannon between v0.5.4 -> v0.5.5 @paulhenschel most likely this: https://github.com/pmndrs/use-cannon/pull/160

something about a fixed time step. the change is between 0.5.4 and 0.5.5

https://user-images.githubusercontent.com/2223602/142944958-421701c0-6680-4c0d-a1b4-30dcf4de11ed.mov

bjornstar commented 2 years ago

@bjornstar @codynova this was also reported on discord,

Hello everyone! 👋 I'm facing weird performance issues when updating packages: react-three-fiber -> @react-three/fiber use-cannon -> @react-three/cannon older version of @react-three/drei It's happening when changing camera position and rotation same time. Expected (first part of the video): Smooth render without stuttering.. This is the case when using "react-three-fiber": "^6.0.13", "use-cannon": "^0.5.3" and "@react-three/drei": "^3.8.6" Application: (https://codesandbox.io/s/minecraft-forked-qrjq5) Result (second part of the video): With new updated packages changing camera position and rotation same time renders with weird stuttering. It's using latest packages: "@react-three/cannon": "4.0.1", "@react-three/fiber": "7.0.17" and "@react-three/drei": "7.3.1" Application: (https://codesandbox.io/s/minecraft-new-packages-b5efn) Any idea what would cause this? Code-wise nothing has changed.. Only packages updated.

https://codesandbox.io/s/minecraft-forked-qrjq5 (no vibration) https://codesandbox.io/s/minecraft-new-packages-b5efn (vibration) found it! it's in cannon between v0.5.4 -> v0.5.5 @paulhenschel most likely this: #160

something about a fixed time step. the change is between 0.5.4 and 0.5.5

r3f-performance-issue.mov

This was reported as issue #293