pmndrs / react-three-rapier

🤺 Rapier physics in React
https://react-three-rapier.pmnd.rs
MIT License
1.07k stars 59 forks source link

Addind feature to apply forces in local space like cannon es #160

Closed AmirHo3einJS closed 1 year ago

wiledal commented 2 years ago

Hey!

Can you explain a bit more what you are expecting from this?

AmirHo3einJS commented 2 years ago

@wiledal Yeah sure, like use-cannon library, when we bind physics world to a three JS object, the API that cannon returns has methods for applyLocalImpulse and applyLocalForce which are applied based on the local space of the object not world space.

fgarrec0397 commented 2 years ago

@AmirHo3einJS not sure what you mean by local space and world space but you can actually apply force on a rigidbody. From your ref on the Rigidbody component just call colliderRef.current.applyImpulse(new Vector3(0, 1, 0));

If you want more documentation, you can in fact see the original Javascript documentation. This library is just a React implementation of it. https://rapier.rs/docs/api/javascript/JavaScript3D

And the RigidBody class https://rapier.rs/javascript3d/classes/RigidBody.html