FrameAnimation3d

Play a sequence of 3D models as a frame-by-frame animation.

FrameAnimation3d

FrameAnimation3d(name, fps=12, loop=True, autoplay=True, frame_times=None, auto_destroy=False, **kwargs)

Located in ursina/prefabs/frame_animation_3d.py

Overview

FrameAnimation3d loads a series of mesh files (e.g. .obj) and displays them one after another on an Entity. It functions like a flipbook in 3D, useful for simple character or object animations without using a full skeletal system.

Constructor Arguments

ArgumentTypeDefaultDescription
namestrBase filename or path prefix for model files (e.g. "run_cycle_" to match run_cycle_000.obj).
fpsint12Frames per second.
loopboolTrueWhether to repeat the animation when it ends.
autoplayboolTrueIf True, start playback immediately.
frame_timeslist[float]NonePer-frame durations in seconds. Overrides fps if provided.
auto_destroyboolFalseIf True, destroy the entity when the sequence finishes (when not looping).
**kwargsanyAny other Entity parameters (position, scale, parent, etc.).

Properties

PropertyDescription
.durationTotal playtime in seconds, derived from fps or frame_times.
.current_frameIndex of the currently visible frame (0-based).

Methods

MethodDescription
start()Begin playback from frame 0 or resume if paused.
pause()Stop playback at the current frame.
resume()Continue playback from the paused frame.
finish()Jump to the final frame and stop.
on_destroy()Cleanup logic called if auto_destroy=True after sequence ends.

Example

from ursina import *
from ursina.prefabs.frame_animation_3d import FrameAnimation3d

app = Ursina()

# run_cycle_000.obj, run_cycle_001.obj, ... in your assets folder
anim = FrameAnimation3d(
    'run_cycle_', 
    fps=10, 
    loop=True, 
    position=(0,0,0),
    scale=1
)

app.run()