Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func arSwitch() {
- case btnPressed arkit = false
- case btnpressed arkit = true
- }
- @IBAction func arBtnpressed(_ sender: Any) {
- if arSwitch.isOn {
- sceneView.scene = scene
- } else {
- sceneView.scene.stop()// Somehthing like this..
- }
- }
- if arSwitch.isOn {
- let configuration = ARWorldTrackingConfiguration()
- sceneView.session.run(configuration)
- } else {
- sceneView.session = nil
- }
- }
- import ARKit
- class ViewController: UIViewController, ARSCNViewDelegate {
- @IBOutlet var sceneView: ARSCNView!
- @IBOutlet weak var button: UIButton!
- @IBOutlet weak var label: UILabel!
- var count: Int = 1
- let configuration = ARWorldTrackingConfiguration()
- override func viewDidLoad() {
- super.viewDidLoad()
- sceneView.delegate = self
- label.text = "On"
- let scene = SCNScene(named: "art.scnassets/model.scn")!
- sceneView.scene = scene
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- sceneView.session.run(configuration)
- }
- override func viewWillDisappear(_ animated: Bool) {
- super.viewWillDisappear(animated)
- sceneView.session.pause()
- }
- @IBAction func arButtonPressed(_ sender: Any) {
- count += 1
- if count % 2 == 0 {
- sceneView.session.pause()
- label.text = "OFF"
- } else if count % 2 == 1 {
- sceneView.session.run(configuration)
- label.text = "On"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement