Usage
Custom Stiffness
Props
Spring stiffness multiplier. The actual force is
(mouseWorld - grabPoint) * body_mass * stiffness.Show a red arrow indicating the drag direction and force magnitude.
How It Works
- Ctrl/Cmd + Click on a body starts the drag
- The component raycasts to find the clicked body and grab point
- Each frame, a spring force is computed:
F = (mouseWorld - grabWorld) * mass * stiffness - The force is applied via
useBeforePhysicsStep, adding toqfrc_applied - Releasing the mouse ends the drag
Notes
- Forces are applied in the
useBeforePhysicsStepcallback, composing correctly with other force sources - The arrow visual is a Three.js
ArrowHelperupdated each frame - Body 0 (world body) cannot be dragged