-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Add zooming & translation controls to Axis3 #4131
Conversation
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
|
Zooming for Axis3 is basically just shrinking |
I don't know yet. In the prototype code it is, but I don't know if that's a good way to do it. that code was really just to test if |
# TODO: This crashes? But is also necessary... | ||
for i in max(0, N):7 | ||
glDisable(GL_CLIP_DISTANCE0 + UInt32(i)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure in what context this was crashing but it's not crashing anymore on my laptop or PC.
Without this turning clip_planes on once will turn them on forever, with random data. This causes plots to disappear randomly. Maybe this should be a hotfix instead of being part of this pr...
I realized that I could also just reuse the
Also did a bit of cleanup and fixed a rendering bug caused by |
Which comes from just doing xyz/w in inversions. This is not valid if w <= 0, at least with perspective projection
I took the easy way out and just moved them to 3D space/ |
@@ -390,7 +393,7 @@ function project(proj_view::Mat4{T1}, resolution::Vec2, point::Point{N, T2}) whe | |||
# at this point the visible range is strictly -1..1 so FLoat64 doesn't matter | |||
p = (clip ./ clip[4])[Vec(1, 2)] | |||
p = Vec2{T}(p[1], p[2]) | |||
return (0.5 .* (p .+ 1) .* (resolution .- 1)) .+ 1 | |||
return 0.5 .* (p .+ 1) .* resolution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tick alignment with frame lines got worse when I moved the frame to data space. So I spent too long trying to figure out why.
I thought it might be a Float32 vs Float64 thing, so cleaned up the remaining Float32 types in Axis3. Didn't help. I tried forcing lines to convert on the CPU to make sure conversions don't happen till the end. Didn't help.
Then I got frustrated and moved the CairoMakie line point projection to Makie so I could revert moving the frame to data space without having clipping issues. And the alignment issues were still there. Then I tried using that code for ticks as well and it finally went away.
So i tried to figure out why and started comparing. Didn't notice the resolution - 1
. Noticed that clip space points were very different, due to the CairoMakie code clipping to a -1..1 box. So I changed things up to avoid it and there was still a 0.5-1px difference. And then I finally noticed this line, changed it and I the issue seems to be fixed now.
Anyway, fixes #3302.
I'm not sure if I like the translation feature because you cannot really control which axes get translated how much when dragging over a 2D plane. I guess I would put that one behind the ctrl key if at all |
You mean the one that has also been added for |
The WGLMakie failure is just a refimg I forgot to update |
* update CI * update versions * dont test on branch push (already runs for prs against master) * fix versions * Updates for GeometryBasics refactor (#4319) * get Makie to compile * get GLMakie to compile * fix nromal rename, meshscatter * fix pointtype in mesh conversion * avoid matrix in vector rotation * fix more tests * update GeometryBasics functions/interface * fix voronoiplot clipping * update CairoMakie * update RPRMakie * prepare WGLMakie * Update CI to use the GeometryBasics refactor branch (#4326) * Update ci.yml * Update Docs.yml * Update reference_tests.yml * add MeshIO branch --------- Co-authored-by: ffreyer <[email protected]> * update _faces * normals -> normal * add ShaderAbstractions to ci * update docs, normals deprecation * fix branch names * fix catmesh getting normals regenerated * update for ShaderAbstractions * handle voxel clipping in CairoMakie like in GLMakie * fix another two "normals" * add dev branches for RPRMakie CI * fix missing kwarg name in conversion * update for FaceViews * add example for per-face colors and normals * improve typing * fix Sampler, allow mipmap via Sampler * try to fix benchmarks * add to correct env * remove from master project * fix docs * fix Rect decomposition * fix poly converts * fix typo * improve precompilation by avoiding constprop and more direct icon loading via PNGFiles * fix CairoMakie precompile * fix old syntax * fix ambient light * add temp dependencies to relocatbility test * bump RPR to required version * update changelog * fix test * fix other branch in ray cast test * fix relocatability ci * fix rpr and relocatability --------- Co-authored-by: Anshul Singhvi <[email protected]> Co-authored-by: SimonDanisch <[email protected]> * rename clear_faceviews * update GeometryBasics dev branch * update CI * more CI bumps * fix relocatibility CI * fix 2x2 surface * fix CairoMakie * fix WGLMakie 2x2 surface * fix picking tests * remove reliance on Rect mesh generation * Metamesh and multi mesh loading (#4496) * prototype `mesh(::MetaMesh)` * tweak default color handling * add refimg test * add docs * add fallback for MetaMesh * update CI dependencies * try matching file without capitalization * fix CairoMakie, WGLMakie test errors * exclude from CairoMakie --------- Co-authored-by: ffreyer <[email protected]> * rename Tesselation -> Tessellation (#4564) * try fix benchmark * regenerate bundled * update Changelog [skip CI] * allow GeometryBasics 0.5 [skip ci] * Change automatic color generation for Voronoiplot (#4357) * Chane color generation * Changelog --------- Co-authored-by: Simon <[email protected]> Co-authored-by: Frederic Freyer <[email protected]> * add precompile for refreshcallback * try gc() between compile timings * update GeometryBasics, MeshIO versions * update ShaderAbstractions & CI * remove branches from relocatability * remove dev branches from docs * Split marker_offset from quad_offset (#4594) * split marker_offset from quad_offset * add test * fix typo * add 3D tests * fix FastPixel scaling with marker_offset in data space * improve test, remove old * fix CairoMakie image scatter offset * tweak test some more * test marker_offset with 2D and 3D rotations * fix 2D rotation + marker_offset + Rect in CairoMakie * exclude 3D test in CairoMakie * fix test error * 1.6 compat * update changelog * add attribute example * remove TODO * Add `transform_marker` attribute to meshscatter (#4606) * add transform_marker attribute * add refimg test * update changelog * allow mesh with no normals in mesh3d path * cleanup mesh3d transformation pipeline * add test * apply f32c.scale to meshscatter vertices in GLMakie, WGLMakie * fix WGLMakie * tweak test to include significant float32convert scaling * fix voxels * remove f32c + transform func tests (doesn't check what its supposed to) * fix wrong order for f32convert and model * fix double translation with transform_marker = true * fix unwanted model application with transform_marker = false * make limits static in test * test model + transform_marker with f32c and transform func * update and test boundingbox with transform_marker * Makie.rotate! * remove initial refimg test * update changelog * fix missing newline * fix deprecated normals * Add zooming & translation controls to Axis3 (#4131) * zoom prototype * add zooming as an Interaction * add limit reset * add translation * make translation more accurate * add docstrings * fix x/y/z reversed * update changelog [skip ci] * move code to the right places * fix corrupted gl state * fix CairoMakie text - clip planes interaction * remove comment * reuse and conform to existing infrastructure * add docs for Axis3 interactions * add unit tests & fix zoom coordinate system * do plot picking ray cast as part of :cursor zoom * remove old code * match zoom direction with Axis, LScene * update tests * add viewmode = :free * tweak refimg to include perspectiveness and be less wide * fix some test failures * revert change to decorations * fix backend dependency of new refimg * fix var name in new test * avoid rendering issues from too small near * skip irrelevant code for viewmode = :free * fix aspect problems with translations * cleanup some stuff * reuse in-axis translations for viewmode = :free * add center-on-cursor interaction * fix limit reset not resetting targetlimits * fix position_on_plot error for 2D meshes * move framelines to 3D scene to avoid line inversion issue Which comes from just doing xyz/w in inversions. This is not valid if w <= 0, at least with perspective projection * use Float64 * bandaid fix for render order * Change LimitReset to more closely match Axis * update docs * fix offset between ticks and grid/frame * fix test error * add test for project(scene, point) * add option to clip decorations (default on) * use viewport for clipping * don't clip decorations by default because it clips titles and too much of labels/tick labels * make test more robust --------- Co-authored-by: Simon <[email protected]> * Fix Float32 constraints in poly pipeline (#4615) * Fix Float32 constraints in poly pipeline Also fix dimensionality constraints * changelog * Update poly.jl * Update poly.jl --------- Co-authored-by: Simon <[email protected]> * try fixing memory leak * aggressively clean up objects * check screen outside animationframe + upload electron logs in CI * Clean up CI + CHangelog * Update CHANGELOG.md --------- Co-authored-by: Anshul Singhvi <[email protected]> Co-authored-by: SimonDanisch <[email protected]> Co-authored-by: Daniel VandenHeuvel <[email protected]>
* Added field fullbox to controll if the full box of Framelines is drawn. Added fields xspinecolor_4, yspinecolor_4 and zspinecolor_4 to control the color of the 4th line when the fullbox is drawn. * Renamed function to_topscene_z_2d into to_topscene_small_z_2d. Createted function to_topscene_big_z_2d to project points into parent space with a big z value * Renamed varaiable framepoints to framepoints_main. Added variable fraimpoints_fullbox replicating the functionality of assining to framepoints_main using p7 and p8 and the function to_topscene_big_z_2d. Added an if statement to add the front lines of the fullbox if the field fullbox od Axis3 is true. * Correctet/removed coments * Added spinecolor_4 to theme_black. * Create the fullbox lines anyway, just controll visibility by ax.fullbox && attr(:spinesvisible). * Changed the name "fullbox" into "front_spines" * spine_color * Update CHANGELOG.md * update CI * update versions * dont test on branch push (already runs for prs against master) * fix versions * Updates for GeometryBasics refactor (#4319) * get Makie to compile * get GLMakie to compile * fix nromal rename, meshscatter * fix pointtype in mesh conversion * avoid matrix in vector rotation * fix more tests * update GeometryBasics functions/interface * fix voronoiplot clipping * update CairoMakie * update RPRMakie * prepare WGLMakie * Update CI to use the GeometryBasics refactor branch (#4326) * Update ci.yml * Update Docs.yml * Update reference_tests.yml * add MeshIO branch --------- Co-authored-by: ffreyer <[email protected]> * update _faces * normals -> normal * add ShaderAbstractions to ci * update docs, normals deprecation * fix branch names * fix catmesh getting normals regenerated * update for ShaderAbstractions * handle voxel clipping in CairoMakie like in GLMakie * fix another two "normals" * add dev branches for RPRMakie CI * fix missing kwarg name in conversion * update for FaceViews * add example for per-face colors and normals * improve typing * fix Sampler, allow mipmap via Sampler * try to fix benchmarks * add to correct env * remove from master project * fix docs * fix Rect decomposition * fix poly converts * fix typo * improve precompilation by avoiding constprop and more direct icon loading via PNGFiles * fix CairoMakie precompile * fix old syntax * fix ambient light * add temp dependencies to relocatbility test * bump RPR to required version * update changelog * fix test * fix other branch in ray cast test * fix relocatability ci * fix rpr and relocatability --------- Co-authored-by: Anshul Singhvi <[email protected]> Co-authored-by: SimonDanisch <[email protected]> * rename clear_faceviews * update GeometryBasics dev branch * update CI * more CI bumps * fix relocatibility CI * fix 2x2 surface * fix CairoMakie * fix WGLMakie 2x2 surface * fix picking tests * remove reliance on Rect mesh generation * Metamesh and multi mesh loading (#4496) * prototype `mesh(::MetaMesh)` * tweak default color handling * add refimg test * add docs * add fallback for MetaMesh * update CI dependencies * try matching file without capitalization * fix CairoMakie, WGLMakie test errors * exclude from CairoMakie --------- Co-authored-by: ffreyer <[email protected]> * rename Tesselation -> Tessellation (#4564) * try fix benchmark * regenerate bundled * update Changelog [skip CI] * allow GeometryBasics 0.5 [skip ci] * Change automatic color generation for Voronoiplot (#4357) * Chane color generation * Changelog --------- Co-authored-by: Simon <[email protected]> Co-authored-by: Frederic Freyer <[email protected]> * add precompile for refreshcallback * try gc() between compile timings * update GeometryBasics, MeshIO versions * update ShaderAbstractions & CI * remove branches from relocatability * remove dev branches from docs * Split marker_offset from quad_offset (#4594) * split marker_offset from quad_offset * add test * fix typo * add 3D tests * fix FastPixel scaling with marker_offset in data space * improve test, remove old * fix CairoMakie image scatter offset * tweak test some more * test marker_offset with 2D and 3D rotations * fix 2D rotation + marker_offset + Rect in CairoMakie * exclude 3D test in CairoMakie * fix test error * 1.6 compat * update changelog * add attribute example * remove TODO * Add `transform_marker` attribute to meshscatter (#4606) * add transform_marker attribute * add refimg test * update changelog * allow mesh with no normals in mesh3d path * cleanup mesh3d transformation pipeline * add test * apply f32c.scale to meshscatter vertices in GLMakie, WGLMakie * fix WGLMakie * tweak test to include significant float32convert scaling * fix voxels * remove f32c + transform func tests (doesn't check what its supposed to) * fix wrong order for f32convert and model * fix double translation with transform_marker = true * fix unwanted model application with transform_marker = false * make limits static in test * test model + transform_marker with f32c and transform func * update and test boundingbox with transform_marker * Makie.rotate! * remove initial refimg test * update changelog * fix missing newline * fix deprecated normals * Add zooming & translation controls to Axis3 (#4131) * zoom prototype * add zooming as an Interaction * add limit reset * add translation * make translation more accurate * add docstrings * fix x/y/z reversed * update changelog [skip ci] * move code to the right places * fix corrupted gl state * fix CairoMakie text - clip planes interaction * remove comment * reuse and conform to existing infrastructure * add docs for Axis3 interactions * add unit tests & fix zoom coordinate system * do plot picking ray cast as part of :cursor zoom * remove old code * match zoom direction with Axis, LScene * update tests * add viewmode = :free * tweak refimg to include perspectiveness and be less wide * fix some test failures * revert change to decorations * fix backend dependency of new refimg * fix var name in new test * avoid rendering issues from too small near * skip irrelevant code for viewmode = :free * fix aspect problems with translations * cleanup some stuff * reuse in-axis translations for viewmode = :free * add center-on-cursor interaction * fix limit reset not resetting targetlimits * fix position_on_plot error for 2D meshes * move framelines to 3D scene to avoid line inversion issue Which comes from just doing xyz/w in inversions. This is not valid if w <= 0, at least with perspective projection * use Float64 * bandaid fix for render order * Change LimitReset to more closely match Axis * update docs * fix offset between ticks and grid/frame * fix test error * add test for project(scene, point) * add option to clip decorations (default on) * use viewport for clipping * don't clip decorations by default because it clips titles and too much of labels/tick labels * make test more robust --------- Co-authored-by: Simon <[email protected]> * Fix Float32 constraints in poly pipeline (#4615) * Fix Float32 constraints in poly pipeline Also fix dimensionality constraints * changelog * Update poly.jl * Update poly.jl --------- Co-authored-by: Simon <[email protected]> * try fixing memory leak * aggressively clean up objects * check screen outside animationframe + upload electron logs in CI * Clean up CI + CHangelog * Update CHANGELOG.md * fix merge, cleanup * add refimg test * add Sphere to verify z-order and check for artifacts * fiddle with rendering so that WGLMakie, CairoMakie order frame lines correctly without GLMakie, WGLMakie artifacting + tweak test --------- Co-authored-by: ffreyer <[email protected]> Co-authored-by: Simon <[email protected]> Co-authored-by: Anshul Singhvi <[email protected]> Co-authored-by: Daniel VandenHeuvel <[email protected]>
Description
Now that #3958 has been merged we can implement zooming and translation for Axis3 without data spilling out of he Axis limits.
Old Description
I don't aim to work on this immediately. Instead I'm hoping that this pr can spark some discussions on how zooming and translations should work with Axis3, so that the end result is more polished.Some questions:
Camera3D
/LScene? E.g.:I extended the following interactions to work with Axis3:
ScrollZoom
which comes withx/y/zzoomlock
andx/y/zzoomkey
Axis3 attributes like Axis does, and additionally azoommode
which controls whether zoom is centered on the Axis3 area (default) or on the cursor (1)DragPan
which comes withx/y/ztranslationlock
andx/y/ztranslationkey
rather than...pan...
as pan technically refers to a rotation of the camera.LimitReset
(1) "zoom centered on the cursor" really means that we want to keep a point under the cursor at the same location as we zoom in or out. With perspective projection in 3D this depends on the depth value of the point, which changes as we zoom. Without knowing exactly where that point is, we cannot fulfill that condition. And even if we ray-cast to find the coordinate, another point at a different depth that initially overlapped will move away as we zoom. Because of that I think it's better to just zoom towards the well-defined center.
TODO:
maybe add interaction for "center on clicked object"Discuss whether clipping related changes count as breaking or bug fixesI think it doesn't actually change anything...?Related issues: #3792, #1655, #1667
Type of change
Checklist