The culprit here is that the tangent directions for friction are computed wrong in 3D. For the initial contact, one of them is pointing along the contact normal, while the other is close to zero.
Solution
Fix the tangent directions. This turned out to be just a dumb sign error...
This changes 3D behavior quite a bit, but it's for the better. Friction and bounces are more realistic, and stacking is more stable. Bounces behave correctly:
(note, the initial angular velocity is slightly different here than in the earlier example, it looks better for the README)
Objective
Fixes #489.
Friction in 3D currently behaves very unrealistically. In the README's example, the cube should bounce to the side as it lands on a corner:
Instead, the cube bounces up a bit, spins in the air, and falls in the middle of the platform.
And in a case with locked rotation and zero restitution, friction also causes a weird upward bounce:
https://github.com/user-attachments/assets/0eec421c-741e-4639-b74e-ee3c16cc6cc5
The culprit here is that the tangent directions for friction are computed wrong in 3D. For the initial contact, one of them is pointing along the contact normal, while the other is close to zero.
Solution
Fix the tangent directions. This turned out to be just a dumb sign error...
This changes 3D behavior quite a bit, but it's for the better. Friction and bounces are more realistic, and stacking is more stable. Bounces behave correctly:
(note, the initial angular velocity is slightly different here than in the earlier example, it looks better for the README)