# Rotate camera about point in Makie 3D scene

**URL:** <https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [April 1, 2021, 12:02am UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337 "2021-04-01T00:02:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [April 1, 2021, 12:02am UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337/1 "2021-04-01T00:02:32Z")

</div>

This is what I’ve got for keeping my 3D scene pointed at the origin. It seems a bit janky, is there a better way?

```julia
function lookcenter(scene, stopper)
  @async begin
    while !stopper[] && isopen(scene)
      sleep(0.25)
      ep = scene.camera.eyeposition[]
      update_cam!(scene, ep, Vec3f0(0))
    end
  end
end

stopper = Ref(false)
lookcenter(scene, stopper)

# to end the task later:
stopper[] = true

```

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [April 1, 2021, 4:56pm UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337/2 "2021-04-01T16:56:36Z")

</div>

`cam3d_cad!` may do what you want. It does not translate the lookat when zooming, only when right-click dragging. You can use one of:

- `fig, ax, p = scatter(rand(Point3f0, 10), camera=cam3d_cad!)`
- `ax = LScene(..., scene_kw=(camera=cam3d_cad!,))`
- `cam3d_cad!(ax.scene)`

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [April 1, 2021, 5:40pm UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337/3 "2021-04-01T17:40:37Z")

</div>

I tried that and it doesn’t quite do what I want, as it’s too easy to translate and once that happens it’s hard to get back to where I started.

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [April 1, 2021, 6:01pm UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337/4 "2021-04-01T18:01:02Z")

</div>

You can adjust `pan_button` as a keyword argument to `cam3d_cad!`. I think the way it’s implemented you could set it to `Keyboard.left_control`, for example, and it would trigger when you press left control and hold any mouse button down. There’s also `move_key` which is an additional you’d have to press, though that applies to both rotating and panning.

---

<div class="post-metadata">

**Author:** ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)\
**Post date:** [April 1, 2021, 8:34pm UTC](https://discourse.julialang.org/t/rotate-camera-about-point-in-makie-3d-scene/58337/5 "2021-04-01T20:34:02Z")

</div>

Thanks, that works!

Relatedly, I’d like if possible to have zooming via the mouse (2-finger drag up/down, equivalent to mouse wheel) also not modify the lookat position. Or maybe better would be for it to operate along the vector from eyeposition to lookat position.

Obviously it can be done with Observables but that seems like an option of last resort.

Edit: Actually, never mind. I was using `cam3d!` not `cam3d_cad`. With the latter it has the zoom behavior I’m looking for.
