# Makie - Camera position

**URL:** <https://discourse.julialang.org/t/makie-camera-position/69243>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 5, 2021, 4:45pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243 "2021-10-05T16:45:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kang\_Pyo\_So](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kang_pyo_so/32/26391_2.png) [@Kang\_Pyo\_So](https://discourse.julialang.org/u/Kang_Pyo_So)\
**Post date:** [October 5, 2021, 4:45pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243/1 "2021-10-05T16:45:19Z")

</div>

Hi Everyone,

i have been using the Makie for a while. particularly, I like the 3D reconstruction function.  
the 3D reconstructive function allow me create the color code 3D plot from the 3D electron microscopy.  
however, few month ago, the cameracontrol function start to not work. I’m not sure if syntax changed or any other modification needed?  
i have been spending some time to ask different people including julia slack #helpdesk.  
but, not clear solution for it. can anyone help with it?

here is my original code that has been working perfectly.

```julia
using GLMakie, FileIO, LinearAlgebra, Images

begin
    img = load("CG/200.png")
    #img = Gray.(frame)
    #img = imresize(img, (384, 684))
    w, h = size(img)
    ret = adjust_histogram(img, ContrastStretching(t = 5, slope = 4))
    f(x, y) = img[x,y]
    k = 4
    z = Float32[100f(x,y) for x in 1:k:w, y in 1:k:h]
end
fig = Figure()
#lscene = LScene(fig[1, 1], scenekw = (camera = cam3d!, raw = false))
lscene = LScene(fig[1, 1])
scene = surface(1:k:w, 1:k:h, z, colormap = :Paired_10)

  #control the camera position
   cam = cameracontrols(scene)
            #cam.lookat[] = [0,0,200]
   cam.eyeposition[] = [3000,200,20000]
   update_cam!(scene)

```

thank you  
best  
KP

---

<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:** [October 5, 2021, 10:18pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243/2 "2021-10-05T22:18:08Z")

</div>

I’d guess you’re not passing a `scene` but a Figure, LScene, Axis3 or FigureAxisPlot. You want something like this:

```julia
fig = Figure()
lscene = LScene(fig[1, 1])
# plot! to lscene

scene = lscene.scene
# camera stuff

```

If that’s not it, it might because the more recent camera changes. Though I don’t think it would mess with something like this. You could try a more direct

```julia
cam = cameracontrols(scene)
update_cam!(scene, cam, Vec3f(3000, 200, 20_000), cam.lookat[])

```

---

<div class="post-metadata">

**Author:** ![Kang\_Pyo\_So](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kang_pyo_so/32/26391_2.png) [@Kang\_Pyo\_So](https://discourse.julialang.org/u/Kang_Pyo_So)\
**Post date:** [October 5, 2021, 11:24pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243/3 "2021-10-05T23:24:45Z")

</div>

> [@ffreyer](#):
>
> `lscene = LScene(fig[1, 1])`

Dear Frederic,

great, thanks for your reply! first of all, I really appreciate your feedback.  
i modified the code with the surface plot but “cam = cameracontrols(scene)” this part is not working.

 ![Screenshot from 2021-10-05 19-18-01](https://global.discourse-cdn.com/julialang/original/3X/3/f/3f36aa6ac1890f3a4698a905cefbf2f52c3b57e0.png)  
here is the snapshot in my workstation.  
would you check what might be wrong?  
it could be a simple problem, but I cannot figure it out from my limited knowledge.  
thanks much in advance  
best  
KP

---

<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:** [October 6, 2021, 9:25am UTC](https://discourse.julialang.org/t/makie-camera-position/69243/4 "2021-10-06T09:25:49Z")

</div>

```julia
fig = Figure()
lscene = LScene(fig[1, 1])
surface!(lscene, ...)

cam = cameracontrols(lscene.scene)
cam.lookat[] = [0, 0, 200]
cam.eyeposition[] = [3000, 200, 2000]
update_cam!(lscene.scene, cam) # not sure if there is a method without cam

Makie.save(..., fig) # fig is the root object

```

---

<div class="post-metadata">

**Author:** ![Kang\_Pyo\_So](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kang_pyo_so/32/26391_2.png) [@Kang\_Pyo\_So](https://discourse.julialang.org/u/Kang_Pyo_So)\
**Post date:** [October 6, 2021, 10:28am UTC](https://discourse.julialang.org/t/makie-camera-position/69243/5 "2021-10-06T10:28:23Z")

</div>

great!! works for me! thanks much

---

<div class="post-metadata">

**Author:** ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Post date:** [October 7, 2021, 1:33pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243/6 "2021-10-07T13:33:32Z")

</div>

Somehow it is not possible to change the up direction using this approach. Here’s a MWE of the problem

```julia
using Makie
using FileIO
using GLMakie

catmesh = FileIO.load(assetpath("cat.obj"))

fig = Figure()
scene = LScene(fig[1, 1])
mesh!(scene, catmesh, shading=true, color = :blue)

cam = cameracontrols(scene.scene)
cam.lookat[] = [0, 0, 200]
cam.eyeposition[] = [3000, 200, 2000]
cam.upvector[] = [0, 1, 0]
update_cam!(scene.scene, cam) # not sure if there is a method without cam

fig

```

---

<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:** [October 7, 2021, 2:34pm UTC](https://discourse.julialang.org/t/makie-camera-position/69243/7 "2021-10-07T14:34:24Z")

</div>

That’s because cats are tiny and executing `fig` at the end re-centers the scene. Try

```julia
using FileIO
using GLMakie

catmesh = FileIO.load(assetpath("cat.obj"))

fig = Figure()
scene = LScene(fig[1, 1], scenekw=(center=false,))
mesh!(scene, catmesh, shading=true, color = :blue)

cam = cameracontrols(scene.scene)
cam.lookat[] = [0, 0, 200] ./ 1000
cam.eyeposition[] = [3000, 200, 2000] ./ 1000
cam.upvector[] = [0, 1, 0]
update_cam!(scene.scene, cam)

fig

```
