pmndrs / use-cannon

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

Updating mass not working #144

Closed wiledal closed 3 years ago

wiledal commented 3 years ago

Problem

Calling api.mass.set(x) after a body is created does nothing.

Possible solution

Add call to body.updateMassProperties() around here: https://github.com/pmndrs/use-cannon/blob/master/src/worker.js#L238

As per documentation: https://schteppe.github.io/cannon.js/docs/classes/Body.html#method_updateMassProperties

Franckapik commented 3 years ago

I have changed the setMass function according to @wiledal solution. It's working by setting shape type to 1 (dynamic) https://github.com/Franckapik/use-cannon/blob/update_mass/src/worker.js#L240

Thank you for your message here !! It help me a lot !

rrelmy commented 3 years ago

@stockHuman Is there a reason the version (v0.5.4) with this fix is not yet published on npmjs?

stockhuman commented 3 years ago

Hi @rrelmy. Yes, the package was renamed in September, to match others as a @react-three family. Per the first line in the readme: yarn add @react-three/cannon will pull from npmjs. In the future, you'll see a deprecation warning when installing use-cannon.