SCNAnimationPlayer() 似乎在使用 SceneKit 时只播放动画的一小部分

SCNAnimationPlayer() Seems to be playing only small part of animation while using SceneKit

我在 Blender 中制作了一个动画并将其移动到 Xcode 并且它是从 .dae 文件转换而来的 通过 Xcode.

到 .scn

我可以在 Xcode 的场景图中播放动画,因为它是在 Blender 中设计的。

我正在加载几何体和动画并为动画对象创建节点。

我使用 SCNAnimationPlayer() 加载动画。代码如下。

let scene = SCNScene(named: "scene.scn")!
let geometry = scene.rootNode.childNode(withName: "animatedGeo",
                                              recursively:true).geometry!

let animationNode = SCNNode(geometry: geometry)


let armature = scene.rootNode.childNode(withName: "Armature", recursively: true)!
let animationPlayer = armature.animationPlayer(forKey: "action_container-Armature")!
animationNode.addAnimationPlayer(animationPlayer, forKey: "action_container-Armature")

rootNode.addChildNode(animationNode)

我没有以编程方式为 animationPlayer 设置任何内容,因为所有设置看起来 在 Xcode 的场景图 window 中正常。

然而,当场景加载时,我看到 iPhone 屏幕上的动画对象有一个小动作。 看起来只有第一个(父)骨骼动画正在部分播放。 我找不到为什么所有的动画都没有像在场景图中播放的那样播放。

是的,当我尝试以编程方式操纵我在 Blender 中设计和制作动画的对象而不是我在 Blender 中制作的动画时,我找到了如何做到这一点。

您需要做的是将 "Armature" 节点添加到您的场景节点。 这就是全部。您不必使用 SCNAnimationPlayer()。

let scene = SCNScene(named: "scene.scn")!

let myObjectArmaturNode = scene.rootNode.childNode(withName: "Armature", recursively: true)!

rootNode.addChildNode(myObjectArmaturNode)

就是这样。 动画运行起来就像在 Blender 中设计的那样。 顺便说一句,动画由4块骨头组成。