# Animate a sphere following the path of spline curve in 3D

Instead of a point, I want to animate a 3D Sphere to following the path of this 3D-spline. How would I do this with the given code below. Any solutions to this ?

 pts = {{0, 0, 1}, {1, 1, 1}, {0.5, 1.5, 1}};
s = BSplineFunction[pts, SplineClosed -> True, SplineDegree -> 1];
Animate[
ParametricPlot3D[s[t], {t, 0, 1},
Epilog :> {Red, PointSize[Large], Point[s[t]]}],
{t, 0., 1.}]

• 1. You should use a different dummy variable for ParametricPlot3D[] and Animate[] 2. Epilog is only intended for appending 2D primitives. Thus: Animate[Show[ParametricPlot3D[s[t], {t, 0, 1}], Graphics3D[{Red, PointSize[Large], Point[s[u]]}]], {u, 0., 1.}] – J. M. is away Mar 12 '18 at 19:08

## 2 Answers

You can't put 3D graphics objects in a epilog clause. The Epilog option is strictly for adding a 2D foreground to a plot, 2D or 3D. You should use Show and make the sphere with a Graphics expression. Like so.

pts = {{0, 0, 1}, {1, 1, 1}, {0.5, 1.5, 1}};
s = BSplineFunction[pts, SplineClosed -> True, SplineDegree -> 1];

Animate[
Show[
ParametricPlot3D[s[t], {t, 0, 1}],
Graphics3D[{Red, Sphere[s[t], Scaled[.02]]}]],
{t, 0., 1}] • Thank you, this was very helpful – Brandon M Mar 13 '18 at 21:47
• @BrandonM. Helpful but not worth an up-vote? – m_goldberg Mar 13 '18 at 22:06
• How do I do that? I'm new to stackexchange. – Brandon M Mar 14 '18 at 16:17
• @BrandonM. Just click on the up-arrow on lefthand side of the answer -- above the acceptance checkmark that you have already clicked on (and thanks for that). – m_goldberg Mar 14 '18 at 19:10
Animate[ParametricPlot3D[s[t], {t, 0, 1}, MeshFunctions -> {#4 &},
Mesh -> {{u}}, MeshStyle -> Red] /. Point[x_] :> Sphere[x, .05], {u,  0., 1.}] 