Three.js dark theme example

surface = dodecahedron(mesh=True, color='blue').scale(0.5)
curve = parametric_plot3d([sin(x), cos(x), x/pi], (x, -pi, pi), color='red')
points = point3d([random_vector(RR, 3) for i in range(0, 100)], color='green')
text = text3d("Hello world!", (1, 1, 1), color='yellow')
show(surface + curve + points + text, theme='dark')

Dark theme animation

animate([dodecahedron().rotateZ(t*pi/32) for t in range(0, 64)]).interactive(delay=5, theme='dark')

New, simpler version of the animation branch

sage: def build_frame(t):
....:     e = parametric_plot3d([sin(x-t), 0, x], (x, 0, 2*pi), color='red')
....:     m = parametric_plot3d([0, -sin(x-t), x], (x, 0, 2*pi), color='green')
....:     return e + m
sage: frames = [build_frame(t) for t in (0, pi/32, pi/16, .., 2*pi)]
sage: plot = animate(frames).interactive()
sage: show(plot, delay=5, auto_play=False, projection='orthographic')

A moving point using animate3d

sage: p(u) = (sin(u), cos(u), sin(u)*cos(u))
sage: frames = [point3d(p(u)) for u in (0,pi/16,..,2*pi)]
sage: animate3d(frames)
Graphics3d Object

Frames of motion

sage: show(animate3d(frames), animate=False)

More options for animate3d

sage: animate3d(frames, delay=10, loop='once', auto_play=False, var_name='u')
Graphics3d Object

Animating 2D plots

sage: frames = [None] + [polar_plot(sin(5*x)^2, (x, 0, t)) for t in (pi/32,pi/16,..,2*pi)]
sage: animate3d(frames, delay=5) # long time
Graphics3d Object

Moving sine wave using animated_plot3d

sage: def moving_sine(t):
....:     return parametric_plot3d([sin(x-t), 0, x], (x, 0, 4*pi))
sage: animated_plot3d(moving_sine, t=anim_var(0, pi/16, .., 2*pi))
Graphics3d Object

More options for animation variables

sage: animated_plot3d(moving_sine, t=anim_var(
....:     'u', [0, pi/16, .., 2*pi], initial=pi, loop='pingpong',
....:     speed=pi, auto_play=False))
Graphics3d Object

Combining animated plots

sage: def moving_sine2(t):
....:     return parametric_plot3d([0, -sin(x-t), x], (x, 0, 4*pi), color='red')
sage: plot1 = animated_plot3d(moving_sine, t=anim_var(
....:             [0, pi/16, .., 2*pi], auto_play=True, speed=pi))
sage: plot2 = animated_plot3d(moving_sine2, t=anim_var(
....:             [0, pi/16, .., 2*pi], auto_play=True, speed=-pi))
sage: show(plot1 + plot2, projection='orthographic')

Sharing animation variables

sage: t_var = anim_var([0, pi/16, .., 2*pi], auto_play=True, speed=pi)
sage: plot1 = animated_plot3d(moving_sine, t_var)
sage: plot2 = animated_plot3d(moving_sine2, t_var)
sage: show(plot1 + plot2, projection='orthographic')

Preventing playback of animation variables

sage: theta, phi = var('theta,phi')
sage: def draw_torus(R, r):
....:     return parametric_plot3d(
....:         [(R + r*cos(theta)) * cos(phi), (R + r*cos(theta)) * sin(phi), r*sin(theta)],
....:        (theta, 0, 2*pi), (phi, 0, 2*pi))
sage: R_var = anim_var([0.2, 0.4, .., 2], speed=0)
sage: r_var = anim_var([0.1, 0.2, .., 1], speed=0)
sage: animated_plot3d(draw_torus, R_var, r_var) # long time
Graphics3d Object

Passing non-animation variable arguments

sage: def d12(x, y, z, theta):
....:     return dodecahedron().translate((x, y, z)).rotateZ(theta)
sage: plot = animated_plot3d(d12, 1, 2, z=3, theta=anim_var(0, pi/16, .., 2*pi))
sage: show(plot, auto_play=False)