I want to create a 3D animation with rgl
package. My code is like this:
for (frame in 1:100) {
open3d()
... # run some commands here for plotting, like points3d() or spheres3d()
# Now, save the frame to a png file
rgl.snapshot(paste0("Frame",sprintf("%04d",frame),".png"))
}
It works fine and creates an snapshot in PNG file for each frame. But after that, there would be 100 open X11 windows. The other problem is that I guess with opening many windows the running time would be too high.
I tried using rgl.close()
and clear3d()
, none of them worked fine (they made the output png files to be black).
Is there anyway?
# rgl.close() ... works fine and is self explanatory