@realsee/five
Version:
Realsee Renderer SDK
39 lines (38 loc) • 1.62 kB
TypeScript
type MotionValue<K extends string> = Record<K, number>;
type MotionConfig<K extends string> = Record<K, {
circle: MotionCircle | false;
}>;
type MotionInitalValue<K extends string> = Record<K, MotionValue<K>[K] | ({
value: MotionValue<K>[K];
} & MotionConfig<K>[K])>;
interface MotionKeyframe<K extends string> {
progress: number;
value: MotionValue<K>;
key?: string;
}
/** 是否是循环变化,比如 [0, 2 * Math.PI], 前闭后开 */
type MotionCircle = [number, number];
type ValueOfMotion<M> = M extends Motion<infer K> ? MotionValue<K> : never;
type KeyframeOfMotion<M> = M extends Motion<infer K> ? MotionKeyframe<K> : never;
declare class Motion<K extends string> {
config: MotionConfig<K>;
value: MotionValue<K>;
progress: number;
ended: boolean;
startTime: number;
startVelocity: number;
duration: number;
keyframes: MotionKeyframe<K>[];
private callbacks?;
constructor(initalValue: MotionInitalValue<K>);
private getProgress;
private getValue;
getProgressVelocity(time: number): number;
update(time: number): boolean;
getKeyFrameSegment(time: number): [MotionKeyframe<K>, MotionKeyframe<K>];
getTargetKeyframe(): MotionKeyframe<K>;
set(value: Partial<MotionValue<K>>, duration: number, startProgressVelocity?: number, time?: number): Promise<void>;
setKeyframes(keyframes: MotionKeyframe<K>[], duration: number, startProgressVelocity?: number, time?: number): Promise<void>;
dispose(): void;
}
export { Motion, MotionCircle, MotionValue, MotionInitalValue, MotionKeyframe, ValueOfMotion, KeyframeOfMotion };