import { Object3D, Vector3, AnimationClip, Quaternion, Line3 } from "three"; import type { Curve, KeyframeTrack } from "three"; import { SampleOptions } from "@three3d/tools"; /** * createCurveAnimationClip 的类型 */ export type CreateCurveAnimationClipOptions = Partial & Partial; export interface CreateCurveAnimationClipReturn { clip: AnimationClip; curveLength: number | undefined; lengths: number[] | undefined; } export declare function createCurveAnimationClip(options: CreateCurveAnimationClipByCurveOptions): CreateCurveAnimationClipReturn; export declare function createCurveAnimationClip(options: CreateCurveAnimationClipByPolylineOptions): CreateCurveAnimationClipReturn; export declare function createCurveAnimationClip(options: CreateCurveAnimationClipOptions): CreateCurveAnimationClipReturn; /** * 路径动画时间选项 */ export interface PathAnimationTimeOptions { /** * 动画的持续时间 * @remarks * `duration` 和 `speed` 只需要指定其一;优先 duration */ duration?: number; /** * 动画的速度 * @remarks * `duration` 和 `speed` 只需要指定其一; */ speed?: number; } /** * 创建路径动画的选项 */ export type CreateCurveAnimationClip_Base = PathAnimationTimeOptions & CurveOptions; /** * 动画的基础选项 */ export interface CreateCurveAnimationClipOptions_Base { /** * 动画的名字 */ name: string; /** * 是否平滑旋转 * * @remarks * 当开启此功能后,当沿折线转弯时会平滑处理 * * @defaultValue true */ smooth?: boolean | null; } /** * 动画选项 */ export type CreateCurveAnimationClipByCurveOptions = CreateCurveAnimationClipOptions_Base & CreateKeyframeTrackOptions; /** * 创建曲线路径动画 * @param options * @returns */ export declare function createCurveAnimationClipByCurve(options: CreateCurveAnimationClipByCurveOptions): { clip: AnimationClip; curveLength: number | undefined; lengths: number[] | undefined; }; /** * createKeyframeTracksOfCurveAnimationByPolyline 新增的、所特有的选项 */ export interface CreateKeyframeTrackOptions_Base { /** * 应用动画的目标对象的访问路径 * @remarks * 相对于根对象 * * @defaultValue null */ targetPath?: string | null; /** * 观看点的距离 * @remarks * 表示看向前方多远处的位置 * * @defaultValue 0 */ lookDistance?: number | null; } export type CreateKeyframeTrackOptions = CreateKeyframeTrackOptions_Base & CreateCurveAnimationClip_Base & SampleOptions & Omit; /** * 创建关键帧轨道 * @param options - 选项 * @param targetPath - 轨道被应用的目标对象的路径 * @returns */ export declare function createKeyframeTracksOfCurveAnimation(options: CreateKeyframeTrackOptions): { keyframeTracks: KeyframeTrack[]; duration: number; curveLength: number | undefined; lengths: number[] | undefined; }; /** * 曲线选项 */ export interface CurveOptions { /** * 路径 * @remarks * 用来描述路径的曲线 */ curve: Curve; } /** * 获取曲线的分段数据的基本选项 */ export interface GetDivisionDataOptions_Base extends CurveOptions { /** * 动画的持续时间 * @remarks * `duration` 和 `speed` 只需要指定其一;优先 duration */ duration: number; } /** * 获取曲线的分段数据的选项 */ export interface GetDivisionsDataOptions extends GetDivisionDataOptions_Base { /** * 分隔的段数 * @remarks * 要将曲线划分为的分段数 */ division: number; } /** * 获取路径动画对象的持续时间 * @param options - 选项 * @returns */ export declare function getDurationOfPathAnimationOptions(options: PathAnimationTimeOptions, length?: number): number; /** * getKeyframeTransformDatas 的基础选项 */ export interface GetKeyframeTransformDatasOptions_Base { /** * 目标对象 * @remarks * 需要让哪个目标沿着曲线路径运行 */ target?: Object3D | null; /** * 表示目标对象在运动时的前方方向的向量 * @remarks * 该向量是目标对象局部坐标系下向量 * * 需要旋转数据时才需要 * * @defaultValue 默认曲线起始处的切线方向 */ front?: Vector3 | null; /** * 是否需要获取位置信息 * @defaultValue true */ position?: boolean | null; /** * 是否需要获取旋转信息 * @defaultValue true */ rotate?: boolean | null; /** * 是否启用up * @remarks * 启用 up 后,旋转时会考虑 up 方向 */ enableUp?: boolean | null; /** * 是否固定 up 方向 * @remarks * 默认情况下,会优先 front 方向,然后在 front 方向的基础上再调整 up 方向; * 如果 fixUp 为 true,则会优先保证 up 方向,然后再调整 front 方向 */ fixUp?: boolean | null; /** * 局部坐标系下 up 方向的向量 * @remarks * target 的局部坐标系 */ up?: Vector3 | null; /** * 锚点 * @remarks * 目标对象上局部坐标系下的一个位置,该位置会始终在曲线上;即让目标对象上的哪个位置沿曲线路径进行动画 * * @defaultValue 局部坐标系的原点 */ anchor?: Vector3 | null; /** * 观看点相关的选项 * @remarks * 观看点表示看向前方多远处的位置;默认是 0 * * 需要旋转数据时才需要 */ lookPoint?: LookPointOptionsOfKeyframes; } export interface GetKeyframeTransformDatasOptionsByCurve_Base extends GetKeyframeTransformDatasOptions_Base { /** * t的列表 * @remarks * ts 和 us 只需要指定其一;优先 ts; */ ts?: number[]; /** * u的列表 * @remarks * ts 和 us 只需要指定其一;优先 ts; */ us?: number[]; } /** * getKeyframeTransformDatas 的选项 */ export type GetKeyframeTransformDatasOptions = GetKeyframeTransformDatasOptionsByCurve_Base & CurveOptions; export interface LookPointOptions { /** * 观看点的距离 * @remarks * 表示看向前方多远处的位置 */ distance?: number | null; /** * 曲线总长度 */ curveLength?: number | null; } export interface LookPointOptionsOfKeyframes extends LookPointOptions { /** * 各个关键点位置片的长度 * @remarks * 只有需要计算 {@link GetKeyframeTransformDatasOptions.lookPoint} 时才需要,但也不是必须的; * * 在需要该选项时,传递该选项可以节约计算 */ lengths?: number[]; } /** * 获取目标沿运行运行的关键帧变换数据 * @param options * @returns */ export declare function getKeyframeTransformDatas(options: GetKeyframeTransformDatasOptions): { rotates: Quaternion[]; points: Vector3[]; curveLength: number | undefined; lengths: number[] | undefined; }; /** * 获取分段的 t 列表 * @param division - 分段 * @returns */ export declare function getTS(division: number): number[]; /** * 获取分段的时间列表 * @remarks * 假设沿曲线均速运动 * * @param options * @returns */ export declare function getTimes(options: GetDivisionsDataOptions): number[]; /** * 动画选项 */ export type CreateCurveAnimationClipByPolylineOptions = CreateCurveAnimationClipOptions_Base & CreateKeyframeTrackByPolylineOptions & SampleOptions; /** * 创建折线路径动画 * @param options * @returns */ export declare function createCurveAnimationClipByPolyline(options: CreateCurveAnimationClipByPolylineOptions): CreateCurveAnimationClipReturn; /** * createKeyframeTracksOfCurveAnimationByPolyline 的选项 */ export type CreateKeyframeTrackByPolylineOptions = CreateKeyframeTrackOptions_Base & PathAnimationTimeOptions & GetKeyframeTransformDatasByPolylineOptions; /** * 创建折线路径的关键帧轨道 * @param options - 选项 * @returns */ export declare function createKeyframeTracksOfCurveAnimationByPolyline(options: CreateKeyframeTrackByPolylineOptions): { keyframeTracks: KeyframeTrack[]; duration: number; lengths: number[]; curveLength: number; }; /** * 折线选项 */ export interface PolylineOptions { /** * 描述拆线路径的顶点列表 */ points: Vector3[]; } export interface GetKeyframeTransformDatasByPolylineOptions_Base extends Omit { /** * 时间列表 */ times: number[]; } /** * getKeyframeTransformDatasByPolyline 的选项 */ export type GetKeyframeTransformDatasByPolylineOptions = GetKeyframeTransformDatasByPolylineOptions_Base & PolylineOptions; /** * 获取目标沿运行运行的关键帧变换数据 * @param options * @param lines - 折线的线段列表,用于减少计算; * @returns */ export declare function getKeyframeTransformDatasByPolyline(options: GetKeyframeTransformDatasByPolylineOptions, lines?: Line3[]): { rotates: Quaternion[]; points: Vector3[]; rotateTimes: number[]; pointTimes: number[]; }; //# sourceMappingURL=path-animation.d.ts.map