-- snip --
On 11/4/2012 7:45 AM, Duncan Murdoch wrote:
First, draw the new sphere at the first point and save the object id:
sphereid <- sphere3d(dat[1,c("X", "Y", "Z")], col="red", radius=1)
# Also save the spinner that you like:
spin <- spin3d( ) #maybe with different parms
# Now, the animation function:
f <- function(time) {
par3d(skipRedraw = TRUE) # stops intermediate redraws
on.exit(par3d(skipRedraw=FALSE)) # redraw at the end
rgl.pop(id=sphereid) # delete the old sphere
pt <- time %% 40 + 1 # compute which one to draw
pnt <- dat[pt, c("X", "Y", "Z")] # maybe interpolate instead?
sphereid <<- spheres3d(pnt, radius=1, col="red")
spin(time)
}
Duncan Murdoch
Thanks so much Duncan!
I probably never would have gotten there without your help. (Especially
since I had to look at the help for the <<- operator, which is
conceptually a level beyond where I usually work). It would be great
to have an additional creative example or two for f(time) functions in
the play3d() help. Your useful code comments really help me see what
needs to happen in an f(time) function.
I really appreciate that you took the time to get me going!
I've made a small addition to the spin3d function and added an example
to the ?spin3d page. This isn't on CRAN yet, but you can get the
latest from R-forge. Make sure you get 0.92.898 or newer.
The new example shows a rotating view of spinning cubes, using the
sprites3d function within the animation function.
Duncan Murdoch
Thanks so much for taking the time to do this and for all the other
contributions you make to the R community!
I should tell you that I also looked at your rgl function writeWebGL()
over the weekend, and I think it holds tremendous potential for sharing
visualizations of multidimensional data with a non-technical audience.
Who knew it could be so easy to move three dimensional data from R to
the web?
Rob Baer
--
__________________
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksille College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 USA
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.