Skip to content

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