Ontdek de code van Klaas

001import UIKit002import SceneKit003import ARKit004 005@available(iOS 11.3, *)006protocol ARViewDelegate: class {007 func didLoadView()008 func didPlaceModel()009 func didTapOnScene()010 func didTapBack()011 func didTapClose()012 func didFocusOnSurface()013 func didFocusOutSurface()014}015 016protocol ARViewProtocol: class {017 var viewData: ARViewData? { get set }018 func embedActions(_ controller: UIViewController)019 func embedInstructions(controller: UIViewController)020}021 022@available(iOS 11.3, *)023class ARViewController: UIViewController {024 025 @IBOutlet private weak var sceneView: ARSCNView!026 @IBOutlet private weak var footerContainer: UIView!027 @IBOutlet private weak var headerContainer: UIView!028 @IBOutlet private var gestures: [UIGestureRecognizer]!029 030 weak var delegate: ARViewDelegate?031 032 var viewData: ARViewData? {033   didSet {034     guard let viewData = viewData else { return }035 036     if viewData.alignment != oldValue?.alignment {037       updateAlignment(viewData.alignment)038     }039 040     if viewData.vibrate != oldValue?.vibrate, viewData.vibrate {041       SystemSoundService.play(systemSoundType: .peek)042     }043 044     if viewData.shouldRemoveModel {045       model.runAction(SCNAction.fadeOut(duration: 0.3)) {046         self.model.removeFromParentNode()047       }048     }049 050     model.scale(by: viewData.modelSize)051   }052 }053 054 // MARK: Private Properties055 056 private lazy var model: Model = {057   return Model(name: "tv")058 }()059 060 private var currentAngleY: Float = 0.0061 private var currentPosition: CGPoint?062 private var featurePointModel = FeaturePointNode()063 private var featurePoints: [FeaturePointNode] = []064 private let configuration = CoolblueAR.configurationType.init()065 private var tappedNode: SCNNode?
AR
Dit is echte code uit onze Coolblue App. Scroll er gerust doorheen.
Vorige
Volgende