Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,8 +46,8 @@ def create_planet_flyby_animation(planet, radius, duration):
|
|
46 |
for frame in range(start_frame, end_frame + 1):
|
47 |
angle = (frame / end_frame) * 2 * math.pi
|
48 |
x = radius * math.cos(angle)
|
49 |
-
y =
|
50 |
-
z =
|
51 |
planet.location = (x, y, z)
|
52 |
planet.keyframe_insert(data_path="location", index=-1, frame=frame)
|
53 |
|
@@ -57,9 +57,23 @@ def add_animated_space_rocks():
|
|
57 |
for i in range(30):
|
58 |
bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.01, 0.1), location=(random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-4, 9)))
|
59 |
space_rock = bpy.context.active_object
|
60 |
-
space_rock.keyframe_insert(data_path="location", frame=1)
|
61 |
-
space_rock.location = (random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10))
|
62 |
-
space_rock.keyframe_insert(data_path="location", frame=duration * bpy.context.scene.render.fps)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
def create_particle_effects_animation():
|
65 |
bpy.context.scene.render.fps = 10
|
|
|
46 |
for frame in range(start_frame, end_frame + 1):
|
47 |
angle = (frame / end_frame) * 2 * math.pi
|
48 |
x = radius * math.cos(angle)
|
49 |
+
y = planet.location.y
|
50 |
+
z = radius * math.sin(angle)
|
51 |
planet.location = (x, y, z)
|
52 |
planet.keyframe_insert(data_path="location", index=-1, frame=frame)
|
53 |
|
|
|
57 |
for i in range(30):
|
58 |
bpy.ops.mesh.primitive_uv_sphere_add(radius=random.uniform(0.01, 0.1), location=(random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-4, 9)))
|
59 |
space_rock = bpy.context.active_object
|
60 |
+
##space_rock.keyframe_insert(data_path="location", frame=1)
|
61 |
+
##space_rock.location = (random.uniform(-10, 10), random.uniform(-10, 10), random.uniform(-10, 10))
|
62 |
+
##space_rock.keyframe_insert(data_path="location", frame=duration * bpy.context.scene.render.fps)
|
63 |
+
bpy.context.view_layer.objects.active = space_rock
|
64 |
+
space_rock.select_set(True)
|
65 |
+
space_rock.animation_data_create()
|
66 |
+
space_rock.animation_data.action = bpy.data.actions.new(name="OrbitAction")
|
67 |
+
start_frame = 1
|
68 |
+
end_frame = int(duration * 10)
|
69 |
+
for frame in range(start_frame, end_frame + 1):
|
70 |
+
angle = (frame / end_frame) * 2 * math.pi
|
71 |
+
x = radius * math.cos(angle)
|
72 |
+
y = space_rock.location.y
|
73 |
+
z = radius * math.sin(angle)
|
74 |
+
space_rock.location = (x, y, z)
|
75 |
+
space_rock.keyframe_insert(data_path="location", index=-1, frame=frame)
|
76 |
+
|
77 |
|
78 |
def create_particle_effects_animation():
|
79 |
bpy.context.scene.render.fps = 10
|