import bpy
import math
import random
from mathutils import Vector
# 速度を指定する
zion_speed = 1.0
# 目標位置を指定する
zion_target = Vector((0, -60, 0))
# 平行移動するかどうかを指定する
parallel = False
# 平行移動量を指定する
parallel_distance = Vector((300, 300, 300))  # ここを変更する
# 球体を作成する関数
def create_sphere(location, radius):
    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)
# アニメーションを設定する関数
def set_animation(obj, start_frame, end_frame, target_location, speed):
    distance = (target_location - obj.location).length
    duration = distance / speed
    for frame in range(start_frame, end_frame+1):
        t = (frame - start_frame) / duration
        obj.location = obj.location.lerp(target_location, t)
        obj.keyframe_insert(data_path="location", frame=frame)
# 球体を作成する
spheres = []
for i in range(100):
    phi = random.uniform(0, math.pi)
    theta = random.uniform(0, 2*math.pi)
    radius = 30
    x = radius * math.sin(phi) * math.cos(theta)
    y = radius * math.sin(phi) * math.sin(theta)
    z = radius * math.cos(phi)
    location = Vector((x, y, z))
    create_sphere(location, 1.0)
    obj = bpy.context.active_object
    spheres.append(obj)
# アニメーションを設定する
for i, sphere in enumerate(spheres):
    start_frame = 1
    end_frame = 250
    location = sphere.location
    if parallel:
        target_location = location + parallel_distance
    else:
        # 表面に沿って動くように設定する
        normal = location.normalized()
        target_location = location + normal * 60  # 半径30の球体表面に沿って動く
    distance = (target_location - location).length
    speed = zion_speed / distance
    set_animation(sphere, start_frame, end_frame, target_location, speed)
import bpy
import math
import random
from mathutils import Vector
# 速度を指定する
zion_speed = 1.0
# 目標位置を指定する
zion_target = Vector((0, -60, 0))
# 平行移動するかどうかを指定する
parallel = False
# 平行移動量を指定する
parallel_distance = Vector((300, 300, 300))  # ここを変更する
# 球体を作成する関数
def create_sphere(location, radius):
    bpy.ops.mesh.primitive_uv_sphere_add(location=location, radius=radius)
# アニメーションを設定する関数
def set_animation(obj, start_frame, end_frame, target_location, speed):
    distance = (target_location - obj.location).length
    duration = distance / speed
    for frame in range(start_frame, end_frame+1):
        t = (frame - start_frame) / duration
        obj.location = obj.location.lerp(target_location, t)
        obj.keyframe_insert(data_path="location", frame=frame)
# 球体を作成する
spheres = []
for i in range(100):
    phi = random.uniform(0, math.pi)
    theta = random.uniform(0, 2*math.pi)
    radius = 30
    x = radius * math.sin(phi) * math.cos(theta)
    y = radius * math.sin(phi) * math.sin(theta)
    z = radius * math.cos(phi)
    location = Vector((x, y, z))
    create_sphere(location, 1.0)
    obj = bpy.context.active_object
    spheres.append(obj)
# アニメーションを設定する
for i, sphere in enumerate(spheres):
    start_frame = 1
    end_frame = 250
    location = sphere.location
    if parallel:
        target_location = location + parallel_distance
    else:
        # 表面に沿って動くように設定する
        normal = location.normalized()
        target_location = location + normal * 60  # 半径30の球体表面に沿って動く
    distance = (target_location - location).length
    speed = zion_speed / distance
    set_animation(sphere, start_frame, end_frame, target_location, speed)
bbb