Play animation of rgl scene

Share:

Description

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.

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

type

What type of movie to create. See Details.

Details

The function f will be called in a loop with the first argument
being the startTime plus 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.

play3d will run for the specified duration (in seconds), but
can be interrupted by pressing ESC while the rgl window has the focus.

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.

As of rgl version 0.94, the dev argument is not needed: the
function f can specify its device, as spin3d does,
for example. However, if dev is specified, it will be selected
as the current device as each update is played.

As of rgl version 0.95.1476, f can
include multiple values in a "subscene"
component, and par3d() will be called
for each of them.

Value

This function is called for the side effect of its repeated calls to f.
It returns NULL invisibly.

Author(s)

Duncan Murdoch, based on code by Michael Friendly

See Also

spin3d and par3dinterp return functions suitable
to use as f. See demo(flag) for an example that modifies the
scene in f.