How do I close rgl X11 windows?

I want to create 3D animation with a package rgl

. My code looks 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 great and creates a snapshot in a PNG file for each frame. But after that there will be 100 open X11 windows. Another problem is that I am guessing that when many windows are open, the runtime will be too high.

I tried using rgl.close()

and clear3d()

, none of them worked fine (they made the output png files black).

Anyway?

+3


source to share


1 answer


I realized this is an old question, but this is the simple solution I came across to close everything rgl windows

.



while (rgl.cur() > 0) { rgl.close() }

      

+3


source







All Articles