feat(编辑器): 支持导入 GLB/GLTF 模型并驱动角色动画

- 新增 GLB/GLTF 模型加载与渲染,支持内嵌动画播放
- 通过 IndexedDB 持久化大体积模型二进制,规避 localStorage 限制
- 新增动作片段序列,时间轴可添加、编辑与编排多段动作
- 优化机位视角相机同步,修复角度修改不生效问题
- 扩展骨骼识别,兼容 Mixamo 前缀及 UE4 骨架
This commit is contained in:
2026-09-18 18:23:13 +08:00
parent 9d3a5b9bea
commit 38dc27501a
36 changed files with 1899 additions and 427 deletions

View File

@@ -70,6 +70,24 @@ export interface SceneSettings {
/** 基础动作类型:none=不应用循环,idle/walk/run 由 ProceduralMannequin 按 time 驱动。 */
export type MotionKind = "none" | "idle" | "walk" | "run";
/**
* 单个动作片段:角色在时间轴上某段区间内播放的基础动作(待机 / 行走 / 跑步)。
* 同一角色可叠加多个片段(动作序列,如先走再跑)。片段之间允许重叠,
* 播放时「后定义的片段」覆盖先定义的片段(最后覆盖者胜)。
* `end` 为非有限值(Infinity)时表示一直播放到时间轴末尾。
*/
export interface MotionClip {
id: string;
kind: MotionKind;
speed: number;
amplitude: number;
enabled: boolean;
/** 片段起点(秒):角色在此之前保持静止。 */
start: number;
/** 片段终点(秒):非有限值表示到时间轴末尾。 */
end: number;
}
/** 单个角色的「动作」配置。当前 MVP 只接通 walk,其它类型字段保留以便后续扩。 */
export interface CharacterMotionState {
kind: MotionKind;
@@ -87,6 +105,10 @@ export interface CharacterRigState {
controls: Record<string, number>;
/** 缺省视为 { kind: "none", speed: 1, amplitude: 1, enabled: true };旧工程无需迁移。 */
motion?: CharacterMotionState;
/** 时间轴上的动作片段序列(多段不重叠动作)。缺省为空 → 回退到单一 `motion` 字段。 */
motionClips?: MotionClip[];
/** 当该角色几何来自「导入的 GLB/GLTF 资产」时,指向该资产 id;渲染用其 url 加载人形模型并驱动动作。 */
modelAssetId?: string;
}
export interface DirectorAssetRef {
@@ -98,6 +120,12 @@ export interface DirectorAssetRef {
url: string;
assetSource?: DirectorAssetSource;
projectionMode?: PanoramaProjectionMode;
/**
* GLB/GLTF 等二进制模型的 IndexedDB 存储 id。
* 存在时 localStorage 只保存轻量元数据(url 置空),运行时再从 IndexedDB 还原 objectURL,
* 避免大文件 base64 撑爆 localStorage。
*/
binaryId?: string;
}
/**