I noticed an issue when using the Cannon Physics Plugin, where the physics body never goes to a sleep state. To demonstrate this, please check the following playground:
In cannon the body apparently falls to sleep when the angular and directional velocity stay under a threshold for a some time. To debug I printed both the internal velocity and the one on the babylon physics impostor and additionally the cannon sleep state. The sleep state never changes from 0 to 1 or 2 (which would be sleepy or sleeping). Both velocities are the same but thereās something weird going on. Even though the sphere is not moving, the velocity never really drops below 0.02 (to be precise it might drop to 0.004 but would actually increase to something around 0.02 on the next frame):
It makes perfect sense, the physics body never falls asleep, since the per default settings the treshold needs to be below 0.01 for at least 1 second. Please note Iām deliberately ignoring the angular velocity in all cases.
I created a simliar example with cannon-es, which is not the version babylonjs is using, but should not make any differences. To reproduce I did the following:
there has been reports of sleep issue with ammo too, perhaps related? Although, if i remember correctly, raggar said that an older version of ammo fixed the problem, which, at least for that case, seems like it may not be the bjs plugin.
side note, cannon-es did have some arbitrary breaking changes, like changing the shape schema to typescript enums from the original js object look up. they also removed a method that had an alias, because it had a comment over it that was like ātodo , removeā. I know this because I rewrote the original cannon to esm/typescript. I have a copy somewhere anyone wants it
I get different āstabilizedā velocity depending on gravity and physics time step.
The small velocity difference is due to the sphere penetrating a little in the ground, and the ground responding.
This said, even when setting linear velocity to 0, I donāt get the impostor to go to sleep.