Created
October 1, 2017 03:25
-
-
Save iannase/69c76a63ad9c09d21a33f46ead3169c1 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 | |
// ARDicee | |
// | |
// Created by Ian on 9/30/17. | |
// Copyright © 2017 IanAnnase. 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 | |
let cube = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 0.01) | |
let material = SCNMaterial() | |
material.diffuse.contents = UIColor.red | |
cube.materials = [material] | |
let node = SCNNode() | |
node.position = SCNVector3(x: 0, y: 0.1, z: -0.5) | |
node.geometry = cube | |
sceneView.scene.rootNode.addChildNode(node) | |
sceneView.autoenablesDefaultLighting = 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() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment