play3d {rgl} | R Documentation |
play3d
calls a function repeatedly, passing it the elapsed
time in seconds, and using the result of the function to
reset the viewpoint. movie3d
does the same, but
records each frame to a file to make a movie.
play3d(f, duration = Inf, dev = rgl.cur(), ...) movie3d(f, duration, dev = rgl.cur(), ..., fps = 10, movie = "movie", frames = movie, dir = tempdir(), convert = TRUE, clean = TRUE, verbose=TRUE, top = TRUE)
f |
A function returning a list that may be passed to par3d |
duration |
The duration of the animation |
dev |
Which rgl device to select |
... |
Additional parameters to pass to f . |
fps |
Number of frames per second |
movie |
The base of the output filename, not including .gif |
frames |
The base of the name for each frame |
dir |
A directory in which to create temporary files for each frame of the movie |
convert |
Whether to try to convert the frames to a single GIF movie, or a command to do so |
clean |
If convert is TRUE , whether to delete the individual frames |
verbose |
Whether to report the convert command and the output filename |
top |
Whether to call rgl.bringtotop before each frame |
The function f
will be called in a loop with the first argument being the time in
seconds since the start (where the start is measured after all
arguments have been evaluated).
play3d
is likely to place a high load
on the CPU; if this is a problem, calls to Sys.sleep
should be made within the function to release time to other processes.
movie3d
saves each frame to disk in a filename of the form "framesXXX.png", where
XXX is the frame number, starting from 0. If convert
is TRUE
, it
uses ImageMagick to convert them to an animated GIF. Alternatively, convert
can be a command to execute in the standard shell (wildcards are allowed).
All work is done in the directory dir
, so paths are not needed in
the command.
The top=TRUE
default is designed to work around an OpenGL limitation:
in some implementations, rgl.snapshot
will fail if the window
is not topmost.
This function is called for the side effect of its repeated calls to f
.
It returns NULL
invisibly.
Duncan Murdoch, based on code by Michael Friendly
spin3d
and par3dinterp
return functions suitable
to use as f
. See demo(flag)
for an example that modifies the
scene in f
.
open3d() plot3d( cube3d(col="green") ) M <- par3d("userMatrix") play3d( par3dinterp( userMatrix=list(M, rotate3d(M, pi/2, 1, 0, 0), rotate3d(M, pi/2, 0, 1, 0) ) ), duration=4 ) ## Not run: movie3d( spin3d(), duration=5 ) ## End(Not run)