xr-frame / Exports / Animation
# Class: Animation<IData, IOptions>
动画资源基类,被Animator使用,可以继承它来实现具体的动画。
# Type parameters
| Name | Type | Description |
|---|---|---|
IData | any | 动画初始化接受的数据。 |
IOptions | any | 动画播放时接受的额外追加选项。 |
# Hierarchy
Animation
# Table of contents
# Constructors
# Events
# Properties
# Accessors
# Constructors
# constructor
• new Animation<IData, IOptions>(_scene, data)
# Type parameters
| Name | Type |
|---|---|
IData | any |
IOptions | any |
# Parameters
| Name | Type | Description |
|---|---|---|
_scene | Scene | 场景实例。 |
data | IData | 初始化动画数据。 |
# Events
# onInit
▸ onInit(data): void
动画初始化时执行的生命周期,只会执行一次。
# Parameters
| Name | Type | Description |
|---|---|---|
data | IData | 初始化动画数据。 |
# Returns
void
# onPause
▸ onPause(el): void
在动画暂停时执行的回调。
# Parameters
| Name | Type | Description |
|---|---|---|
el | Element | 本次播放作用于的element。 |
# Returns
void
# onPlay
▸ onPlay(el, clipName, options): Object
动画开始播放时执行的生命周期。
# Parameters
| Name | Type | Description |
|---|---|---|
el | Element | 本次播放作用于的element,一个动画可能作用于多个element,可以在这里区分。 |
clipName | string | 本次播放的片段名字。 |
options | IOptions | 本次播放时的附加选项。 |
# Returns
Object
返回本次播放片段的参数,必须包括时长duration(s),可选循环次数loop、延迟delay和方向direction。
| Name | Type |
|---|---|
delay? | number |
direction? | TDirection |
duration | number |
loop? | number |
# onResume
▸ onResume(el): void
在动画从暂停状态唤醒时执行的回调。
# Parameters
| Name | Type | Description |
|---|---|---|
el | Element | 本次播放作用于的element。 |
# Returns
void
# onStop
▸ onStop(el): void
在动画停止时执行的回调。
# Parameters
| Name | Type | Description |
|---|---|---|
el | Element | 本次播放作用于的element。 |
# Returns
void
# onUpdate
▸ onUpdate(el, progress, reverse): void
在动画更新时执行的回调。
# Parameters
| Name | Type | Description |
|---|---|---|
el | Element | 本次播放作用于的element。 |
progress | number | 播放进度,范围为线性的0~1。 |
reverse | boolean | 本次播放是否反向。 |
# Returns
void
# Properties
# clipNames
• clipNames: string[]
动画所有的片段名字,必须在onInit中被初始化。
# Accessors
# scene
• get scene(): Scene
场景实例。