Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. func arSwitch() {
  2. case btnPressed arkit = false
  3. case btnpressed arkit = true
  4. }
  5.  
  6. @IBAction func arBtnpressed(_ sender: Any) {
  7.  
  8. if arSwitch.isOn {
  9. sceneView.scene = scene
  10. } else {
  11. sceneView.scene.stop()// Somehthing like this..
  12. }
  13. }
  14.  
  15. if arSwitch.isOn {
  16. let configuration = ARWorldTrackingConfiguration()
  17. sceneView.session.run(configuration)
  18.  
  19. } else {
  20. sceneView.session = nil
  21. }
  22.  
  23. }
  24.  
  25. import ARKit
  26.  
  27. class ViewController: UIViewController, ARSCNViewDelegate {
  28.  
  29. @IBOutlet var sceneView: ARSCNView!
  30. @IBOutlet weak var button: UIButton!
  31. @IBOutlet weak var label: UILabel!
  32. var count: Int = 1
  33. let configuration = ARWorldTrackingConfiguration()
  34.  
  35. override func viewDidLoad() {
  36. super.viewDidLoad()
  37. sceneView.delegate = self
  38. label.text = "On"
  39. let scene = SCNScene(named: "art.scnassets/model.scn")!
  40. sceneView.scene = scene
  41. }
  42. override func viewWillAppear(_ animated: Bool) {
  43. super.viewWillAppear(animated)
  44. sceneView.session.run(configuration)
  45. }
  46. override func viewWillDisappear(_ animated: Bool) {
  47. super.viewWillDisappear(animated)
  48. sceneView.session.pause()
  49. }
  50. @IBAction func arButtonPressed(_ sender: Any) {
  51. count += 1
  52.  
  53. if count % 2 == 0 {
  54. sceneView.session.pause()
  55. label.text = "OFF"
  56. } else if count % 2 == 1 {
  57. sceneView.session.run(configuration)
  58. label.text = "On"
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement