Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cannon bodies to CollideEvent #380

Open
ffdead opened this issue Apr 29, 2022 · 3 comments
Open

Add cannon bodies to CollideEvent #380

ffdead opened this issue Apr 29, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@ffdead
Copy link

ffdead commented Apr 29, 2022

I'm looking for a way to reset the position of an InstancedMesh when it collides with a ground plane. So when it collides, I would want to update the position and velocity of that instance's physics body.

But it seems there is no way to get the current instance index from the onCollide callback. Similar question here: #106

Would it be possible to directly expose the physics bodies in addition to the Object3D in the CollideEvent?

@ffdead ffdead changed the title Add cannon bodies to collide event Add cannon bodies to CollideEvent Apr 29, 2022
@isaac-mason
Copy link
Member

isaac-mason commented May 26, 2022

Adding the instance index in the onCollide callback sounds like a doable change.

Unfortunately exposing the cannon-es physics bodies isn't possible though, as the bodies are created inside a web worker.

@isaac-mason isaac-mason added the enhancement New feature or request label May 26, 2022
@isaac-mason
Copy link
Member

If you're referring to exposing the physics body APIs returned from the body hooks, that would be doable! Just dawned on me that you might be referring to that.

@ffdead
Copy link
Author

ffdead commented May 27, 2022

If you're referring to exposing the physics body APIs returned from the body hooks, that would be doable! Just dawned on me that you might be referring to that.

Ah yes, I think that would be enough - sorry for being unclear. The purpose would be to be able to reach to a colllision event and add forces manually or modify the position of the bodies that collided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants