【发布时间】:2018-07-21 06:52:25
【问题描述】:
我正在使用 ARkit 构建一个应用程序,我希望用户能够使用视图控制器中的按钮来启动和停止场景中的动画。但是,我无法找到此代码的示例。任何指针将不胜感激。作为参考,我的代码如下,用于对 dae 文件进行动画处理。我有一个可以停止动画的版本,但无法让它重新启动。提前致谢。
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))
}
}
【问题讨论】:
标签: arkit