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

3D Camera Orientation Widget #2944

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft

3D Camera Orientation Widget #2944

wants to merge 35 commits into from

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented May 11, 2023

Description

Old Description Implements the Widget from #2624, which allows you to orient a 3D axis by clicking on different faces of the mesh, or rotating that mesh with mouse interactions. This will need some adjustments after #2746.

Screenshot from 2023-05-11 21-01-18

I think this looks pretty bad atm so I'm open to suggestions.

Blender has this with only 6 directions, which is a bit too coarse imo.

Maybe this should be similar to the Navball in Kerbal Space Program, which could also double as an (external) axis type thing. To orient the plot we could allow different angular step size, which we could round to on click. (Ignore all the UI around the ball)

This pr is in some sense a continuation/more polished implementation of #2624. The goal is to provide another tool for controlling and understanding the orientation of the 3D camera. I'm taking inspiration from Kerbal Space Program here, which uses a textured ball to represent the orientation of a rocket relative to the planets surface.

Navball

My current Makie version looks like this:

Screenshot from 2023-07-20 17-05-13

The background color choice in KSP, light blue and brown, is probably meant to represent the sky and the ground. (The blue side always faces up). I wanted to avoid dark backgrounds for this, so I switched from brown to green, which I hope still gets that thought across. The green is a bit darker than the blue, so it should still be differentiable with color blindness.

This will need some adjustments after #2746.

TODO:

  • apply rotations of the ball to a linked LScene or Axis3 and vice verse
  • move attributes to Block
  • make a prototype for the Navball version
  • allow this to be detached from layouting
  • allow a detached controller to be draged around in the window
  • add click interactions for focusing a view direction
  • add scroll interactions to adjust the granularity of click interactions
  • cleanup debug printing
  • add different textures for different zoom levels to keep things readable
  • general cleanup

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@MakieBot
Copy link
Collaborator

MakieBot commented May 11, 2023

Compile Times benchmark

Note, 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(display(fig))
using create display create display
GLMakie 3.54s (3.49, 3.60) 0.04+- 396.58ms (389.64, 404.99) 7.06+- 478.24ms (467.52, 492.88) 8.49+- 7.18ms (7.10, 7.27) 0.07+- 25.69ms (25.58, 25.89) 0.10+-
master 3.53s (3.48, 3.56) 0.03+- 383.58ms (316.35, 420.76) 41.84+- 484.63ms (467.09, 520.07) 17.51+- 7.20ms (7.15, 7.23) 0.03+- 25.60ms (25.45, 25.84) 0.12+-
evaluation 1.00x invariant, 0.02s (0.46d, 0.41p, 0.04std) 0.97x invariant, 12.99ms (0.43d, 0.45p, 24.45std) 1.01x invariant, -6.38ms (-0.46d, 0.41p, 13.00std) 1.00x invariant, -0.02ms (-0.41d, 0.47p, 0.05std) 1.00x invariant, 0.08ms (0.73d, 0.20p, 0.11std)
CairoMakie 3.13s (3.06, 3.20) 0.05+- 343.40ms (328.06, 369.80) 14.86+- 149.84ms (143.27, 157.03) 5.49+- 7.62ms (7.37, 7.96) 0.22+- 604.93μs (601.55, 613.51) 4.42+-
master 3.11s (3.05, 3.18) 0.05+- 335.85ms (326.30, 351.52) 9.60+- 146.82ms (143.41, 155.27) 4.55+- 7.39ms (7.26, 7.50) 0.08+- 603.01μs (597.16, 617.20) 7.28+-
evaluation 0.99x invariant, 0.02s (0.45d, 0.42p, 0.05std) 0.98x invariant, 7.55ms (0.60d, 0.28p, 12.23std) 0.98x invariant, 3.02ms (0.60d, 0.28p, 5.02std) 0.97x slower X, 0.23ms (1.35d, 0.04p, 0.15std) 1.00x invariant, 1.92μs (0.32d, 0.56p, 5.85std)
WGLMakie 4.05s (3.90, 4.27) 0.15+- 343.78ms (325.56, 377.35) 18.16+- 9.31s (8.86, 9.94) 0.48+- 10.09ms (9.54, 11.15) 0.59+- 69.36ms (68.07, 70.67) 0.90+-
master 3.90s (3.80, 4.23) 0.15+- 347.79ms (325.87, 394.38) 26.67+- 9.07s (8.85, 9.55) 0.26+- 9.85ms (9.24, 10.62) 0.59+- 70.32ms (67.86, 75.23) 2.58+-
evaluation 0.96x invariant, 0.16s (1.06d, 0.07p, 0.15std) 1.01x invariant, -4.02ms (-0.18d, 0.75p, 22.42std) 0.97x invariant, 0.24s (0.62d, 0.27p, 0.37std) 0.98x invariant, 0.25ms (0.42d, 0.45p, 0.59std) 1.01x invariant, -0.96ms (-0.50d, 0.38p, 1.74std)

@asinghvi17
Copy link
Member

There are some nice textures we could use for a KSP like navball here - all under a FOSS license

@ffreyer
Copy link
Collaborator Author

ffreyer commented May 11, 2023

Oh, cool. I think as a default we'd want a texture with x/y/z marked rather than north, south, etc, but I could try to be compatible with those textures.

@ffreyer
Copy link
Collaborator Author

ffreyer commented May 12, 2023

Navball prototype with a texture from the repo:
Screenshot from 2023-05-12 11-42-12
I think with a (linear) gauge showing the step width rather than the plain text this would be pretty nice.

@asinghvi17
Copy link
Member

I could do a spherical axis instead, that might actually be better since it's more customizable. Will send the code when I can.

@ffreyer
Copy link
Collaborator Author

ffreyer commented May 12, 2023

I was planning to generate a texture with Makie code. That could be customized, though you probably want to do it in CairoMakie because fxaa makes this kinda of ugly in GLMakie.

@ffreyer
Copy link
Collaborator Author

ffreyer commented May 16, 2023

This is how it currently looks: (outdated, see initial post)
Screenshot from 2023-05-16 18-53-53

The texture is generated with the two prs I referenced. The white region marks where you can snap to on click, and it reacts to hovers. The degree indicator appears when you scroll and disappears after 3s

src/layouting/layouting.jl Outdated Show resolved Hide resolved
@ffreyer ffreyer mentioned this pull request Aug 29, 2023
4 tasks
@ffreyer
Copy link
Collaborator Author

ffreyer commented Dec 7, 2023

TODO:

  • Updating img with Sampler(img) does seem to change Sampler.data but creates the same texture as pre-update if that update happens before displaying.
  • Anisotropic filtering doesn't work anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready, but unreviewed
Development

Successfully merging this pull request may close these issues.

None yet

4 participants