schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

After world step query constraint forces? #315

Closed gkovacsds closed 6 years ago

gkovacsds commented 6 years ago

Hello, is there a way to query the force acting on a constraint after the world has stepped? I mean, I'd like to have kind of a virtual measurement device, so for example know how large force is acting on a RevoluteConstraint ("bearing"), or on a PrismaticConstraint that reached its limits and topped out and p2.js is counteracting with a force so it won't get out of the limits. I don't plan to use it a scientific grade measurement tool, but I'd like to see the change/magnitude of these forces in different settings of the scene. Thank you!

schteppe commented 6 years ago

It is possible, yes. See the testable constraints demo: https://github.com/schteppe/p2.js/blob/master/demos/tearable.html