From a4a83f58c65f7b499cde533f1cae2d013168b71a Mon Sep 17 00:00:00 2001 From: = Date: Wed, 16 Oct 2024 19:26:14 +0200 Subject: [PATCH 1/3] replace timer with tick events --- src/camera/camera3d.jl | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/src/camera/camera3d.jl b/src/camera/camera3d.jl index bb6412bec52..c26e8816845 100644 --- a/src/camera/camera3d.jl +++ b/src/camera/camera3d.jl @@ -8,7 +8,6 @@ struct Camera3D <: AbstractCamera3D controls::Attributes # Interactivity - pulser::Observable{Float64} selected::Observable{Bool} # view matrix @@ -55,7 +54,6 @@ Settings include anything that isn't a mouse or keyboard button. - `mouse_translationspeed = 0.5` sets the speed of mouse translations. - `mouse_zoomspeed = 1.0` sets the speed of mouse zooming (mousewheel). -- `update_rate = 1/30` sets the rate at which keyboard based camera updates are evaluated. - `circular_rotation = (true, true, true)` enables circular rotations for (fixed x, fixed y, fixed z) rotation axis. (This means drawing a circle with your mouse around the center of the scene will result in a continuous rotation.) ## Controls @@ -163,7 +161,6 @@ function Camera3D(scene::Scene; kwargs...) projectiontype = Makie.Perspective, circular_rotation = (true, true, true), rotation_center = :lookat, - update_rate = 1/30, zoom_shift_lookat = true, fixed_axis = true, cad = false, @@ -185,7 +182,6 @@ function Camera3D(scene::Scene; kwargs...) settings, controls, # Internals - controls - Observable(-1.0), Observable(true), # Semi-Internal - view matrix @@ -204,34 +200,12 @@ function Camera3D(scene::Scene; kwargs...) # Keyboard controls # ticks every so often to get consistent position updates. - on(camera(scene), cam.pulser) do prev_time - current_time = time() - active = on_pulse(scene, cam, current_time - prev_time) - @async if active && cam.selected[] - sleep(settings.update_rate[]) - cam.pulser[] = current_time - else - cam.pulser.val = -1.0 + on(camera(scene), events(scene).tick) do tick + if cam.selected[] + on_pulse(scene, cam, tick.delta_time) end end - keynames = ( - :up_key, :down_key, :left_key, :right_key, :forward_key, :backward_key, - :zoom_in_key, :zoom_out_key, :increase_fov_key, :decrease_fov_key, - :pan_left_key, :pan_right_key, :tilt_up_key, :tilt_down_key, - :roll_clockwise_key, :roll_counterclockwise_key - ) - - # Start ticking if relevant keys are pressed - on(camera(scene), events(scene).keyboardbutton) do event - if event.action in (Keyboard.press, Keyboard.repeat) && cam.pulser[] == -1.0 && - cam.selected[] && any(key -> ispressed(scene, controls[key][]), keynames) - cam.pulser[] = time() - return Consume(true) - end - return Consume(false) - end - # de/select plot on click outside/inside # also deselect other cameras deselect_all_cameras!(root(scene)) @@ -320,6 +294,14 @@ function on_pulse(scene, cam::Camera3D, timestep) tilt_up_key, tilt_down_key, pan_left_key, pan_right_key, roll_counterclockwise_key, roll_clockwise_key, zoom_out_key, zoom_in_key, increase_fov_key, decrease_fov_key ) + + if !ispressed(scene, right_key | left_key | up_key | down_key | backward_key | forward_key | + tilt_up_key | tilt_down_key | pan_left_key | pan_right_key | roll_counterclockwise_key | + roll_clockwise_key | zoom_out_key | zoom_in_key | increase_fov_key | decrease_fov_key) + + return + end + @extractvalue cam.settings ( keyboard_translationspeed, keyboard_rotationspeed, keyboard_zoomspeed, projectiontype ) From 82dde20e01eb1ce0578b943fe6ba5b4b1b40e9c9 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 16 Oct 2024 19:26:38 +0200 Subject: [PATCH 2/3] disable circular rotations byy default --- src/camera/camera3d.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/camera/camera3d.jl b/src/camera/camera3d.jl index c26e8816845..93a73a41ff3 100644 --- a/src/camera/camera3d.jl +++ b/src/camera/camera3d.jl @@ -54,7 +54,7 @@ Settings include anything that isn't a mouse or keyboard button. - `mouse_translationspeed = 0.5` sets the speed of mouse translations. - `mouse_zoomspeed = 1.0` sets the speed of mouse zooming (mousewheel). -- `circular_rotation = (true, true, true)` enables circular rotations for (fixed x, fixed y, fixed z) rotation axis. (This means drawing a circle with your mouse around the center of the scene will result in a continuous rotation.) +- `circular_rotation = (false, false, false)` enables circular rotations for (fixed x, fixed y, fixed z) rotation axis. (This means drawing a circle with your mouse around the center of the scene will result in a continuous rotation.) ## Controls @@ -159,7 +159,7 @@ function Camera3D(scene::Scene; kwargs...) mouse_zoomspeed = 1.0, projectiontype = Makie.Perspective, - circular_rotation = (true, true, true), + circular_rotation = (false, false, false), rotation_center = :lookat, zoom_shift_lookat = true, fixed_axis = true, From ea5e9f2bed7d4662930472933ff49e7e312c8f21 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 16 Oct 2024 20:32:09 +0200 Subject: [PATCH 3/3] update changelog [skip ci] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1b8269163..dddabdc774b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Changed image, heatmap and surface picking indices to correctly index the relevant matrix arguments. [#4459](https://github.com/MakieOrg/Makie.jl/pull/4459) - Improved performance of `record` by avoiding unnecessary copying in common cases [#4475](https://github.com/MakieOrg/Makie.jl/pull/4475). - Fix usage of `AggMean()` and other aggregations operating on 3d data for `datashader` [#4346](https://github.com/MakieOrg/Makie.jl/pull/4346). +- Changed default for `circular_rotation` in Camera3D to false, so that the camera doesn't change rotation direction anymore [4492](https://github.com/MakieOrg/Makie.jl/pull/4492) ## [0.21.14] - 2024-10-11