我使用渲染器(_:updateAtTime :)函数来改变场景中对象的位置
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
cylinder.position = SCNVector3(0, sin(time), 0)
}
所以,如果我想停止在ARSCNView中显示的场景,我尝试使用以下代码
ARSceneView.scene.isPaused = true
但它没有帮助,所以我的对象仍然移动而不是保持原位(因为渲染器功能仍然被称为每帧)
那么如何在ARSCNView中停止场景?或者如何停止调用渲染器(_:updateAtTime :)函数?
我还没有找到如何停止renderer(_:updateAtTime:)
实例方法的解决方案。我可以为您提供简单而强大的解决方法:
let action = SCNAction.move(by: SCNVector3(0, sin(time), 0), duration: 2)
let repeatAction = SCNAction.repeat(action, count: 1)
cylinderNode.runAction(repeatAction)
希望这可以帮助。