examples

76 interactive examples

hover example to preview

1

Snake 3D

audio
2

Creating Yoyo Animation

3

Creating Wooden Planks Animation

4

Creating Windstorm Animation

5

Creating Windmill Animation

6

Creating Whale Animation

7

Creating Waterfall Animation

8

Creating Volcano Animation

9

Creating Vaporwave Animation

10

Creating Tree Animation

11

Creating Tornado Animation

12

Creating Sun Animation

13

Creating Stone Wall Animation

14

Creating Spring Animation

15

Creating Spider Animation

16

Creating Spaceship Animation

17

Creating Solar System Educational Animation

18

Creating Solar System Animation

19

Creating Snowglobe Animation

20

Creating Snake Animation

21

Creating Sailboat Animation

22

Creating Robot Animation

23

Creating River Rapids Animation

24

Creating Rainbow Animation

25

Creating Prism Animation

26

Creating Pinwheel Animation

27

Creating Pine Tree Animation

28

Creating Phoenix Animation

29

Creating Pendulum Animation

30

Creating Octopus Animation

31

Creating Mushroom Animation

32

Creating Metronome Animation

33

Creating Meteor Animation

34

Creating Metal Plates Animation

35

Creating Lissajous Animation

36

Creating Lightning Animation

37

Creating Lighthouse Animation

38

Creating Lava Lamp Animation

39

Creating Lantern Animation

40

Creating Kite Animation

41

Creating Kaleidoscope Animation

42

Creating Jellyfish Animation

43

Creating Inner Planets Orbit Animation

44

Creating Hourglass Animation

45

Creating Hive Animation

46

Creating Grass Animation

47

Creating Geyser Animation

48

Creating Gear Animation

49

Creating Fountain Animation

50

Creating Flower Animation

51

Creating Fish Animation

52

Creating Fireworks Animation

53

Creating Fern Animation

54

Creating Earth Orbit Animation

55

Creating Dragon Animation

56

Creating Disco Ball Animation

57

Creating Demon Animation

58

Creating Crystallization Animation

59

Creating Crystal Animation

60

Creating Cosmic Formation Animation

61

Creating Coral Reef Animation

62

Creating Compass Animation

63

Creating Cloud Animation

64

Creating Clock Animation

65

Creating Castle Animation

66

Creating Carousel Animation

67

Creating Candle Animation

68

Creating Campfire Animation

69

Creating Cactus Animation

70

Creating Butterfly Animation

71

Creating Bush Animation

72

Creating Brick Wall Animation

73

Creating Blackhole Animation

74

Creating Beehive Animation

75

Creating Aurora Animation

76

🎈 Floating Balloons

hover for preview

Creating Inner Planets Orbit Animation

published on 8/21/2025
interactive example

Inner Planets Orbit - 3D Voxel Animation

This guide walks you through how to generate a looping 3D voxel animation of the inner planets orbiting the Sun using SpatialStudio. The script creates a realistic solar system model showing Mercury, Venus, Earth, and Mars in their orbital paths around a glowing Sun inside a cubic 3D space, then saves the animation to a .splv file.


What this script does

  • Creates a 3D scene of size 128×128×128
  • Spawns the Sun at the center with:
    • A bright yellow-orange glowing sphere
    • Subtle surface texture variations
    • Radial light emission effects
  • Animates 4 inner planets (Mercury, Venus, Earth, Mars) with:
    • Accurate relative sizes and colors
    • Elliptical orbital paths at different speeds
    • Individual rotation on their axes
  • Runs for 12 seconds at 24 FPS showing multiple orbital cycles
  • Outputs the file inner_planets_orbit.splv that you can play in your viewer

How it works (simplified)

  1. Voxel volume Each frame is a 3D grid filled with RGBA values (SIZE × SIZE × SIZE × 4).

  2. Central Sun The Sun is drawn as a large sphere with animated surface patterns and a bright glow effect.

  3. Planet orbits Each planet follows an elliptical path calculated using trigonometric functions, with Mercury orbiting fastest and Mars slowest.

  4. Planet rendering Planets are drawn as textured spheres with realistic colors (gray Mercury, bright Venus, blue-green Earth, red Mars).

  5. Animation timing A normalized time variable t cycles from 0 → 2π, with each planet having different orbital periods for realistic motion.

  6. Encoding Frames are passed into splv.Encoder, which writes them into the .splv video file.


Try it yourself

Install requirements first:

pip install spatialstudio numpy tqdm

Then copy this script into inner_planets_orbit.py and run:

python inner_planets_orbit.py

Full Script

import numpy as np
from spatialstudio import splv
from tqdm import tqdm

# Scene setup
SIZE, FPS, SECONDS = 128, 24, 12
FRAMES = FPS * SECONDS
CENTER_X = CENTER_Y = CENTER_Z = SIZE // 2
OUT_PATH = "../outputs/inner_planets_orbit.splv"

# Solar system settings
SUN_RADIUS = 8
PLANET_DATA = [
    {"name": "Mercury", "radius": 2, "orbit_radius": 18, "speed": 4.0, "color": (169, 169, 169)},
    {"name": "Venus", "radius": 3, "orbit_radius": 25, "speed": 1.6, "color": (255, 198, 73)},
    {"name": "Earth", "radius": 3, "orbit_radius": 32, "speed": 1.0, "color": (100, 149, 237)},
    {"name": "Mars", "radius": 2, "orbit_radius": 40, "speed": 0.5, "color": (205, 92, 92)}
]

