Created
January 17, 2019 11:39
-
-
Save shrawan2015/a14f3bf560cc1dabfc5def0265302bd5 to your computer and use it in GitHub Desktop.
rotation object in ARKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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