I'm building an app with ARkit and I'd like the user to have the ability to start and stop animations in the scene with the use of a button in the viewcontroller. However, I am having trouble finding an example of this code. Any pointers would be appreciated. For reference, my code is as follows for animating the dae file. I had a version working where I could stop the animation, but could not get it to restart. Thanks in advance.
func loadModels(atom: String) {
// Create a new scene
let scene = SCNScene(named: "art.scnassets/" + atom + ".scn")!
// Set the scene to the view
sceneViewAr?.scene = scene
let mainnode = scene.rootNode.childNode(withName: "mainnode", recursively: true)
mainnode?.runAction(SCNAction.rotateBy(x: 10, y: 0, z: 0, duration: 0))
let orbit = scene.rootNode.childNode(withName: "orbit", recursively: true)
orbit?.runAction(SCNAction.rotateBy(x: 0, y: 2 * 50, z: 0, duration: 100))
if let orbittwo = scene.rootNode.childNode(withName: "orbit2", recursively: true) {
orbittwo.runAction(SCNAction.rotateBy(x: 0, y: -2 * 50, z: 0, duration: 100))
}
if let orbitthree = scene.rootNode.childNode(withName: "orbit3", recursively: true) {
orbitthree.runAction(SCNAction.rotateBy(x: 0, y: 2 * 50, z: 0, duration: 100))
}
}