I've problem Rendering sun rotation animation. Steps to reproduce:
- Create the sun object
- Set 1st keyframe
- Select keyframe
- Rotate sun object using the handle
- "I" > Select Rotation
- Set 10th keyframe (Reproduce same steps found in 2nd point)
- Add
frame_change_post
handler to print sunrotation_euler
- Run Render > Render Animation
The result was 11 times (0-10) printed same rotation Euler
<Euler (x=-7.9113, y=0.2392, z=-7.1615), order='XYZ'>
.But when I move from keyframe to keyframe Euler XYZ positions are updated. Why is that so?
Here is a demo plugin created to replicate the issue:
bl_info = {
"name": "Sun animation using lever",
"author": "karlisup",
"version": (1, 0),
"blender": (2, 80, 0),
}
import bpy
from bpy.app.handlers import persistent
@persistent
def sun_handler(scene, depsgraph):
if "Sun" not in bpy.data.objects:
create_sun()
sun = bpy.data.objects["Sun"]
print(scene.frame_current, sun.rotation_euler)
def create_sun():
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.layer_collection
light_data = bpy.data.lights.new(name="Sun", type='SUN')
light_data.energy = 30
light_object = bpy.data.objects.new(name="Sun", object_data=light_data)
light_object.location = (5, 5, 5)
bpy.context.collection.objects.link(light_object)
bpy.context.view_layer.objects.active = light_object
def register():
bpy.app.handlers.frame_change_post.append(sun_handler)
def unregister():
bpy.app.handlers.frame_change_post.remove(sun_handler)
if __name__ == "__main__":
register()