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

RealityKit播放预定义动画时BlendShapes无法正常工作的问题求助

RealityKit播放预定义动画时BlendShapes无法正常工作的问题求助

问题背景

我最近在RealityKit 3.0+里遇到了一个棘手的问题:当播放.usdz模型自带的预定义角色动画时,没法同时正常驱动BlendShapes(形状键)的动画。

我想实现的效果是:让角色播放一段预定义的肢体动画(比如挥手动作)的同时,用BlendShapeWeightsComponent叠加面部表情动画(比如眨眼、嘴唇开合)。在没有播放任何预定义动画的时候,手动驱动形状键的逻辑完全正常,但一旦调用entity.playAnimation()播放模型自带的动画,形状键的视觉更新就完全失效了——虽然日志里显示数值确实在变化,但画面上根本看不到效果。

在SceneKit里用同一个模型测试时,形状键和骨骼动画可以完美同时播放,所以我怀疑是不是RealityKit有什么特殊的限制,或者我在实现方式上漏掉了关键步骤?

我的当前设置

  • 模型:从Blender导出的.usdz格式绑定骨骼的角色模型,内置BlendShapes和预定义动画
  • 手动驱动形状键的核心代码如下:
func setBlendShapes(_ blendShapes: [String: Float]) {
    guard let root = modelEntity, 
          let armatureEntity = findEntity(named: "Armature", in: root), 
          var blendShapeComponent = armatureEntity.components[BlendShapeWeightsComponent.self] 
    else { return }
    
    let weightNames = blendShapeComponent.weightSet[0].weightNames
    var weights = blendShapeComponent.weightSet[0].weights
    
    for (blendShapeName, weight) in blendShapes {
        if let index = weightNames.firstIndex(of: blendShapeName) {
            weights[index] = weight
        }
    }
    
    blendShapeComponent.weightSet[0].weights = weights
    armatureEntity.components.set(blendShapeComponent)
}

这段代码在不播放预定义动画时工作完全正常,面部表情能正确显示。

问题触发场景

一旦我执行类似下面的代码播放预定义动画后,上面的形状键更新逻辑就失效了:

modelEntity.playAnimation(trimmedAnimation)

求助问题

有没有办法在RealityKit中,让BlendShapes和模型自带的骨骼动画同时播放/更新?这是RealityKit的固有限制吗?如果需要,我可以提供用于复现问题的Demo项目。


内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.07 12:28:04