Swift3 iOS 11中不推荐使用CAAnimation-需要最新答案吗?

Swift3 iOS 11中不推荐使用CAAnimation-需要最新答案吗?,swift3,scenekit,ios11,caanimation,arkit,Swift3,Scenekit,Ios11,Caanimation,Arkit,好的,我已经到处找过了,我想在这里简单地从导入Xcode(或.scn,无论什么)的.dae中提取一个动画,这样我就可以在整个场景工具包游戏中在模型上运行它。问题在于所引用的所有方法(包括此处) 似乎在iOS 11中已被弃用。所以我没有办法给我放在场景中的任何3D模型设置动画 现在,我可以使用此选项显示模型-我从dae获取模型并将其放入空白scn: if let d = modelScene.rootNode.childNodes.first { theDu

好的,我已经到处找过了,我想在这里简单地从导入Xcode(或.scn,无论什么)的.dae中提取一个动画,这样我就可以在整个场景工具包游戏中在模型上运行它。问题在于所引用的所有方法(包括此处)

似乎在iOS 11中已被弃用。所以我没有办法给我放在场景中的任何3D模型设置动画

现在,我可以使用此选项显示模型-我从dae获取模型并将其放入空白scn:

if let d = modelScene.rootNode.childNodes.first
        {
            theDude.node = d
            theDude.setupNode() //this scales it down
        }
func setupNode()
    {
        node.scale = SCNVector3(x: modifier, y: modifier, z: modifier)
}

//Then add to scene on tap

let clone = theDude.node.clone()
            theDude.node = clone
            self.sceneView.scene.rootNode.addChildNode(theDude.node)
            theDude.node.position = hitPosition
这很有效。但是,尝试让它运行我在Maya中添加到它中的动画却不会。我在我的项目中根据苹果的例子添加了以下扩展:

我试着按照它说的那样做,只是用一个立方体作为基本测试(从上面的问题):

但是有了这个
CAAnimation.animationwithscenename(“art.scnassets/cubeAnimatedSkeleton.dae”)整个事情都不起作用,因为这个来自苹果的扩展:

extension CAAnimation {
    class func animationWithSceneNamed(_ name: String) -> CAAnimation? {
        var animation: CAAnimation?
        if let scene = SCNScene(named: name) {
            scene.rootNode.enumerateChildNodes({ (child, stop) in
                if child.animationKeys.count > 0 {
                    animation = child.animation(forKey: child.animationKeys.first!) //ERROR

                    stop.initialize(to: true)
                }
            })
        }
        return animation
    }
}
表示iOS 11中不推荐使用addAnimation for key。用
animation=child.animationPlayer(forKey:child.animationKeys.first!)
替换它不起作用,我不知道还能做什么

这里怎么了

extension CAAnimation {
    class func animationWithSceneNamed(_ name: String) -> CAAnimation? {
        var animation: CAAnimation?
        if let scene = SCNScene(named: name) {
            scene.rootNode.enumerateChildNodes({ (child, stop) in
                if child.animationKeys.count > 0 {
                    animation = child.animation(forKey: child.animationKeys.first!) //ERROR

                    stop.initialize(to: true)
                }
            })
        }
        return animation
    }
}