def add_voxel(volume, x, y, z, color):
    if 0 <= x < SIZE and 0 <= y < SIZE and 0 <= z < SIZE:
        volume[x, y, z, :3] = color
        volume[x, y, z, 3] = 255

def generate_sun(volume, cx, cy, cz, t):
    sun_color = (255, 215, 0)
    glow_color = (255, 165, 0)
    
    # Main sun body with surface texture
    for dx in range(-SUN_RADIUS-2, SUN_RADIUS+3):
        for dy in range(-SUN_RADIUS-2, SUN_RADIUS+3):
            for dz in range(-SUN_RADIUS-2, SUN_RADIUS+3):
                distance = np.sqrt(dx*dx + dy*dy + dz*dz)
                
                # Sun core
                if distance <= SUN_RADIUS:
                    surface_var = np.sin(dx*0.4 + t*2) * np.cos(dy*0.3 + t*1.5) * np.sin(dz*0.5 + t*1.8)
                    brightness = 1.0 + surface_var * 0.2
                    final_color = tuple(min(255, int(c * brightness)) for c in sun_color)
                    add_voxel(volume, cx+dx, cy+dy, cz+dz, final_color)
                
                # Sun glow effect
                elif distance <= SUN_RADIUS + 2:
                    glow_intensity = 1.0 - (distance - SUN_RADIUS) / 2.0
                    glow_final = tuple(int(c * glow_intensity * 0.6) for c in glow_color)
                    add_voxel(volume, cx+dx, cy+dy, cz+dz, glow_final)

def generate_planet(volume, cx, cy, cz, radius, color, t, rotation_speed=1.0):
    for dx in range(-radius-1, radius+2):
        for dy in range(-radius-1, radius+2):
            for dz in range(-radius-1, radius+2):
                distance = np.sqrt(dx*dx + dy*dy + dz*dz)
                
                if distance <= radius:
                    # Add surface texture based on planet rotation
                    texture = np.sin(dx*0.5 + t*rotation_speed) * np.cos(dy*0.3) * np.sin(dz*0.4 + t*rotation_speed*0.7)
                    brightness = 0.8 + texture * 0.3
                    
                    # Add some shading based on distance from center
                    shade = 1.0 - (distance / radius) * 0.2
                    brightness *= shade
                    
                    final_color = tuple(max(0, min(255, int(c * brightness))) for c in color)
                    add_voxel(volume, cx+dx, cy+dy, cz+dz, final_color)

def generate_orbital_system(volume, t):
    # Generate the Sun
    generate_sun(volume, CENTER_X, CENTER_Y, CENTER_Z, t)
    
    # Generate each planet in its orbit
    for planet in PLANET_DATA:
        # Calculate orbital position
        angle = t * planet["speed"]
        
        # Add slight elliptical orbit variation
        orbit_variation = planet["orbit_radius"] + np.sin(angle * 2) * 2
        
        # Calculate 3D position (orbiting in XZ plane with slight Y variation)
        px = CENTER_X + int(orbit_variation * np.cos(angle))
        py = CENTER_Y + int(np.sin(angle * 0.3) * 3)  # Slight vertical variation
        pz = CENTER_Z + int(orbit_variation * np.sin(angle))
        
        # Generate the planet with its own rotation
        generate_planet(volume, px, py, pz, planet["radius"], planet["color"], t, planet["speed"]*2)

def add_orbit_trails(volume, t):
    trail_color = (50, 50, 50)
    
    # Draw faint orbital paths
    for planet in PLANET_DATA:
        radius = planet["orbit_radius"]
        for i in range(0, 360, 8):  # Every 8 degrees
            angle = np.radians(i)
            x = CENTER_X + int(radius * np.cos(angle))
            z = CENTER_Z + int(radius * np.sin(angle))
            
            # Only show trail occasionally for visual clarity
            if (int(t*10) + i) % 32 < 4:
                add_voxel(volume, x, CENTER_Y, z, trail_color)

def generate_scene(volume, t):
    add_orbit_trails(volume, t)
    generate_orbital_system(volume, t)

# Initialize encoder
enc = splv.Encoder(SIZE, SIZE, SIZE, framerate=FPS, outputPath=OUT_PATH, motionVectors="off")

# Generate animation frames
for frame in tqdm(range(FRAMES), desc="Generating inner planets orbit"):
    volume = np.zeros((SIZE, SIZE, SIZE, 4), dtype=np.uint8)
    t = (frame / FRAMES) * 2*np.pi
    generate_scene(volume, t)
    enc.encode(splv.Frame(volume, lrAxis="x", udAxis="y", fbAxis="z"))

enc.finish()
print(f"Created {OUT_PATH}")

Next steps

  • Adjust PLANET_DATA to modify orbital speeds, sizes, or colors
  • Add asteroid belt by creating small rocks between Mars and Jupiter's orbit
  • Include planet moons (like Earth's Moon) with their own sub-orbits
  • Experiment with different orbital inclinations by modifying the Y-axis calculations
  • Add starfield background by sprinkling white pixels in the distant volume
  • Increase SECONDS to show longer orbital periods and planet alignments

Educational notes

This animation demonstrates several astronomical concepts:

  • Orbital mechanics: Inner planets orbit faster than outer ones (Kepler's laws)
  • Relative sizes: Planets are scaled proportionally to show size differences
  • Rotation periods: Each planet spins on its axis while orbiting
  • Solar dominance: The Sun's size and brightness show its gravitational influence

The animation completes multiple Mercury orbits while Mars barely completes one, accurately representing the relative orbital periods of our solar system's inner planets.