无法从ARKit中的SceneView获取SCNNode

时间:2017-07-17 12:52:39

标签: swift scenekit augmented-reality arkit scnnode

我正试图移动SCNNode而我正在使用this solution

但是当我这样做时:

let start = sceneView.node(for: first)

我的应用程序死机,Xcode没有做任何事情。

修改

func startBouncing(time: TimeInterval) {

    guard let sceneView = self.view as? ARSCNView,
    let first = anchors.first, 
    let start = sceneView.node(for: first),
    let last = anchors.last, 
    let end = sceneView.node(for: last)
    else { return }

    if ballNode.parent == nil {
        sceneView.scene.rootNode.addChildNode(ballNode)
    }

    let animation = CABasicAnimation(keyPath: #keyPath(SCNNode.transform))
    animation.fromValue = start.transform
    animation.toValue = end.transform
    animation.duration = time
    animation.autoreverses = true
    animation.repeatCount = .infinity
    ballNode.removeAllAnimations()
    ballNode.addAnimation(animation, forKey: nil)
} 

0 个答案:

没有答案