我想用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"))
}
它工作正常,并在每个帧的PNG文件中创建一个快照。但在那之后,将有100个开放的X11窗口。另一个问题是,我想打开许多窗户的运行时间会太高。
我尝试使用rgl.close()
和clear3d()
,没有一个工作正常(他们使输出png文件为黑色)。
反正呢?
我意识到这是一个老问题,但这是我提出的关闭所有rgl windows
的简单解决方案。
while (rgl.cur() > 0) { rgl.close() }
#rgl.close()...工作正常,并且是自我解释的
3D visualization device system
Description
3D real-time rendering system.
Usage
# Low level rgl.* interface
rgl.open(useNULL = rgl.useNULL()) # open new device
rgl.close() # close current device