soonspacejs
Version:
soonspacejs 2.x
109 lines (108 loc) • 2.54 kB
TypeScript
import { Vector3 } from 'three';
import type { Object3D } from 'three';
import type { Tween } from 'three/examples/jsm/libs/tween.module.js';
import { IVector3 } from '../Interface';
/**
* 路径动画选项
*/
export interface PathAnimationOptions {
/**
* 移动速度
*/
speed?: number;
/**
* 反向播放
*/
reverse?: boolean;
/**
* 是否需要旋转
*/
needsRotate?: boolean;
/**
* 位置更新回调
* @remarks
* 每当目标位置有更新时会触发
*/
onUpdate?: (position: Vector3, tween: Tween<Vector3>) => void;
/**
* 动画开始时回调
*/
onStart?: (tween: Tween<Vector3>) => void;
/**
* 每段 tween 动画开始时回调
* @param tween
*/
onEveryStart?: (tween: Tween<Vector3>) => void;
/**
* 当到达一个点时回调
*/
onPoint?: (index: number, point: Vector3) => void;
}
/**
* 路径动画
*/
export declare class PathAnimation implements PathAnimationOptions {
target: Object3D;
points: IVector3[];
/**
*
* @param target - 被动画的目标对象
* @param points - 路径点列表
* @param options - 选项
*/
constructor(target: Object3D, points: IVector3[], options?: PathAnimationOptions);
/**
* 移动速度
*/
speed: number;
/**
* 反向播放
*/
reverse: boolean;
/**
* 是否需要旋转
*/
needsRotate: boolean;
/**
* 位置更新回调
* @remarks
* 每当目标位置有更新时会触发
*/
onUpdate?: (position: Vector3, tween: Tween<Vector3>) => void;
/**
* 动画开始时回调
*/
onStart?: (tween: Tween<Vector3>) => void;
/**
* 每段 tween 动画开始时回调
* @param tween
*/
onEveryStart?: (tween: Tween<Vector3>) => void;
/**
* 当到达一个点时回调
*/
onPoint?: (index: number, point: Vector3) => void;
/**
* 当前目标点的索引
*/
index: number;
/**
* 是否正在播放
*/
get isPlaying(): boolean;
protected _tween?: Tween<any> | null;
/**
* 播放
*/
play(): Promise<boolean | undefined>;
protected _play(points: IVector3[]): Promise<true | undefined>;
/**
* 暂停
*/
pause(): void;
resume(): void;
/**
* 停止
*/
stop(): void;
}