This animation of 3D slicing was generated by the following setup of GLMakie observables:
# initialize figures
fig = Figure(resolution = (1000, 500))
ax3d = Axis3(fig[1,1],
elevation = pi/16,
azimuth = -5*pi/8,
viewmode = :fit,
zlabel = "z (cm)",
aspect = (1,1,1))
m = mesh!(ax3d, normal_mesh(F),
color = :chocolate4,
shading = true)
ax2d = Axis(fig[1,2],
limits = (-1,1, -1,1),
xlabel = "x (cm)",
ylabel = "y (cm)")
# plot initial observable data
SEG = fill(NaN32, 3, 3*nF) # line SEGment buffer
MEASURE = zeros(Float32, 2)
zCut::Float32 = 1f0
nCol = zslice(zCut, F, TZ, TI, SEG, MEASURE)
SEG_obs = Observable(SEG)
slice2d = @lift @view $SEG_obs[1:2,1:nCol]
slice3d = @lift @view $SEG_obs[:,1:nCol]
strHeight = @sprintf(
"slice height = %.2f cm\ncircumference = %.2f cm",
zCut, MEASURE[1])
str_obs = Observable(strHeight)
lines!(ax3d, slice3d,
linewidth = 5,
color = :black)
lines!(ax2d, slice2d,
color = :black)
text!(ax2d, str_obs,
position = (0.05, 0.75),
space = :data)
fig
# generate video of slicing
zMax = 2.0
nFrame = 720
record(fig, "sl.mp4", 1:nFrame) do iFrame
ax3d.azimuth[] = -3pi/4 - 2pi*(iFrame-1)/nFrame
zCut = zMax - abs(zMax - 2*zMax*(iFrame-1)/nFrame)
nCol = zslice(zCut, F, TZ, TI, SEG, MEASURE)
notify(SEG_obs)
str_obs[] = @sprintf(
"slice height = %.2f cm\ncircumference = %.2f cm",
zCut, MEASURE[1])
end # for each video frame
The essay now includes that fast 3D slicing example application without PGA. On my laptop computer Makie generates the above 30 second video in 8.2 seconds. I haven’t yet finished the PGA version but I suspect it will be about the same speed, like the other 2D and 3D geometry applications I’ve ported from ganja.js to Julia and Makie.
In dimensions higher than 3D, it is easy to see the advantages of PGA but I haven’t yet encountered a 2D or 3D geometry application that gets faster or simpler using PGA. However, in his demonstration of his origami example application, Steven De Keninck suggests that PGA makes that 3D geometry application “a lot more fun and a lot more easy”, so I am inclined to try porting that ganja.js origami application next.