【发布时间】:2023-03-28 01:33:01
【问题描述】:
我有由图像检测触发的 3D 对象。我添加了按钮,以便用户可以在不同的视图中查看对象,例如左、右、上、下等。我的代码有一个缺陷,因为旋转点是从最后一次触摸设置的。例如,如果你按右,它会变成 .pi/2,然后当你按左时它会变成 -.pi/2,将它重置回前视图而不是左视图。我如何能够设置一个原始的前原点,以便在每次按下后旋转“重置”并进入相应的视图?谢谢。
@IBAction func leftSideRotate(_ sender: UIButton) {
let rotate = SCNAction.rotateBy(x: 0, y: -.pi/2, z: 0, duration: 0.5)
sender.isEnabled = false
toggleButton = sender
activeNode?.runAction(rotate,completionHandler: enableButtonn)
}
func enableButtonn (){
toggleButton?.isEnabled = true
}
@IBAction func upSole(_ sender: UIButton) {
let rotate = SCNAction.rotateBy(x: -.pi/2, y: 0, z: 0, duration: 0.5)
sender.isEnabled = false
toggleButton = sender
activeNode?.runAction(rotate,completionHandler: enableButtonnn)
}
func enableButtonnn (){
toggleButton?.isEnabled = true
}
【问题讨论】:
标签: swift xcode rotation scenekit arkit