SceneKit:使用骨骼动画渲染两个 SCNNode 时发生错误

SceneKit: Error occur while rendering two SCNNodes with skeletal animations

我尝试使用以下代码加载骨骼动画:

let file = Bundle.main.url(forResource: name, withExtension: "dae")
let source = SCNSceneSource(url: file!, options: nil)
let  node = SCNNode()
for n in try! (source?.scene(options: nil).rootNode.childNodes)! as [SCNNode] {
    node.addChildNode(n)
}
let animationIDs = source?.identifiersOfEntries(withClass: CAAnimation.self)
var animationArray:[CAAnimation] = []
for id in animationIDs!{
    let animation = source?.entryWithIdentifier(id, withClass: CAAnimation.self)
    animationArray.append(animation!)
}
let animationGroup = CAAnimationGroup()
animationGroup.animations = animationArray
animationGroup.duration = 1000
animationGroup.repeatCount = 1000
animationGroup.beginTime = 0
node.addAnimation(animationGroup, forKey: "Animation")
scene.rootNode.addChildNode(node)

起初它与主要英雄节点一起工作成功。骨骼动画看起来不错。但是当我创建敌人节点时,我在游戏场景加载后收到以下错误:

validateFunctionArguments:2665: failed assertion `(length - offset)(10992) must be >= 12304 at buffer binding at index 1 for scn_node[0].'

所以这有什么问题吗?看来我还是可以加载其他没有骨骼动画的模型,而且这些动画还是可以运行完美。但这是否意味着SceneKit只允许我们在一个特定的SCNNode上加载骨骼动画?

如果您知道该错误,请帮我解决... 如果您对如何从 dae 文件加载骨骼动画有更好的解决方案,请分享... 非常感谢你...

这可能是 SceneKit 中的错误,或者是金属验证层的误报。

您可以尝试 disable the validation layer in your scheme options 或尝试在 Xcode 之外打开您的应用程序,以查看骨骼动画是否正常工作以及错误是否无关紧要。