% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/animate-3d.R
\name{anim_save_3d}
\alias{anim_save_3d}
\title{Save a 3D animation to a file}
\usage{
anim_save_3d(animation = NULL, filename)
}
\arguments{
\item{animation}{An animation object from \code{\link[=animate_3d]{animate_3d()}}, or \code{NULL}
to use the last rendered animation.}

\item{filename}{Output file path.}
}
\value{
Invisibly returns the output file path (a character string).
Called primarily for its side effect of copying the animation to
\code{filename}.
}
\description{
Saves an animation object produced by \code{\link[=animate_3d]{animate_3d()}} to a file.
If no animation is provided, saves the most recently rendered animation.
}
\examples{
\dontshow{if (requireNamespace("gifski", quietly = TRUE)) withAutoprint(\{ # examplesIf}
\donttest{
p <- ggplot() +
  geom_function_3d(
    fun = function(x, y) sin(x) * cos(y),
    xlim = c(-pi, pi), ylim = c(-pi, pi),
    fill = "steelblue", color = "steelblue") +
  coord_3d()

animate_3d(p, yaw = c(0, 360))
anim_save_3d(filename = file.path(tempdir(), "my_animation.gif"))
}
\dontshow{\}) # examplesIf}
}
