duplicate of Makie - Testing GLMakie with correct ReferenceTests - #2 by sdanisch
“Minimal code changes necessary” — this whole restructuring broke almost every line of my mesh-animation code…
Can you share what you’ve run into?
I don’t think we made any big changes, besides the big Vec3f0 → Vec3f conversion, which should be easily fixable with the script from: https://github.com/JuliaGeometry/GeometryBasics.jl/pull/97#issue-714149607
It might be a later version (apparently v0.15 is the current one).
Anyway my old code is:
scene = Scene(
show_axis = false,
resolution = (1920, 1080)
)
camera(scene)
mesh!(
Mesh(drop.mesh),
#color = RGBAf0(0, 0, 1, 0.5),
color = :blue,
shading = true,
)
xs = -1.5:1e-2:1.5
r0 = center_of_mass(drop)
surface!(
xs,
xs,
zeros(Float32, length(xs), length(xs)),
color = [
convert(
RGBAf0,
mycmap(90 / 360 * 2pi)
) for x in xs, y in xs
],
shading = false
)
update_cam!(scene, cameracontrols(scene), Vec3f0(2.5, 0, 1), Vec3f0(0), Vec3f0(0, 0, 1))
scene |> display
record(
scene,
joinpath(trajectory.datapath, "anim3d.mp4"),
-30:2:1000,
framerate = 30
) do t
i = findlast(<=(t), trajectory.times)
i = isnothing(i) ? -1 : i
t, (drop, subs) = trajectory[max(1, i)]
r0 = center_of_mass(drop)
scene.plots[1].input_args[1][] = Mesh(drop.mesh)
if i > 0
scene.plots[2][:color] = [
convert(
RGBAf0,
target_angle(drop, subs, t, SVector(x, y, 0), r0) |> mycmap
) for x in xs, y in xs
]
else
scene.plots[2][:color] = [
convert(
RGBAf0,
mycmap(90 / 360 * 2pi)
) for x in xs, y in xs
]
end
end
I got it mostly working again like so:
#fig = Figure()
#ax = Axis3(fig, show_axis = false, resolution = (1920, 1080))
#cam = Camera3D(fig.scene)
fig, ax, drop_plot = mesh(
Mesh(drop.mesh),
#color = RGBAf0(0, 0, 1, 0.5),
color = :blue,
#colormap = (:white, :white),
shading = false,
figure = (resolution = (1920, 1080),),
#lightposition = Vec3f0(0, 1, 2),
#diffuse = Vec3f0(0.5, 0.5, 0.5),
#ambient = Vec3f0(0.5,0.5,0.6),
#shininess = 128f0,
)
xs = -1.5:1e-2:1.5
r0 = center_of_mass(drop)
subs_plot = surface!(
xs,
xs,
zeros(Float32, length(xs), length(xs)),
color = [
convert(
RGBAf0,
mycmap(90 / 360 * 2pi)
) for x in xs, y in xs
],
shading = false
)
scene = fig.scene
#update_cam!(scene, cam, Vec3f0(2.5, 0, 1), Vec3f0(0), Vec3f0(0, 0, 1))
#scene |> display
Makie.get_scene(fig) |> display
record(
fig,
joinpath(trajectory.datapath, "anim3d.mp4"),
-120:10:2000,
framerate = 30
) do t
i = findlast(<=(t), trajectory.times)
i = isnothing(i) ? -1 : i
t, (drop, subs) = trajectory[max(1, i)]
r0 = center_of_mass(drop)
drop_plot.input_args[1][] = Mesh(drop.mesh)
if i > 0
subs_plot.color = [
convert(
RGBAf0,
target_angle(drop, subs, t, SVector(x, y, 0), r0) |> mycmap
) for x in xs, y in xs
]
else
subs_plot.color = [
convert(
RGBAf0,
mycmap(90 / 360 * 2pi)
) for x in xs, y in xs
]
end
end
Notably, update_camera
still doesnt work, and Vec3f
is still Vec3f0
for some reason.
My main gripe is that there is no backwards compatibility, and no obvious place to find what replaced what. It’s just trial and error after each update
It looks like you skipped many major versions, from what I can tell…
This is always a bit of a struggle.
We also have become better at documenting breaking changes in NEWS.md + release notes and be more careful about deprecations - it’s still not perfect, but I’m pretty sure we had worse documentation for the versions you skipped.
Yes, that’s likely true. I avoided updating for a long time because I couldnt afford to break anything.
What’s not working with the old code? Scene
is still around and if you don’t need layouting or an axis it’s not a bad idea to use that.
For the second version you should be using
ax = LScene (fig[1, 1], scenekw = (show_axis = false, ))
...
cam = cameracontrols(ax.scene)
update_cam!(ax.scene, cam, ...)
Axis3 doesn’t have a camera the way scene had and fig.scene is not the 3d scene you’re drawing to.
Thanks. That really begs the question though: Why isn’t fig.scene
the scene that I’m drawing to? Where did I create a different scene?
The figure has its own top level scene with a PixelCamera which means all plot objects there are drawn in 2D, and a line from 0,0 to 100,0 is 100 pixels long. If you place an LScene in the Figure (which you only need because the normal Scene doesn’t have the infrastructure to connect to a layout) then you get a new child scene wrapped in there, accessible under lscene.scene
, and for that you can manipulate the camera however you want. Axis3 is really only for that very specific 3D axis in a layout look.
I think was able to follow that. But I could not make your suggested camera code work and tbh it’s intensely all alienating. Why does the figure come with a PixelCamera that is effectively unusable? (rhetorical question) I think somewhere there needs to be a design document that explains how I’m actually supposed to interact with this labyrinthean system of Cameras, Figures, Scenes, Axes, Layout, etc. It’s impenetrable (even for someone who has already worked a lot with PyPlot and Plots.jl)
Maybe it would be more goal oriented to open specific issues in the Makie repo or here in separate threads. Reviving an older topic such as this for voicing your frustration with the package doesn’t really lead to actionable improvements I fear. A lot of effort went into the documentation that explains the connection between the parts you have trouble with, so opening docs issues or PRs that relate to those specific points would be highly appreciated.
Right now I’m trying to make a heatmap using Makie, but the plots are upside down. How can I reverse the y-axis?
There’s an example of the different orientation options here image