dimforge / rapier.js

Official JavaScript bindings for the Rapier physics engine.
https://rapier.rs
Apache License 2.0
413 stars 57 forks source link

Adjust local anchors of a ball joint #55

Open Chargeuk opened 2 years ago

Chargeuk commented 2 years ago

Hi, I was wondering if it would be possible to adjust the local_anchor1 and local_anchor2 values of a ball joint after the joint had been created? I have been digging through the code, but do not know the rust language. It seems that the anchors are simply defined within the ball joint class, but I do see that other classes take copies (or references?) to their values. If a method to change the anchors was added to the ball joint, would the changed value be used throughout the system? And then could this method be exposed via the JavaScript interface? Many thanks, Rapier looks like an awesome physics engine.

jcyuan commented 2 years ago

i think you can't modify it after the creation.

Chargeuk commented 2 years ago

Hi @jcyuan - I did actually locally make this change and it worked fine. However, that was before the large number of changes made by @sebcrozet in version 0.8.x so my changes are not mergeable with the code as it stands. Once 0.8 is out of alpha I will try to make the changes again and open a pull request against the official repo so everyone could benefit (assuming it still works).

jcyuan commented 2 years ago

Hi @jcyuan - I did actually locally make this change and it worked fine. However, that was before the large number of changes made by @sebcrozet in version 0.8.x so my changes are not mergeable with the code as it stands. Once 0.8 is out of alpha I will try to make the changes again and open a pull request against the official repo so everyone could benefit (assuming it still works).

sounds great~ thanks. (assuming it still works), yep, you could test it first though lol. 👍

Chargeuk commented 2 years ago

Hi @jcyuan - I've opened a pull request to expose the Rapier methods that change the local anchor points within Rapier.js. I also exposed the method to change the joint limits. Please note that I am in no way a Rust dev, so I hope what I've done is ok. Pull request here: https://github.com/dimforge/rapier.js/pull/149