With this little Bonito app, how can I call update_cam! after the plot is rendered on the client?
julia> App() do session
button = Button("reset cam")
fig = Figure()
ax = LScene(fig[1, 1])
scatter!(ax, randn(10), randn(10), randn(10))
on(button.value) do _
# this should be called after the plot is done rendering:
update_cam!(ax.scene, Vec3f(1), Vec3f(0), Vec3f(0,0,1))
end
return DOM.div(button, fig)
end
Why do you need to call update_cam! after rendering? Does it error if you do it before, or simply not work? Or do you need to update the cam after rendering for another reason?
I have a 3d plot and there are a couple of issues:
On my computer the plot doesn’t rotate around the origin after the first load. It is just slightly out of balance and the plot wobbles around when rotating (it is a sphere).
On a colleague’s computer the z-Axis is not straight any more after a while. I can observe the same behavior for me but very rarely and usually if there is some kind of reload happening while I rotate the plot.
using Bonito, WGLMakie
App() do session
button = Button("reset cam")
fig = Figure()
ax = LScene(fig[1, 1])
scatter!(ax, randn(10), randn(10), randn(10))
reset = Observable(false)
connect!(reset, button.value)
on(reset) do _
# this should be called after the plot is done rendering:
update_cam!(ax.scene, Vec3f(1), Vec3f(0), Vec3f(0, 0, 1))
end
js = js"""
$(fig.scene).then(s=> $(reset).notify(true))
"""
return DOM.div(button, fig, js)
end
You can just interpolate the values/observables into javascript.
If you interpolate a scene into js, it returns a promise which will get resolved as soon as the scene is fully loaded.
Regarding the rotation issue, I think I know what causes it:
It is a 3d object with a texture that takes some time to compute and transmit.
The texture updates.
During the time the texture updates, the 3d graphic is unresponsive and if you drag it, it looses its center and the z-axis does not point upward any more. The more you drag it during the unresponsive phase, the worse it gets.