play3d                  package:rgl                  R Documentation

_P_l_a_y _a_n_i_m_a_t_i_o_n _o_f _r_g_l _s_c_e_n_e

_D_e_s_c_r_i_p_t_i_o_n:

     '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.

_U_s_a_g_e:

     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) 

_A_r_g_u_m_e_n_t_s:

       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 

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

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

_A_u_t_h_o_r(_s):

     Duncan Murdoch, based on code by Michael Friendly

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     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)

