Animation — Aspose.3D FOSS for Python API Reference

Overview

The Aspose.3D animation system is organised around a hierarchy of objects that bind time-sampled data to scene properties.

  • An AnimationClip is a named playback range (e.g. “Walk”, “Run”) held by a Scene.
  • An AnimationNode lives inside a clip and binds animated data to specific properties on scene objects.
  • A BindPoint connects an AnimationNode to a named Property on an A3DObject.
  • An AnimationChannel holds a single scalar KeyframeSequence within a bind point.
  • A KeyframeSequence is an ordered list of KeyFrame time–value samples.

All animation classes are in the aspose.threed.animation sub-package, though they are also accessible directly from aspose.threed.

from aspose.threed.animation import (
    AnimationClip,
    AnimationNode,
    AnimationChannel,
    BindPoint,
    KeyFrame,
    KeyframeSequence,
    Interpolation,
    ExtrapolationType,
)

AnimationClip

A named container for one playback range. A Scene may hold multiple clips. Inherits from SceneObject.

Constructor

SignatureDescription
AnimationClip(name=None)Creates a clip with an optional name

Properties

NameTypeDescription
namestrClip name (e.g. "Walk")
descriptionstrOptional description
startfloatStart time in seconds
stopfloatEnd time in seconds
animationslist[AnimationNode]Read-only list of animation nodes in this clip
propertiesPropertyCollectionCustom properties

Methods

MethodReturn TypeDescription
create_animation_node(node_name)AnimationNodeCreates and registers a new AnimationNode in this clip

AnimationNode

Binds an AnimationClip to one or more BindPoint objects targeting scene-object properties. Inherits from A3DObject.

Constructor

SignatureDescription
AnimationNode(name=None)Creates an animation node with optional name

Properties

NameTypeDescription
namestrNode name
bind_pointslist[BindPoint]Read-only list of bind points
sub_animationslist[AnimationNode]Read-only list of child animation nodes
propertiesPropertyCollectionCustom properties

Methods

MethodReturn TypeDescription
find_bind_point(target, name)BindPoint | NoneFinds a bind point for the property named name on target
get_bind_point(target, prop_name, create)BindPoint | NoneGets (or creates) a bind point for a named property
create_bind_point(obj, prop_name)BindPoint | NoneCreates a new bind point for the property prop_name on obj
get_keyframe_sequence(target, prop_name, channel_name, create)KeyframeSequence | NoneReturns the keyframe sequence for the named channel; creates it if create=True

BindPoint

Connects an AnimationNode to a single Property on an A3DObject. Each BindPoint may hold multiple AnimationChannel objects (one per scalar component). Inherits from A3DObject.

Properties

NameTypeDescription
propertyPropertyThe scene-object property this bind point targets
channels_countintNumber of animation channels in this bind point

Methods

MethodReturn TypeDescription
add_channel(name, value, type=None)boolAdds a named channel with a default value
get_channel(channel_name)AnimationChannel | NoneRetrieves a channel by name
get_keyframe_sequence(channel_name)KeyframeSequence | NoneReturns the keyframe sequence for the named channel
create_keyframe_sequence(name)KeyframeSequenceCreates a new KeyframeSequence for this bind point
bind_keyframe_sequence(channel_name, sequence)NoneAssociates an existing KeyframeSequence with a channel
reset_channels()NoneRemoves all channels

AnimationChannel

Holds a single scalar KeyframeSequence for one animated component.

Properties

NameTypeDescription
namestrChannel name (e.g. "X", "Y", "Z")
default_valueAnyValue used when no keyframe data is present
keyframe_sequenceKeyframeSequence | NoneThe sequence of keyframes for this channel

KeyframeSequence

An ordered list of KeyFrame samples for a single scalar channel. Inherits from A3DObject.

Constructor

SignatureDescription
KeyframeSequence(name=None)Creates an empty keyframe sequence

Properties

NameTypeDescription
namestrSequence name
key_frameslist[KeyFrame]Read-only list of keyframes in chronological order
pre_behaviorExtrapolationBehaviour before the first keyframe
post_behaviorExtrapolationBehaviour after the last keyframe
bind_pointBindPoint | NoneThe bind point owning this sequence

Methods

MethodReturn TypeDescription
add(time, value, interpolation=Interpolation.LINEAR)NoneAppends a keyframe at time (seconds) with the given value and interpolation mode
reset()NoneClears all keyframes and resets pre/post behaviour

KeyFrame

A single time–value sample in a KeyframeSequence.

Constructor

KeyFrame objects are created internally by KeyframeSequence.add(); do not construct them directly.

Properties

NameTypeDescription
timefloatTime position in seconds
valuefloatAnimated value at this time
interpolationInterpolationInterpolation mode applied between this keyframe and the next
tangent_weight_modeWeightedModeTangent weight mode (Bezier curves)
step_modeStepModeStep behaviour (PREVIOUS_VALUE or NEXT_VALUE)
next_in_tangentVector2 | NoneIncoming tangent vector for Bezier interpolation
out_tangentVector2 | NoneOutgoing tangent vector for Bezier interpolation
out_weightfloatOutgoing tangent weight
next_in_weightfloatIncoming tangent weight
tensionfloatTension parameter (TCB spline)
continuityfloatContinuity parameter (TCB spline)
biasfloatBias parameter (TCB spline)
independent_tangentboolWhen True, in and out tangents are independent
flatboolWhen True, tangents are clamped flat
time_independent_tangentboolWhen True, tangent direction is independent of time scaling

Interpolation (Enum)

Controls how values are interpolated between consecutive keyframes.

ValueDescription
CONSTANTStep (hold previous value until next keyframe)
LINEARLinear interpolation between values
BEZIERCubic Bezier using in/out tangents
B_SPLINEUniform B-spline
CARDINAL_SPLINECardinal spline
TCB_SPLINETension–Continuity–Bias spline

ExtrapolationType (Enum)

Controls animation behaviour beyond the first and last keyframe.

ValueDescription
CONSTANTHold the boundary value
GRADIENTExtrapolate at the tangent gradient of the boundary keyframe
CYCLERepeat the keyframe range (loops)
CYCLE_RELATIVERepeat with cumulative offset (relative to end value)
OSCILLATEPing-pong (alternating forward and backward repeat)

Example

from aspose.threed import Scene
from aspose.threed.animation import AnimationClip, Interpolation
from aspose.threed.utilities import Vector3

scene = Scene()
node = scene.root_node.create_child_node("animated_box")
node.transform.translation = Vector3(0.0, 0.0, 0.0)

# Create an animation clip
clip = AnimationClip("Move")
clip.start = 0.0
clip.stop  = 2.0

# Create an animation node inside the clip
anim_node = clip.create_animation_node("box_anim")

# Get keyframe sequences for the X and Y translation channels
seq_x = anim_node.get_keyframe_sequence(node.transform, "Translation", "X", True)
seq_y = anim_node.get_keyframe_sequence(node.transform, "Translation", "Y", True)

if seq_x:
    seq_x.add(0.0,  0.0,  Interpolation.LINEAR)
    seq_x.add(1.0, 10.0,  Interpolation.LINEAR)
    seq_x.add(2.0,  0.0,  Interpolation.LINEAR)

if seq_y:
    seq_y.add(0.0,  0.0, Interpolation.BEZIER)
    seq_y.add(1.0,  5.0, Interpolation.BEZIER)
    seq_y.add(2.0,  0.0, Interpolation.BEZIER)

# Export to FBX to preserve animation data
scene.save("animated.fbx")

See Also