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

Collisions? #280

Closed
oliver-ni opened this issue Mar 24, 2018 · 9 comments
Closed

Collisions? #280

oliver-ni opened this issue Mar 24, 2018 · 9 comments
Assignees
Milestone

Comments

@oliver-ni
Copy link

Is there any way to detect collisions in Two.js?

@jonobr1
Copy link
Owner

jonobr1 commented Mar 24, 2018

What type of collisions are you referring to? Hit detection between mouse and object? Overlapping between two or more paths? Physics or velocity based changes?

@oliver-ni
Copy link
Author

Overlapping between two groups or paths

@jonobr1 jonobr1 added this to the v0.8.0 milestone Mar 25, 2018
@jonobr1 jonobr1 self-assigned this Mar 25, 2018
@jonobr1
Copy link
Owner

jonobr1 commented Mar 25, 2018

Unfortunately this doesn't exist out of the box at the moment. There are a number of workarounds depending on the use case. It is something I'd like to add though!

The current closest pure Two.js way of achieving this is to do a check against the bounding box of shapes ( Two.Shape.getBoundingClientRect ). Unfortunately this won't give you very high accuracy if you were doing a physics simulation.

Another way might be if you're using the svg renderer you can run path._renderer.elem.checkIntersection( someOtherElem );

@oliver-ni
Copy link
Author

Thanks! I will take a look at the methods you described.

@jonobr1
Copy link
Owner

jonobr1 commented Mar 26, 2018

I'm actually gonna keep this open, because I do want to add this into Two.js in the future.

@jonobr1 jonobr1 reopened this Mar 26, 2018
@jonobr1
Copy link
Owner

jonobr1 commented May 17, 2018

I believe the functionality in 270 will cover this functionality as well. Closing as a duplicate. Thanks for reporting!

@jonobr1 jonobr1 closed this as completed May 17, 2018
@toramanlis
Copy link

Unfortunately this doesn't exist out of the box at the moment. There are a number of workarounds depending on the use case. It is something I'd like to add though!

The current closest pure Two.js way of achieving this is to do a check against the bounding box of shapes ( Two.Shape.getBoundingClientRect ). Unfortunately this won't give you very high accuracy if you were doing a physics simulation.

Another way might be if you're using the svg renderer you can run path._renderer.elem.checkIntersection( someOtherElem );

I can't help but speak about this response.

More often than not, in github issues, maintainers don't even bother to read a question and just barf a generic response, let alone providing a solid workaround like this.

This here is one of the best attitudes I've ever seen here. You took it seriously, possibly took your time to think about it and even though nobody would blame you if you just said there was no such feature, you gave a solution.

Moreover you wanted this thread to be open because you wanted to work on this. I think this mindset will help you achieve a lot. Cheers

@JorensM
Copy link

JorensM commented Nov 7, 2023

Don't think this has been implemented yet?

@jonobr1
Copy link
Owner

jonobr1 commented Nov 7, 2023

It has not, but you can follow the progress of the canonical issue here: #596

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants