You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Blender带动画模型导入RealityKit后动画丢失,如何解决?

问题:USDZ模型导入RealityKit后无法读取动画

我在Blender中制作了一个带动画的cube model,开启bake animation选项后导出为.fbx文件。使用Reality Converter将该.fbx文件转换为.usdz格式并导入到我的Xcode项目中。但在项目中无法恢复动画,代码如下:

import SwiftUI
import RealityKit

struct ContentView : View {
    var body: some View {
        ARViewContainer().edgesIgnoringSafeArea(.all)
    }
}

struct ARViewContainer: UIViewRepresentable {
    
    let arView = ARView(frame: .zero)
    
    func makeUIView(context: Context) -> ARView {
        
        let anchorEntity = AnchorEntity()
        
        //get local usdz file which is in xcode project
        do {               
            let cubeModel = try ModelEntity.load(named: "cube")
            print(cubeModel)                
            print(cubeModel.availableAnimations) // here i get an empty array

            anchorEntity.addChild(cubeModel)               
            arView.scene.addAnchor(anchorEntity)
          }
          catch {
             print(error)
          }
        return arView   // the cube is visible on my ipad  
    }        
    func updateUIView(_ uiView: ARView, context: Context) { }
}

模型能在iPad上正常显示,但cubeModel.availableAnimations输出为空数组,请问我遗漏了什么步骤?


解决方案

一、Blender导出FBX时的关键检查

  • 烘焙动画时,确认选中目标立方体,设置正确的起始帧和结束帧,勾选对应烘焙选项(如果是关键帧动画选烘焙到关键帧,骨骼动画选烘焙到骨骼),确保所有动画关键帧都被烘焙到对象本身,而非仅保留动作数据。
  • 导出FBX的动画选项卡里必须勾选:
    • 烘焙动画
    • 选中的对象
    • 烘焙所有动作(多动作场景)
      同时取消勾选「仅关键帧」,避免丢失动画曲线细节。
  • FBX版本选择FBX 7.4或更高,提升与Reality Converter的兼容性。

二、Reality Converter转换环节

  • 导入FBX后,先查看左侧面板的动画标签,确认是否能识别到动画轨道。如果没有显示,说明FBX的动画信息没被正确导出,回到Blender重新调整设置。
  • 转换为USDZ时,确认勾选「保留动画」选项(默认勾选,但建议手动检查)。

三、RealityKit加载时的细节

  • 动画可能嵌套在子实体中,而非根ModelEntity。可以遍历所有子节点检查:
    func scanAnimations(in entity: Entity) {
        if let model = entity as? ModelEntity {
            print("\(model.name) 的动画列表:\(model.availableAnimations)")
        }
        entity.children.forEach { scanAnimations(in: $0) }
    }
    // 加载模型后调用
    scanAnimations(in: cubeModel)
    
  • 如果是骨骼绑定的动画,需检查entity.animationControllers,或通过AnimationResource手动加载并播放。

四、Xcode项目配置

  • 确认USDZ文件已添加到项目的Copy Bundle Resources中(Build Phases -> Copy Bundle Resources),避免加载未打包的旧文件。
  • 用Reality Composer打开USDZ文件测试动画:如果Reality Composer里也无法播放,问题出在导出/转换环节;如果能播放,就是代码加载逻辑需要调整。

内容的提问来源于stack exchange,提问作者saro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 10:55:23