Skip to content

Conversation

@almarklein
Copy link
Collaborator

@almarklein almarklein commented May 26, 2025

  • Get it to draw a polygon.
  • Triangulation.
  • Selection.
  • Decide on interaction model.
image

@ivoflipse
Copy link

Next up, add morphing 😎

@almarklein
Copy link
Collaborator Author

add morphing

That's worthy of a separate lib :)

@ivoflipse
Copy link

You already have gfxmorph 🤣

@almarklein
Copy link
Collaborator Author

This is nearly done, but the ux needs some thought and work. I'm thinking something like this:

  • User clicks points to create the polygon. Optionally start with existing polygon.
  • Once created, vertices can be dragged.
  • Clicking on an edge will split it in two, creating an extra vertex.
  • Double-clicking on inside the polygon will delete and let the user create a new polygon.

@kushalkolar
Copy link
Member

kushalkolar commented Jun 29, 2025

This is nearly done, but the ux needs some thought and work. I'm thinking something like this:

  • User clicks points to create the polygon. Optionally start with existing polygon.
  • Once created, vertices can be dragged.
  • Clicking on an edge will split it in two, creating an extra vertex.

All this sounds good to me!

  • Double-clicking on inside the polygon will delete and let the user create a new polygon.

I think this should be explicitly called, or via imgui right click menu. Or clicking on the fill area selects the polygon and presing the "Del" key deletes it.

@almarklein
Copy link
Collaborator Author

almarklein commented Jul 4, 2025

Interaction done! Slightly different than I said earlier:

  • Can initialize the tool with an initial selection.
  • If the initial selection is empty, enter polygon creation mode.
  • Can also call start_new_polygon() to clear the current polygon and draw a new one.
  • When creating a new polygon, clicking adds a vertex. Clicking on the first vertex again will finish the polygon.
  • When created, the vertices can be dragged. When dragged on top of a neighbouring polygon, it will be deleted.
  • When clicking/dragging on a line, a new vertex is inserted.

edit: in the above, a snapping visualization is applied to help the user understand that the vertex will be "merged" with the vertex under the mouse.

@almarklein almarklein marked this pull request as ready for review July 4, 2025 12:41
@almarklein
Copy link
Collaborator Author

I just learned about bermuda, a triangulation lib implemented in Rust, a spin-off of the Napari project. We could try and see if it helps here. It would mean an extra dependency, so maybe not use it unless we need it. But we can at least do some quick benchmarks and add a note, so that in case we do need more speed, we know how to get it.

self.geometry,
pygfx.PointsMaterial(size=vertex_size, color=vertex_color, pick_write=True),
)
self._points.local.z = 0.01 # move it slightly towards the camera
Copy link
Member

Choose a reason for hiding this comment

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

I do this often! Is 0.01 the best way to do it? I usually do 0.5

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It depends on the other z-values in your scene, and on the camera depth range settings. From what I understand FPL has layers that are 1.0 apart. I'll change the value above to 0.1; still close to it's original "layer".

@kushalkolar
Copy link
Member

Sorry for the delay in reviewing this, awesome work thanks a lot! 🥳 🥳 . Some minor comments and questions.

@almarklein
Copy link
Collaborator Author

I addressed all comments.

@almarklein
Copy link
Collaborator Author

Need to tweak alpha_mode for the worldObjects used in the selectors, but I propose we first merge this (if you're happy), and then in #873 I make those adjustments.

@kushalkolar
Copy link
Member

Thanks! I was traveling this weekend so it slipped through.

@kushalkolar kushalkolar merged commit 0293fa3 into main Sep 3, 2025
1 of 52 checks passed
@almarklein
Copy link
Collaborator Author

Thanks! I was traveling this weekend so it slipped through.

No problem. My comment was mainly to suggest a sensible order of merging the prs.

@almarklein almarklein deleted the poly-select branch September 3, 2025 08:03
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.

4 participants