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

Simplify the code of the selection example #737

Open
illright opened this issue Feb 26, 2025 · 1 comment
Open

Simplify the code of the selection example #737

illright opened this issue Feb 26, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@illright
Copy link

Is your feature request related to a problem? Please describe.

I want to implement a lasso selection feature similar to what the example has, so I've spent some time studying it but I'm finding the code a bit hard to read due to a lot of things that I have to keep track of in my head.

I would like to be clear that I greatly respect the work you have put in this project and these examples, and this request is entirely in good faith. That said, if I'm overstepping the line, feel free to close this issue, no hard feelings.

Describe the solution you'd like

I could see improvements in the clarity of the example if certain operations were extracted into functions with JSDoc's explaining their function. This would also mitigate a large number of global variables that are only used in specific parts of functionality — scoping them would help the reader to only focus on what's important.

So, my proposal is:

  • group related areas of code in functions with descriptive names (serves as a sort of BVH for code reading :p)
  • add JSDoc docstrings with explanations of functions and argument types
  • move the global variables that are only used in particular functions into these functions
  • add links to this and this to the code — helpful context to understand the high-level algorithm

I would be willing to make a PR with these changes to the "selection" example, since I've spent some time with it, and I feel like I understand what's going on there.

Describe alternatives you've considered

  • creating and uploading a separate example that organizes the code the way I see fit — it probably wouldn't have the same audience, and as such, would have less positive impact
@illright illright added the enhancement New feature or request label Feb 26, 2025
@gkjohnson
Copy link
Owner

gkjohnson commented Feb 27, 2025

Hello! And thanks for the offer - if you'd like help organize some of the code in the selection example that would be great. I don't always have the time or availability to make some of these examples as clear as I'd like so any help is appreciated.

I'm imagining a class for keep tracking of the lasso shape and generating the geometry for it (ie a manager you push the latest mouse points on to) and another helper class for performing the query and returns the requisite information that takes the information about the lasso shape. I'm open to any other suggestions, as well.

Glad to see the example has been useful, as well!

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