0
我试图加载骨骼动画与下面的代码错误发生:SceneKit:在渲染2个SCNNodes与骨骼动画
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文件加载骨骼动画更好的解决方案,请分享... 非常感谢你...