import { Tween } from 'three/examples/jsm/libs/tween.module.js'; import { Vector3, Euler } from 'three'; import { IVector3 } from './base'; type AnimationModeType = 'Linear.None' | 'Quadratic.In' | 'Quadratic.Out' | 'Quadratic.InOut' | 'Cubic.In' | 'Cubic.Out' | 'Cubic.InOut' | 'Quartic.In' | 'Quartic.Out' | 'Quartic.InOut' | 'Quintic.In' | 'Quintic.Out' | 'Quintic.InOut' | 'Sinusoidal.In' | 'Sinusoidal.Out' | 'Sinusoidal.InOut' | 'Exponential.In' | 'Exponential.Out' | 'Exponential.InOut' | 'Circular.In' | 'Circular.Out' | 'Circular.InOut' | 'Elastic.In' | 'Elastic.Out' | 'Elastic.InOut' | 'Back.In' | 'Back.Out' | 'Back.InOut' | 'Bounce.In' | 'Bounce.Out' | 'Bounce.InOut'; type AnimationModeValueType = (amount: number) => number; interface AnimationOptions { duration?: number; delay?: number; repeat?: number | boolean; mode?: AnimationModeType; yoyo?: boolean; } /** * 剪辑动画 —— 单个关键帧 * * @remarks * 字段与 bimeditor `IAnimationKeyframe` 协议对齐,可直接将服务端数据传入 * `ssp.playClipAnimation` 而不需要任何字段映射。 * * - `position` / `scale` 单位为模型世界单位 * - `rotation` 为欧拉角,**单位:弧度**(与 three.js `Euler` 一致) * - `repeat = -1` 解释为 `Infinity` */ interface IClipAnimationFrame { /** 关键帧业务 ID(SDK 内部不使用) */ id?: string; /** 目标 position */ position: IVector3; /** 目标 rotation(欧拉角,弧度) */ rotation: IVector3; /** 目标 scale */ scale: IVector3; /** 缓动曲线名称 */ easing: AnimationModeType; /** 持续时间(毫秒),默认 `1000` */ duration?: number; /** 起始延迟(毫秒),默认 `0` */ delay?: number; /** 重复次数;`-1` 视为无限循环;默认 `0`(不重复) */ repeat?: number; /** 是否往返播放,默认 `false` */ yoyo?: boolean; /** 帧排序索引;SDK 在播放前会按此字段升序排序 */ index?: number; /** 业务保留字段(与 SDK 内部行为无关) */ mode?: string; } /** * 剪辑动画 * * @remarks * 字段与 bimeditor `IAnimationClip` 协议对齐。`refId` 是目标对象的标识, * SDK 在 `model` 子树内按 `sid → uuid → userData.key` 顺序查找命中节点。 */ interface IClipAnimation { /** 剪辑业务 ID(SDK 内部不使用) */ id?: string; /** 剪辑名称(SDK 内部不使用) */ name?: string; /** 目标对象的 sid / uuid / userData.key */ refId: string; /** 关键帧列表(按 {@link IClipAnimationFrame.index} 升序播放) */ keyframes: IClipAnimationFrame[]; } /** * 剪辑动画 —— 初始 / 中间 transform 快照 * @internal 由 `ClipAnimationPlayer.initTransform` 记录,供 `reset` 还原使用 */ interface IClipTransform { position: Vector3 | IVector3; rotation: Euler | IVector3; scale: Vector3 | IVector3; } /** * 剪辑动画 —— tween 内部使用的扁平 9 通道数据 * @internal 把 position / rotation / scale 拍平成 tween 能补间的标量集合 */ interface IClipTweenSource { x: number; y: number; z: number; rotationX: number; rotationY: number; rotationZ: number; scaleX: number; scaleY: number; scaleZ: number; } /** * 剪辑动画 —— 播放器事件 * * - `update`:每帧 tween 更新时触发,`source` 为当前帧的 9 通道值 * - `start` :每段 tween 开始时触发 */ interface IClipAnimationPlayerEventMap { update: { source: IClipTweenSource; tween: Tween; }; start: { tween: Tween; }; } export { AnimationModeType, AnimationModeValueType, AnimationOptions, IClipAnimationFrame, IClipAnimation, IClipTransform, IClipTweenSource, IClipAnimationPlayerEventMap, };