pmndrs / use-p2

👋💣 2d physics hooks for @react-three/fiber
https://p2.pmnd.rs
MIT License
149 stars 9 forks source link

How to create a basic mouse constraint? #16

Open bmandeberg opened 1 year ago

bmandeberg commented 1 year ago

Hi, I'm trying to create a basic mouse joint so that I can drag objects, similar to this p2 example.

I've had a bit of success with useRevoluteConstraint, but it seems that enable() and disable() aren't actually available in the ConstraintApi returned from the revolute constraint (only seeing motor functions), so I'm unable to disable the constraint while not dragging the mouse. Also, it only really works if I set a different collisionGroup on the mouse body, but then this messes up the collisions on the target body while dragging it. Sleeping/waking the mouse body doesn't seem to help.

Any advice for creating a basic mouse constraint in use-p2 would be greatly appreciated!