代码测试
//旋转手势
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
}
旋转属性
效果图
旋转比较简单,不涉及到复杂的矩阵运算,自己对应修改不同的轴的角度就好.
网友评论