AnimationClip
(API) is one of the core elements of the Galacean animation system. Galacean supports importing model animations designed with external design software. Each animation in the model output by the designer will be parsed into an AnimationClip
asset in Galacean. We can also create additional animations through the animation clip editor.
There are two common ways to obtain AnimationClip
:
AnimationClip
in Galacean (the following will introduce both editor and script creation methods).The animation clip editor currently supports editing all interpolable properties except for physics-related components. If you need to edit other properties, you need to add the corresponding component to the entity.
No. | Description | Remarks |
---|---|---|
1 | Switch AnimationClip | |
2 | Enable/Disable Recording Mode | |
3 | Play/Pause AnimationClip | |
4 | Replay AnimationClip | |
5 | Add Animation Event | |
6 | Current Frame | Frame number of the timeline |
7 | Switch to Keyframe Mode | |
8 | Switch to Curve Mode | Curve mode is used to adjust how keyframes change |
9 | Added Animation Properties | |
10 | Add Keyframe | |
11 | Add Animation Property | |
12 | Keyframe | Keyframes are used to describe the value of the animation property at a specified frame number |
13 | Timeline | When adding keyframes or animation events, their time is the frame number of the timeline |
14 | Frame Number | : The left side is the number of seconds, and the right side is the number of frames less than 1 second. The animation editor is based on 60FPS. The time 0:30 shown in the figure above is at 30 frames. If the timeline scale is 1:30 , it is at 90 frames. |
+
to create an AnimationClip
asset.AnimationClip
asset and select an entity as the editing object of the AnimationClip
.Click the Create
button, and the editor will automatically add an Animator
(detailed introduction) to your entity
and add the AnimationClip
to the AnimatorController
.
When we click the add keyframe button, the keyframe will store the current value of the specified property. So when we haven't changed anything, the keyframe stores the position
value of the entity at this moment. We want it to move to the position (3, 0, 0) after 60 frames, so first modify the cube to (3, 0, 0) through the property panel and then add a keyframe.
Similarly, we also add keyframes for the rotation
property.
We provide a recording mode to facilitate developers to quickly add keyframes. When recording mode is enabled, keyframes will be automatically added when the corresponding property is modified.
Select the keyframe and drag it.
You can zoom the timeline by scrolling the mouse wheel
.
Enable recording mode, move the timeline to the specified keyframe, and then re-enter the value. If recording mode is not enabled, you need to click the add keyframe button again.
Select the keyframe, right-click and select delete, or press the delete key/backspace key on the keyboard.
AnimationClip
can not only act on the entity
that adds the Animator
(detailed introduction), but also on its child entities
.
entity
to the cube.entity
can be added.entity
, and add keyframes.The AnimationClip
editor supports animation curve editing. Click the curve icon in the upper right corner to switch.
The vertical axis of the curve mode is the value of the property.
You can adjust the vertical axis scale by pressing shift + mouse wheel
.
The color of the curve corresponding to the property is the same as the color of the button.
Selecting a keyframe will show two control points. Adjust the control points to adjust the curve.
You can also directly set the built-in preset values by right-clicking the keyframe.
Select the property panel's property to edit only the curve of the specified property.
Transform
component, Galacean also supports editing animations of other components. You can read the Text Animation document to learn more.animation curves
. You can read the Frame Animation document to learn more.Before using scripts, it is recommended to read the following documents:
You can create an AnimationClip
(API) yourself and add AnimationCurve
(API) to it through the addCurveBinding method.
//custom rotate clip
const rotateClip = new AnimationClip("rotate");
const rotateState =
animator.animatorController.layers[0].stateMachine.addState("rotate");
rotateState.clip = rotateClip;
const rotateCurve = new AnimationVector3Curve();
const key1 = new Keyframe<Vector3>();
key1.time = 0;
key1.value = new Vector3(0, 0, 0);
const key2 = new Keyframe<Vector3>();
key2.time = 10;
key2.value = new Vector3(0, 360, 0);
rotateCurve.addKey(key1);
rotateCurve.addKey(key2);
rotateClip.addCurveBinding("", Transform, "rotation", rotateCurve);
//custom color clip
const colorClip = new AnimationClip("color");
const colorState =
animator.animatorController.layers[0].stateMachine.addState("color");
colorState.clip = colorClip;
const colorCurve = new AnimationFloatCurve();
const key1 = new Keyframe<number>();
key1.time = 0;
key1.value = 0;
const key2 = new Keyframe<number>();
key2.time = 10;
key2.value = 1;
colorCurve.addKey(key1);
colorCurve.addKey(key2);
colorClip.addCurveBinding("/light", DirectLight, "color.r", colorCurve);
You can also add AnimationCurve
to your child entity /light
, as shown in the code example above. At the same time, the third parameter of addCurveBinding
is not limited to the properties of the component; it is a path that can index the value.
You can use AnimationEvent to add events to AnimationClip
. Animation events will call the specified callback function of the component bound to the same entity at the specified time.
const event = new AnimationEvent();
event.functionName = "test";
event.time = 0.5;
clip.addEvent(event);