JoPmt commited on
Commit
1e18591
1 Parent(s): 7cf3136

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -37,10 +37,13 @@ def add_planet(name, radius, mass, distance_from_sun):
37
  bpy.context.view_layer.objects.active = planet
38
  planet.select_set(True)
39
  planet.animation_data_create()
40
- planet.animation_data.action = bpy.data.actions.new(name="OrbitAction")
41
  start_frame = 1
42
  duration=2
43
  end_frame = int(duration * 10)
 
 
 
44
  for frame in range(start_frame, end_frame + 1):
45
  ##angle = (frame / end_frame) * 2 * math.pi
46
  ##x = radius * math.cos(angle)
@@ -50,9 +53,7 @@ def add_planet(name, radius, mass, distance_from_sun):
50
  ##planet.keyframe_insert(data_path="location", index=-1, frame=frame)
51
  angle = math.radians(frame * 18)
52
  planet.rotation_euler = (0, 0, angle)
53
- planet.rotation_mode = 'XYZ'
54
- planet.keyframe_insert(data_path="rotation_euler", index=2, frame=start_frame)
55
- planet.keyframe_insert(data_path="rotation_euler", index=2, frame=end_frame)
56
  ##return planet
57
 
58
  def create_planet_flyby_animation(planet, radius, duration):
 
37
  bpy.context.view_layer.objects.active = planet
38
  planet.select_set(True)
39
  planet.animation_data_create()
40
+ planet.animation_data.action = bpy.data.actions.new(name="RotationAction")
41
  start_frame = 1
42
  duration=2
43
  end_frame = int(duration * 10)
44
+ planet.rotation_mode = 'XYZ'
45
+ planet.keyframe_insert(data_path="rotation_euler", index=2, frame=start_frame)
46
+ planet.keyframe_insert(data_path="rotation_euler", index=2, frame=end_frame)
47
  for frame in range(start_frame, end_frame + 1):
48
  ##angle = (frame / end_frame) * 2 * math.pi
49
  ##x = radius * math.cos(angle)
 
53
  ##planet.keyframe_insert(data_path="location", index=-1, frame=frame)
54
  angle = math.radians(frame * 18)
55
  planet.rotation_euler = (0, 0, angle)
56
+
 
 
57
  ##return planet
58
 
59
  def create_planet_flyby_animation(planet, radius, duration):