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.
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
I’d guess you’re not passing a scene
but a Figure, LScene, Axis3 or FigureAxisPlot. You want something like this:
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
cam = cameracontrols(scene)
update_cam!(scene, cam, Vec3f(3000, 200, 20_000), cam.lookat[])
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.
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
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
great!! works for me! thanks much
Somehow it is not possible to change the up direction using this approach. Here’s a MWE of the problem
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
1 Like
That’s because cats are tiny and executing fig
at the end re-centers the scene. Try
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
1 Like