Created
March 4, 2019 05:51
-
-
Save rajajawahar/e26f18b1f30a5ede5bec3b18f5df25a8 to your computer and use it in GitHub Desktop.
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
// | |
// ViewController.swift | |
// eam360ar | |
// | |
// Created by Raja Jawahar on 04/03/19. | |
// Copyright © 2019 Raja Jawahar. All rights reserved. | |
// | |
import UIKit | |
import SceneKit | |
import ARKit | |
class ViewController: UIViewController, ARSCNViewDelegate { | |
@IBOutlet var sceneView: ARSCNView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Set the view's delegate | |
sceneView.delegate = self | |
// Show statistics such as fps and timing information | |
sceneView.showsStatistics = true | |
// Create a new scene | |
let scene = SCNScene(named: "art.scnassets/ship.scn")! | |
// Set the scene to the view | |
sceneView.scene = scene | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
// Create a session configuration | |
let configuration = ARWorldTrackingConfiguration() | |
// Run the view's session | |
sceneView.session.run(configuration) | |
} | |
override func viewWillDisappear(_ animated: Bool) { | |
super.viewWillDisappear(animated) | |
// Pause the view's session | |
sceneView.session.pause() | |
} | |
// MARK: - ARSCNViewDelegate | |
/* | |
// Override to create and configure nodes for anchors added to the view's session. | |
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { | |
let node = SCNNode() | |
return node | |
} | |
*/ | |
func session(_ session: ARSession, didFailWithError error: Error) { | |
// Present an error message to the user | |
} | |
func sessionWasInterrupted(_ session: ARSession) { | |
// Inform the user that the session has been interrupted, for example, by presenting an overlay | |
} | |
func sessionInterruptionEnded(_ session: ARSession) { | |
// Reset tracking and/or remove existing anchors if consistent tracking is required | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment