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

Strange behavior when inspecting lines in WGLMakie #3672

Closed
kbarros opened this issue Mar 3, 2024 · 8 comments · Fixed by #4282
Closed

Strange behavior when inspecting lines in WGLMakie #3672

kbarros opened this issue Mar 3, 2024 · 8 comments · Fixed by #4282
Labels
bug GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. interaction anything event related planning For discussion and planning development WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@kbarros
Copy link
Contributor

kbarros commented Mar 3, 2024

This is a follow-on to #3503. Not an immediate blocker for us; we've moved away from WGLMakie due to multiple issues (SunnySuite/Sunny.jl#211). GLMakie gives an overall more robust experience, and we're happy with it.

The following snippet leads to strange behavior, as shown in the movie below.

using WGLMakie
begin
    segments = Point2f[(0, 0), (0, 1), (1, 0), (1, 2)]
    color = [:red, :black, :blue, :black]
    inspector_label(_, i, _) = (@show Int(i); ["hello", "world", "nice", "day"][mod1(i, 4)])
    fig, ax, pl = linesegments(segments; color, inspector_label, linewidth=10)
    DataInspector(ax)
    display(fig; backend=WGLMakie)
end
2D_example.mov
@kbarros kbarros added the bug label Mar 3, 2024
@t-bltg t-bltg added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Mar 3, 2024
@kbarros
Copy link
Contributor Author

kbarros commented Mar 24, 2024

If anyone else encounters this, a workaround for us was to use arrows instead of linesegments. Setting arrowsize = 0 draws just the line part of an arrow, as a cylinder. With arrows, the inspector pop-up works well in both GLMakie and WGLMakie.

@EdsterG
Copy link
Contributor

EdsterG commented Aug 6, 2024

Seems like the index returned by pick_closest differs between GLMake and WGLMakie and the ray tracing code has an offset that only works with GLMakie indexing.

What WGLMakie version did you record your video with?

@kbarros
Copy link
Contributor Author

kbarros commented Aug 8, 2024

I tried again just now with the master versions of WGLMakie, Bonito, etc. There is still some strange behavior, but not as strange as before. Mousing over the red segment is now fixed: It shows a hover window with the text "hello" in the right position. Mousing over the blue segment now correctly shows a hover window with the correct text "nice". However, in the second case, the "nice" hover is in the wrong the position (it shifts leftward as the mouse position is raised vertically).

@EdsterG
Copy link
Contributor

EdsterG commented Aug 8, 2024

The position is due to the “wrong” index returned by pick_closest.

@SimonDanisch
Copy link
Member

Yeah the shaders in WGLMakie and GLMakie work a bit different and its hard to do exactly the same thing in them for the index.
And it was also not 100% clear to me which is the better behaviour.
Maybe we should first figure out the correct behaviour for the returned index and then figure out how to change (W)GLMakie.

@EdsterG
Copy link
Contributor

EdsterG commented Aug 8, 2024

IMO WGLMakie has the "correct" behavior. When mousing over the first line it returns index 1 and mousing over the second line index 3. While GLMakie returns 2/4 respectively.

@EdsterG
Copy link
Contributor

EdsterG commented Aug 8, 2024

However, I don't think it really matters what behavior they have as long as they're consistent. Consistency is more important than picking the more convenient implementation detail.

@ffreyer
Copy link
Collaborator

ffreyer commented Aug 8, 2024

It wouldn't be hard to have the index be the nearest line point either, because we already have a value for color interpolation along the line. I.e. have

-----------------
X    X     X    X  linepoints
-----------------
11122222233333444  picked index

as the output. Though maybe it's better to always get the start index of a line segment so that it is consistently given as ps[idx], ps[idx+1].

@ffreyer ffreyer added interaction anything event related GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. planning For discussion and planning development labels Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug GLMakie This relates to GLMakie.jl, the OpenGL backend for Makie. interaction anything event related planning For discussion and planning development WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants