Created
March 26, 2019 06:23
-
-
Save Bilguun132/ce6164fa63d278c2e8a78b32a84f4c07 to your computer and use it in GitHub Desktop.
ARKit-Video-Tutorial-1
This file contains hidden or 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 | |
// Harry Pokker | |
// | |
// Created by Bilguun Batbold on 26/3/19. | |
// Copyright © 2019 Bilguun. 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 | |
} | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
// Create a session configuration | |
let configuration = ARImageTrackingConfiguration() | |
// first see if there is a folder called "ARImages" Resource Group in our Assets Folder | |
if let trackedImages = ARReferenceImage.referenceImages(inGroupNamed: "ARImages", bundle: Bundle.main) { | |
// if there is, set the images to track | |
configuration.trackingImages = trackedImages | |
// at any point in time, only 1 image will be tracked | |
configuration.maximumNumberOfTrackedImages = 1 | |
} | |
// 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment