代码测试
//旋转手势
let rotationGesture = UIRotationGestureRecognizer(target: self, action: #selector(didRotate(_:)))
sceneView.addGestureRecognizer(rotationGesture)
@objc
func didRotate(_ gesture: UIRotationGestureRecognizer) {
guard gesture.state == .changed else { return }
guard let node = node else { return }
node.eulerAngles.y -= Float(gesture.rotation)
gesture.rotation = 0
}
![](https://img.haomeiwen.com/i1638260/4ea50b7afaf9098d.png)
![](https://img.haomeiwen.com/i1638260/17d17076f3dc40e2.gif)
旋转比较简单,不涉及到复杂的矩阵运算,自己对应修改不同的轴的角度就好.
网友评论