Skip to content

Instantly share code, notes, and snippets.

@shrawan2015
Created January 17, 2019 11:39
Show Gist options
  • Save shrawan2015/a14f3bf560cc1dabfc5def0265302bd5 to your computer and use it in GitHub Desktop.
Save shrawan2015/a14f3bf560cc1dabfc5def0265302bd5 to your computer and use it in GitHub Desktop.
rotation object in ARKit
let rotationGesture = UIRotationGestureRecognizer(target: self, action: #selector(viewRotated))
sceneView.addGestureRecognizer(rotationGesture)
@objc private func viewRotated(_ gesture: UIRotationGestureRecognizer) {
let location = gesture.location(in: sceneView)
guard let node = self.object(at: location) else { return }
switch gesture.state {
case .began:
originalRotation = object.eulerAngles
case .changed:
guard var originalRotation = originalRotation else { return }
originalRotation.y -= Float(gesture.rotation)
object.eulerAngles = originalRotation
default:
originalRotation = nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment