如何关闭rgl X11窗口?

时间:2022-10-16 12:02:33

I want to create a 3D animation with rgl package. My code is like this:

我想用rgl包创建一个3D动画。我的代码是这样的:

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.

它工作得很好,并在PNG文件中为每个帧创建一个快照。但在那之后,会有100个打开的X11窗口。另一个问题是,我猜打开许多窗口,运行时间会太高。

I tried using rgl.close() and clear3d(), none of them worked fine (they made the output png files to be black).

我尝试使用rgl.close()和clear3d(),但它们都不能正常工作(它们将输出的png文件设置为黑色)。

Is there anyway?

有呢?

1 个解决方案

#1


3  

I realized this is an old question, but this is the simple solution I came up with to close all rgl windows.

我意识到这是一个老问题,但这是我想到的关闭所有rgl窗口的简单解决方案。

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

#1


3  

I realized this is an old question, but this is the simple solution I came up with to close all rgl windows.

我意识到这是一个老问题,但这是我想到的关闭所有rgl窗口的简单解决方案。

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