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

Unsynchronized rotation behavior in WGLMakie #2243

Closed
ddahlbom opened this issue Aug 29, 2022 · 5 comments
Closed

Unsynchronized rotation behavior in WGLMakie #2243

ddahlbom opened this issue Aug 29, 2022 · 5 comments

Comments

@ddahlbom
Copy link

I am finding that different types of objects behave differently under interactive rotations.

For example, if the scene contains lines and scatter points, clicking and dragging will rotate each of these objects differently. Only the lines follow the axis, the scatter points do something else.

Put another way, it's almost as if the image is the superposition of two different camera views, and clicking and dragging moves each camera in a slightly different way.

This does not happen with GLMakie. I only find this with WGLMakie.

Here is a minimal example. This was executed in VSCode on Linux. I found similar results when using the REPL and a browser interface.

using WGLMakie
begin
    fig = Figure()
    ax = LScene(fig[1,1])
    points = WGLMakie.Point3f0.([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0]])
    lines!(ax, points)
    scatter!(ax, points)
    fig
end

Below are screeshots of the initial view, followed by the view after rotation by clicking and dragging.

initial
rotated

@ffreyer
Copy link
Collaborator

ffreyer commented Aug 31, 2022

This might be related to how markerspace and space are handled in WGLMakie. With markerspace = :data the issue goes away (preprojection matrix is identity) and with markerspace = :clip it's also deynchronized. I checked the preprojection matrices generated for the latter case in
https://github.com/JuliaPlots/Makie.jl/blob/bfe128ee1535ad75a4bab6109826caa08ba5f4de/WGLMakie/src/particles.jl#L208-L210
They match ax.scene.camera.projectionview as they should. Maybe there is an issue passing those matrices to javascript?

@SimonDanisch
Copy link
Member

Yeah I think updating the matrices isn't synchronized to the renderloop, and since updating stuff in JS is comparatively slow, this can be noticed in that case.. Not sure if there's a good fix besides optimizing the updates...
Would be worth to see if there are any low hanging fruits in better updating the values.
I don't think synching updates to the renderloop will be viable, since that would be too slow...

@ffreyer
Copy link
Collaborator

ffreyer commented Aug 31, 2022

Actually could it be that ax.scene.camera does not match the camera in the javascript part? I can't rotate the view further from eyepos = +-z for lines (no preprojection) but can for scatter...?

Also this doesn't fix itself over time or when wiggling the camera around. So it's not like some updates don't make it. A desync between ax.scene.camera.projectionview and the view, projection matrices in javascript seems more likely to me

@SimonDanisch
Copy link
Member

Ah... that can also happen for the camera 3d!

@ffreyer
Copy link
Collaborator

ffreyer commented Aug 31, 2022

We should move the preprojection stuff to javascript then. I don't know how to set that up though
https://github.com/JuliaPlots/Makie.jl/blob/bfe128ee1535ad75a4bab6109826caa08ba5f4de/src/camera/projection_math.jl#L313-L341

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

No branches or pull requests

3 participants