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, type = "gif")par3df.convert is TRUE, whether to delete the individual framesconvert command and the output filenamergl.bringtotop before each framef.
It returns NULL invisibly.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 a single file, by default an animated GIF.
The type argument will be passed to ImageMagick to use as a file extension
to choose the file type.
Alternatively, convert can be a template for a command to
execute in the standard shell (wildcards are allowed). The template is
converted to a command using sprintf(convert, fps,
frames, movie, type, dir, duration). For example, code=TRUE
uses the template "convert -delay 1x%d %s*.png %s.%s". All work
is done in the directory dir, so paths should not be needed in
the command. (Note that sprintf does not require all
arguments to be used, and supports formats that use them in an
arbitrary order.)
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.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 )
movie3d( spin3d(), duration=5 )Run the code above in your browser using DataLab