nartc / angular-three

🧊 THREE.js integration for Angular 🧊
https://angular-three.netlify.app/
MIT License
306 stars 26 forks source link

[Feature] cannon constraint equation multiplier #98

Closed IRobot1 closed 2 years ago

IRobot1 commented 2 years ago

While converting cannon-es tear example, the code accesses the equations property and multiplier.

According to the cannon documentation, this properly is common to all constraints.

This is a request to add support for accessing either the equations and/or multiplier value.

If there another way to get multiplier value using existing features, let me know.

nartc commented 2 years ago

I think there should be a way to get the data. The problem is that we're using Cannon Worker API which is a Web Worker implementation. The data, if available at all, would be in asynchronous state.

Can you look at https://cannon.pmnd.rs/ and see if there's any example that might be similar to tear?

IRobot1 commented 2 years ago

There might be an existing way to achieve this. Looks like there's a multiplier that can be declared with the constraint. I'll investigate using that and follow up.

IRobot1 commented 2 years ago

Adjust the maxMultiplier value on distance contraint. Higher values make the bonds/links between bodies stronger

        const constraint = this.physicConstraint.useDistanceConstraint(body.ref, lastBody.ref, {
          distance: this.distance,
          maxMultiplier: 1000, // higher multiplier makes links stronger
        })