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

Entity clicked event #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SebastianCrow
Copy link

Hi,

I found ability to react on entity click crucial for my project so I think it could be useful to contain it in default verlet-js behaviour.
I've added entityClicked event and also made few performance improvements in nearestEntity function:

  1. selectionRadiusSquare computed at the beginning to avoid computations in every loop
  2. traditional for instead of for...in
  3. breaking last loop after successful PinConstraint finding (further looping is not needed)

Hope you'll enjoy it

Best Regards :)

1. Event “entityClicked” is triggered after clicking entity
2. selectionRadiusSquare introduced (to avoid computations in every
loop)
3. Traditional loops instead of for…in (performance gain)
4. Break final loop after finding matching PinConstraint (to avoid not
needed further processing)
if (nearest) {
var event = new CustomEvent("entityClicked");
event.entity = nearest;
this.dispatchEvent(event);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this fire on the canvas?

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

Successfully merging this pull request may close these issues.

3 participants