├── .gitignore ├── ARGuide.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── dwyszy.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── dwyszy.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ARWalkthrough.xcscheme │ └── xcschememanagement.plist ├── ARGuide ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── iPhone_120pt_@2x.png │ │ ├── iPhone_120pt_@3x.png │ │ ├── iPhone_180pt_@3x.png │ │ ├── iPhone_40pt_@1x.png │ │ ├── iPhone_58pt_@2x.png │ │ ├── iPhone_60pt_@1x.png │ │ ├── iPhone_80pt_@2x.png │ │ ├── iPhone_87pt_@3x.png │ │ └── iTunes_1024pt_@2x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Models │ ├── ORB_Body_Diff.png │ ├── ORB_Circles_Diff.png │ ├── ORB_Eye_Diff.png │ └── sphere.dae ├── Objects │ └── Sphere.swift ├── Scenes │ └── HoverScene.swift ├── Utilities │ ├── Node+Extensions.swift │ ├── SCNVector3+Extensions.swift │ └── UtilityExtensions.swift └── ViewController.swift ├── LICENSE ├── README.md └── eye_patrol.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /ARGuide.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 09206D3D205097EB00A04B19 /* SCNVector3+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09206D3C205097EB00A04B19 /* SCNVector3+Extensions.swift */; }; 11 | 09206D3F205187B500A04B19 /* UtilityExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09206D3E205187B500A04B19 /* UtilityExtensions.swift */; }; 12 | 092A3E7820372FCB006A8935 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092A3E7720372FCB006A8935 /* AppDelegate.swift */; }; 13 | 092A3E7C20372FCB006A8935 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092A3E7B20372FCB006A8935 /* ViewController.swift */; }; 14 | 092A3E7F20372FCB006A8935 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 092A3E7D20372FCB006A8935 /* Main.storyboard */; }; 15 | 092A3E8120372FCB006A8935 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 092A3E8020372FCB006A8935 /* Assets.xcassets */; }; 16 | 092A3E8420372FCB006A8935 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 092A3E8220372FCB006A8935 /* LaunchScreen.storyboard */; }; 17 | 092A3E8E2039E240006A8935 /* HoverScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 092A3E8D2039E240006A8935 /* HoverScene.swift */; }; 18 | 0953926F204EE1930069F35A /* ORB_Body_Diff.png in Resources */ = {isa = PBXBuildFile; fileRef = 0953926C204EE1920069F35A /* ORB_Body_Diff.png */; }; 19 | 09539270204EE1930069F35A /* ORB_Eye_Diff.png in Resources */ = {isa = PBXBuildFile; fileRef = 0953926D204EE1920069F35A /* ORB_Eye_Diff.png */; }; 20 | 09539271204EE1930069F35A /* ORB_Circles_Diff.png in Resources */ = {isa = PBXBuildFile; fileRef = 0953926E204EE1930069F35A /* ORB_Circles_Diff.png */; }; 21 | 095CA43A2039F1AE0013FBF1 /* Node+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 095CA4392039F1AE0013FBF1 /* Node+Extensions.swift */; }; 22 | 09767F1B204091F900F29DE7 /* Sphere.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09767F1A204091F900F29DE7 /* Sphere.swift */; }; 23 | 09767F1D2045A25200F29DE7 /* sphere.dae in Resources */ = {isa = PBXBuildFile; fileRef = 09767F1C2045A25100F29DE7 /* sphere.dae */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 09206D3C205097EB00A04B19 /* SCNVector3+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SCNVector3+Extensions.swift"; sourceTree = ""; }; 28 | 09206D3E205187B500A04B19 /* UtilityExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilityExtensions.swift; sourceTree = ""; }; 29 | 092A3E7420372FCB006A8935 /* ARWalkthrough.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ARWalkthrough.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 092A3E7720372FCB006A8935 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 31 | 092A3E7B20372FCB006A8935 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 32 | 092A3E7E20372FCB006A8935 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | 092A3E8020372FCB006A8935 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 34 | 092A3E8320372FCB006A8935 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 35 | 092A3E8520372FCB006A8935 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 092A3E8D2039E240006A8935 /* HoverScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HoverScene.swift; sourceTree = ""; }; 37 | 0953926C204EE1920069F35A /* ORB_Body_Diff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ORB_Body_Diff.png; sourceTree = ""; }; 38 | 0953926D204EE1920069F35A /* ORB_Eye_Diff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ORB_Eye_Diff.png; sourceTree = ""; }; 39 | 0953926E204EE1930069F35A /* ORB_Circles_Diff.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ORB_Circles_Diff.png; sourceTree = ""; }; 40 | 095CA4392039F1AE0013FBF1 /* Node+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Node+Extensions.swift"; sourceTree = ""; }; 41 | 09767F1A204091F900F29DE7 /* Sphere.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sphere.swift; sourceTree = ""; }; 42 | 09767F1C2045A25100F29DE7 /* sphere.dae */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml.dae; path = sphere.dae; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 092A3E7120372FCB006A8935 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 092A3E6B20372FCB006A8935 = { 57 | isa = PBXGroup; 58 | children = ( 59 | 092A3E7620372FCB006A8935 /* ARGuide */, 60 | 092A3E7520372FCB006A8935 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 092A3E7520372FCB006A8935 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 092A3E7420372FCB006A8935 /* ARWalkthrough.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 092A3E7620372FCB006A8935 /* ARGuide */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 092A3E7720372FCB006A8935 /* AppDelegate.swift */, 76 | 092A3E7B20372FCB006A8935 /* ViewController.swift */, 77 | 09767F19204091E600F29DE7 /* Objects */, 78 | 092A3E8C20377F5B006A8935 /* Scenes */, 79 | 092A3E8B20377F56006A8935 /* Models */, 80 | 095CA4382039F1A10013FBF1 /* Utilities */, 81 | 092A3E7D20372FCB006A8935 /* Main.storyboard */, 82 | 092A3E8020372FCB006A8935 /* Assets.xcassets */, 83 | 092A3E8220372FCB006A8935 /* LaunchScreen.storyboard */, 84 | 092A3E8520372FCB006A8935 /* Info.plist */, 85 | ); 86 | path = ARGuide; 87 | sourceTree = ""; 88 | }; 89 | 092A3E8B20377F56006A8935 /* Models */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 0953926C204EE1920069F35A /* ORB_Body_Diff.png */, 93 | 0953926E204EE1930069F35A /* ORB_Circles_Diff.png */, 94 | 0953926D204EE1920069F35A /* ORB_Eye_Diff.png */, 95 | 09767F1C2045A25100F29DE7 /* sphere.dae */, 96 | ); 97 | path = Models; 98 | sourceTree = ""; 99 | }; 100 | 092A3E8C20377F5B006A8935 /* Scenes */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 092A3E8D2039E240006A8935 /* HoverScene.swift */, 104 | ); 105 | path = Scenes; 106 | sourceTree = ""; 107 | }; 108 | 095CA4382039F1A10013FBF1 /* Utilities */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 095CA4392039F1AE0013FBF1 /* Node+Extensions.swift */, 112 | 09206D3C205097EB00A04B19 /* SCNVector3+Extensions.swift */, 113 | 09206D3E205187B500A04B19 /* UtilityExtensions.swift */, 114 | ); 115 | path = Utilities; 116 | sourceTree = ""; 117 | }; 118 | 09767F19204091E600F29DE7 /* Objects */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 09767F1A204091F900F29DE7 /* Sphere.swift */, 122 | ); 123 | path = Objects; 124 | sourceTree = ""; 125 | }; 126 | /* End PBXGroup section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | 092A3E7320372FCB006A8935 /* ARWalkthrough */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = 092A3E8820372FCB006A8935 /* Build configuration list for PBXNativeTarget "ARWalkthrough" */; 132 | buildPhases = ( 133 | 092A3E7020372FCB006A8935 /* Sources */, 134 | 092A3E7120372FCB006A8935 /* Frameworks */, 135 | 092A3E7220372FCB006A8935 /* Resources */, 136 | ); 137 | buildRules = ( 138 | ); 139 | dependencies = ( 140 | ); 141 | name = ARWalkthrough; 142 | productName = MediumPost; 143 | productReference = 092A3E7420372FCB006A8935 /* ARWalkthrough.app */; 144 | productType = "com.apple.product-type.application"; 145 | }; 146 | /* End PBXNativeTarget section */ 147 | 148 | /* Begin PBXProject section */ 149 | 092A3E6C20372FCB006A8935 /* Project object */ = { 150 | isa = PBXProject; 151 | attributes = { 152 | LastSwiftUpdateCheck = 0920; 153 | LastUpgradeCheck = 0920; 154 | ORGANIZATIONNAME = "Nike, Inc."; 155 | TargetAttributes = { 156 | 092A3E7320372FCB006A8935 = { 157 | CreatedOnToolsVersion = 9.2; 158 | ProvisioningStyle = Automatic; 159 | }; 160 | }; 161 | }; 162 | buildConfigurationList = 092A3E6F20372FCB006A8935 /* Build configuration list for PBXProject "ARGuide" */; 163 | compatibilityVersion = "Xcode 8.0"; 164 | developmentRegion = en; 165 | hasScannedForEncodings = 0; 166 | knownRegions = ( 167 | en, 168 | Base, 169 | ); 170 | mainGroup = 092A3E6B20372FCB006A8935; 171 | productRefGroup = 092A3E7520372FCB006A8935 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | 092A3E7320372FCB006A8935 /* ARWalkthrough */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | 092A3E7220372FCB006A8935 /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 09539270204EE1930069F35A /* ORB_Eye_Diff.png in Resources */, 186 | 09767F1D2045A25200F29DE7 /* sphere.dae in Resources */, 187 | 092A3E8420372FCB006A8935 /* LaunchScreen.storyboard in Resources */, 188 | 092A3E8120372FCB006A8935 /* Assets.xcassets in Resources */, 189 | 0953926F204EE1930069F35A /* ORB_Body_Diff.png in Resources */, 190 | 092A3E7F20372FCB006A8935 /* Main.storyboard in Resources */, 191 | 09539271204EE1930069F35A /* ORB_Circles_Diff.png in Resources */, 192 | ); 193 | runOnlyForDeploymentPostprocessing = 0; 194 | }; 195 | /* End PBXResourcesBuildPhase section */ 196 | 197 | /* Begin PBXSourcesBuildPhase section */ 198 | 092A3E7020372FCB006A8935 /* Sources */ = { 199 | isa = PBXSourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | 09767F1B204091F900F29DE7 /* Sphere.swift in Sources */, 203 | 09206D3D205097EB00A04B19 /* SCNVector3+Extensions.swift in Sources */, 204 | 092A3E8E2039E240006A8935 /* HoverScene.swift in Sources */, 205 | 09206D3F205187B500A04B19 /* UtilityExtensions.swift in Sources */, 206 | 095CA43A2039F1AE0013FBF1 /* Node+Extensions.swift in Sources */, 207 | 092A3E7C20372FCB006A8935 /* ViewController.swift in Sources */, 208 | 092A3E7820372FCB006A8935 /* AppDelegate.swift in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 092A3E7D20372FCB006A8935 /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 092A3E7E20372FCB006A8935 /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 092A3E8220372FCB006A8935 /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 092A3E8320372FCB006A8935 /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 092A3E8620372FCB006A8935 /* Debug */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 240 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 241 | CLANG_CXX_LIBRARY = "libc++"; 242 | CLANG_ENABLE_MODULES = YES; 243 | CLANG_ENABLE_OBJC_ARC = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 250 | CLANG_WARN_EMPTY_BODY = YES; 251 | CLANG_WARN_ENUM_CONVERSION = YES; 252 | CLANG_WARN_INFINITE_RECURSION = YES; 253 | CLANG_WARN_INT_CONVERSION = YES; 254 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 261 | CLANG_WARN_UNREACHABLE_CODE = YES; 262 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 263 | CODE_SIGN_IDENTITY = "iPhone Developer"; 264 | COPY_PHASE_STRIP = NO; 265 | DEBUG_INFORMATION_FORMAT = dwarf; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | ENABLE_TESTABILITY = YES; 268 | GCC_C_LANGUAGE_STANDARD = gnu11; 269 | GCC_DYNAMIC_NO_PIC = NO; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_OPTIMIZATION_LEVEL = 0; 272 | GCC_PREPROCESSOR_DEFINITIONS = ( 273 | "DEBUG=1", 274 | "$(inherited)", 275 | ); 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 283 | MTL_ENABLE_DEBUG_INFO = YES; 284 | ONLY_ACTIVE_ARCH = YES; 285 | SDKROOT = iphoneos; 286 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 288 | }; 289 | name = Debug; 290 | }; 291 | 092A3E8720372FCB006A8935 /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ALWAYS_SEARCH_USER_PATHS = NO; 295 | CLANG_ANALYZER_NONNULL = YES; 296 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 297 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 298 | CLANG_CXX_LIBRARY = "libc++"; 299 | CLANG_ENABLE_MODULES = YES; 300 | CLANG_ENABLE_OBJC_ARC = YES; 301 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 302 | CLANG_WARN_BOOL_CONVERSION = YES; 303 | CLANG_WARN_COMMA = YES; 304 | CLANG_WARN_CONSTANT_CONVERSION = YES; 305 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 306 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 307 | CLANG_WARN_EMPTY_BODY = YES; 308 | CLANG_WARN_ENUM_CONVERSION = YES; 309 | CLANG_WARN_INFINITE_RECURSION = YES; 310 | CLANG_WARN_INT_CONVERSION = YES; 311 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 312 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 314 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 315 | CLANG_WARN_STRICT_PROTOTYPES = YES; 316 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 317 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 318 | CLANG_WARN_UNREACHABLE_CODE = YES; 319 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 320 | CODE_SIGN_IDENTITY = "iPhone Developer"; 321 | COPY_PHASE_STRIP = NO; 322 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 323 | ENABLE_NS_ASSERTIONS = NO; 324 | ENABLE_STRICT_OBJC_MSGSEND = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu11; 326 | GCC_NO_COMMON_BLOCKS = YES; 327 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 328 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 329 | GCC_WARN_UNDECLARED_SELECTOR = YES; 330 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 331 | GCC_WARN_UNUSED_FUNCTION = YES; 332 | GCC_WARN_UNUSED_VARIABLE = YES; 333 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 334 | MTL_ENABLE_DEBUG_INFO = NO; 335 | SDKROOT = iphoneos; 336 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 337 | VALIDATE_PRODUCT = YES; 338 | }; 339 | name = Release; 340 | }; 341 | 092A3E8920372FCB006A8935 /* Debug */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 346 | CODE_SIGN_STYLE = Automatic; 347 | DEVELOPMENT_TEAM = 3GU23X3P3D; 348 | INFOPLIST_FILE = "$(SRCROOT)/ARGuide/Info.plist"; 349 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 350 | PRODUCT_BUNDLE_IDENTIFIER = com.aboveground.ARWalkthrough; 351 | PRODUCT_NAME = "$(TARGET_NAME)"; 352 | PROVISIONING_PROFILE_SPECIFIER = ""; 353 | SWIFT_VERSION = 4.0; 354 | TARGETED_DEVICE_FAMILY = 1; 355 | }; 356 | name = Debug; 357 | }; 358 | 092A3E8A20372FCB006A8935 /* Release */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 362 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 363 | CODE_SIGN_STYLE = Automatic; 364 | DEVELOPMENT_TEAM = 3GU23X3P3D; 365 | INFOPLIST_FILE = "$(SRCROOT)/ARGuide/Info.plist"; 366 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 367 | PRODUCT_BUNDLE_IDENTIFIER = com.aboveground.ARWalkthrough; 368 | PRODUCT_NAME = "$(TARGET_NAME)"; 369 | PROVISIONING_PROFILE_SPECIFIER = ""; 370 | SWIFT_VERSION = 4.0; 371 | TARGETED_DEVICE_FAMILY = 1; 372 | }; 373 | name = Release; 374 | }; 375 | /* End XCBuildConfiguration section */ 376 | 377 | /* Begin XCConfigurationList section */ 378 | 092A3E6F20372FCB006A8935 /* Build configuration list for PBXProject "ARGuide" */ = { 379 | isa = XCConfigurationList; 380 | buildConfigurations = ( 381 | 092A3E8620372FCB006A8935 /* Debug */, 382 | 092A3E8720372FCB006A8935 /* Release */, 383 | ); 384 | defaultConfigurationIsVisible = 0; 385 | defaultConfigurationName = Release; 386 | }; 387 | 092A3E8820372FCB006A8935 /* Build configuration list for PBXNativeTarget "ARWalkthrough" */ = { 388 | isa = XCConfigurationList; 389 | buildConfigurations = ( 390 | 092A3E8920372FCB006A8935 /* Debug */, 391 | 092A3E8A20372FCB006A8935 /* Release */, 392 | ); 393 | defaultConfigurationIsVisible = 0; 394 | defaultConfigurationName = Release; 395 | }; 396 | /* End XCConfigurationList section */ 397 | }; 398 | rootObject = 092A3E6C20372FCB006A8935 /* Project object */; 399 | } 400 | -------------------------------------------------------------------------------- /ARGuide.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ARGuide.xcodeproj/project.xcworkspace/xcuserdata/dwyszy.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide.xcodeproj/project.xcworkspace/xcuserdata/dwyszy.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ARGuide.xcodeproj/xcuserdata/dwyszy.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ARGuide.xcodeproj/xcuserdata/dwyszy.xcuserdatad/xcschemes/ARWalkthrough.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 56 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 77 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /ARGuide.xcodeproj/xcuserdata/dwyszy.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ARWalkthrough.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 092A3E7320372FCB006A8935 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ARGuide/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 2/16/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "iPhone_40pt_@1x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "iPhone_60pt_@1x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "iPhone_58pt_@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "iPhone_87pt_@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "iPhone_80pt_@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "iPhone_120pt_@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "iPhone_120pt_@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "iPhone_180pt_@3x.png", 49 | "scale" : "3x" 50 | }, 51 | { 52 | "size" : "1024x1024", 53 | "idiom" : "ios-marketing", 54 | "filename" : "iTunes_1024pt_@2x.png", 55 | "scale" : "1x" 56 | } 57 | ], 58 | "info" : { 59 | "version" : 1, 60 | "author" : "xcode" 61 | } 62 | } -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_120pt_@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_120pt_@2x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_120pt_@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_120pt_@3x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_180pt_@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_180pt_@3x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_40pt_@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_40pt_@1x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_58pt_@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_58pt_@2x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_60pt_@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_60pt_@1x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_80pt_@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_80pt_@2x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_87pt_@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iPhone_87pt_@3x.png -------------------------------------------------------------------------------- /ARGuide/Assets.xcassets/AppIcon.appiconset/iTunes_1024pt_@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Assets.xcassets/AppIcon.appiconset/iTunes_1024pt_@2x.png -------------------------------------------------------------------------------- /ARGuide/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /ARGuide/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ARGuide/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSCameraUsageDescription 24 | This application will use the camera for Augmented Reality. 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | arkit 33 | 34 | UIStatusBarHidden 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /ARGuide/Models/ORB_Body_Diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Models/ORB_Body_Diff.png -------------------------------------------------------------------------------- /ARGuide/Models/ORB_Circles_Diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Models/ORB_Circles_Diff.png -------------------------------------------------------------------------------- /ARGuide/Models/ORB_Eye_Diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/ARGuide/Models/ORB_Eye_Diff.png -------------------------------------------------------------------------------- /ARGuide/Objects/Sphere.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sphere.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 2/23/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SceneKit 11 | 12 | class SceneObject: SCNNode { 13 | 14 | init(from file: String) { 15 | super.init() 16 | 17 | let nodesInFile = SCNNode.allNodes(from: file) 18 | nodesInFile.forEach { (node) in 19 | self.addChildNode(node) 20 | } 21 | } 22 | 23 | required init?(coder aDecoder: NSCoder) { 24 | fatalError("init(coder:) has not been implemented") 25 | } 26 | 27 | } 28 | 29 | class Sphere: SceneObject { 30 | 31 | var animating: Bool = false 32 | let patrolDistance: Float = 4.85 33 | 34 | init() { 35 | super.init(from: "sphere.dae") 36 | } 37 | 38 | required init?(coder aDecoder: NSCoder) { 39 | fatalError("init(coder:) has not been implemented") 40 | } 41 | 42 | func animate() { 43 | 44 | if animating { return } 45 | animating = true 46 | 47 | let rotateOne = SCNAction.rotateBy(x: 0, y: CGFloat(Float.random(min: -Float.pi, max: Float.pi)), z: 0, duration: 5.0) 48 | 49 | let backwards = rotateOne.reversed() 50 | let rotateSequence = SCNAction.sequence([rotateOne, backwards]) 51 | let repeatForever = SCNAction.repeatForever(rotateSequence) 52 | 53 | runAction(repeatForever) 54 | } 55 | 56 | func patrol(targetPos: SCNVector3) { 57 | let distanceToTarget = targetPos.distance(receiver: self.position) 58 | 59 | if distanceToTarget < patrolDistance { 60 | removeAllActions() 61 | animating = false 62 | SCNTransaction.begin() 63 | SCNTransaction.animationDuration = 0.20 64 | look(at: targetPos) 65 | SCNTransaction.commit() 66 | } else { 67 | if !animating { 68 | animate() 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ARGuide/Scenes/HoverScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HoverScene.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 2/18/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SceneKit 11 | 12 | struct HoverScene { 13 | 14 | var scene: SCNScene? 15 | 16 | init() { 17 | scene = self.initializeScene() 18 | } 19 | 20 | func initializeScene() -> SCNScene? { 21 | let scene = SCNScene() 22 | 23 | setDefaults(scene: scene) 24 | 25 | return scene 26 | } 27 | 28 | func setDefaults(scene: SCNScene) { 29 | 30 | let ambientLightNode = SCNNode() 31 | ambientLightNode.light = SCNLight() 32 | ambientLightNode.light?.type = SCNLight.LightType.ambient 33 | ambientLightNode.light?.color = UIColor(white: 0.6, alpha: 1.0) 34 | scene.rootNode.addChildNode(ambientLightNode) 35 | 36 | // Create a directional light with an angle to provide a more interesting look 37 | let directionalLight = SCNLight() 38 | directionalLight.type = .directional 39 | directionalLight.color = UIColor(white: 0.8, alpha: 1.0) 40 | let directionalNode = SCNNode() 41 | directionalNode.eulerAngles = SCNVector3Make(GLKMathDegreesToRadians(-40), GLKMathDegreesToRadians(0), GLKMathDegreesToRadians(0)) 42 | directionalNode.light = directionalLight 43 | scene.rootNode.addChildNode(directionalNode) 44 | } 45 | 46 | func addSphere(position: SCNVector3) { 47 | guard let scene = self.scene else { return } 48 | 49 | let sphere = Sphere() 50 | sphere.position = position 51 | 52 | let prevScale = sphere.scale 53 | sphere.scale = SCNVector3(0.01, 0.01, 0.01) 54 | let scaleAction = SCNAction.scale(to: CGFloat(prevScale.x), duration: 1.5) 55 | scaleAction.timingMode = .linear 56 | 57 | // Use a custom timing function 58 | scaleAction.timingFunction = { (p: Float) in 59 | return self.easeOutElastic(p) 60 | } 61 | 62 | scene.rootNode.addChildNode(sphere) 63 | sphere.runAction(scaleAction, forKey: "scaleAction") 64 | } 65 | 66 | // Timing function that has a "bounce in" effect 67 | func easeOutElastic(_ t: Float) -> Float { 68 | let p: Float = 0.3 69 | let result = pow(2.0, -10.0 * t) * sin((t - p / 4.0) * (2.0 * Float.pi) / p) + 1.0 70 | return result 71 | } 72 | 73 | func makeUpdateCameraPos(towards: SCNVector3) { 74 | guard let scene = self.scene else { return } 75 | scene.rootNode.enumerateChildNodes({ (node, _) in 76 | if let sphere = node.topmost(until: scene.rootNode) as? Sphere { 77 | sphere.patrol(targetPos: towards) 78 | } 79 | }) 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /ARGuide/Utilities/Node+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Node+Extensions.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 2/18/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import SceneKit 10 | 11 | extension SCNNode { 12 | 13 | public class func allNodes(from file: String) -> [SCNNode] { 14 | var nodesInFile = [SCNNode]() 15 | 16 | do { 17 | guard let sceneURL = Bundle.main.url(forResource: file, withExtension: nil) else { 18 | print("Could not find scene file \(file)") 19 | return nodesInFile 20 | } 21 | 22 | let objScene = try SCNScene(url: sceneURL as URL, options: [SCNSceneSource.LoadingOption.animationImportPolicy:SCNSceneSource.AnimationImportPolicy.doNotPlay]) 23 | 24 | for childNode in objScene.rootNode.childNodes { 25 | nodesInFile.append(childNode) 26 | } 27 | } catch { 28 | 29 | } 30 | 31 | return nodesInFile 32 | } 33 | 34 | func topmost(parent: SCNNode? = nil, until: SCNNode) -> SCNNode { 35 | if let pNode = self.parent { 36 | return pNode == until ? self : pNode.topmost(parent: pNode, until: until) 37 | } else { 38 | return self 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ARGuide/Utilities/SCNVector3+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SCNVector3+Extensions.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 3/7/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SceneKit 11 | 12 | extension SCNVector3 { 13 | public func distance(receiver:SCNVector3) -> Float { 14 | let xd = receiver.x - self.x 15 | let yd = receiver.y - self.y 16 | let zd = receiver.z - self.z 17 | let distance = Float(sqrt(xd * xd + yd * yd + zd * zd)) 18 | 19 | if (distance < 0){ 20 | return (distance * -1) 21 | } else { 22 | return (distance) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ARGuide/Utilities/UtilityExtensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UtilityExtensions.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 3/8/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public extension Float { 12 | /// Returns a random floating point number between 0.0 and 1.0, inclusive. 13 | static var random: Float { 14 | get { 15 | return Float(arc4random()) / 0xFFFFFFFF 16 | } 17 | } 18 | /** 19 | Create a random num Float 20 | 21 | - parameter min: Float 22 | - parameter max: Float 23 | 24 | - returns: Float 25 | */ 26 | public static func random(min: Float, max: Float) -> Float { 27 | return Float.random * (max - min) + min 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ARGuide/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ARWalkthrough 4 | // 5 | // Created by Wyszynski, Daniel on 2/16/18. 6 | // Copyright © 2018 Nike, Inc. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SceneKit 11 | import ARKit 12 | 13 | class ViewController: UIViewController, ARSCNViewDelegate { 14 | 15 | @IBOutlet var sceneView: ARSCNView! 16 | var sceneController = HoverScene() 17 | 18 | var didInitializeScene: Bool = false 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | // Set the view's delegate 24 | sceneView.delegate = self 25 | 26 | // Show statistics such as fps and timing information 27 | sceneView.showsStatistics = true 28 | 29 | // Create a new scene 30 | if let scene = sceneController.scene { 31 | // Set the scene to the view 32 | sceneView.scene = scene 33 | } 34 | 35 | let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.didTapScreen)) 36 | self.view.addGestureRecognizer(tapRecognizer) 37 | } 38 | 39 | override func viewWillAppear(_ animated: Bool) { 40 | super.viewWillAppear(animated) 41 | 42 | // Create a session configuration 43 | let configuration = ARWorldTrackingConfiguration() 44 | 45 | // Run the view's session 46 | sceneView.session.run(configuration) 47 | } 48 | 49 | override func viewDidAppear(_ animated: Bool) { 50 | super.viewDidAppear(animated) 51 | } 52 | 53 | override func viewWillDisappear(_ animated: Bool) { 54 | super.viewWillDisappear(animated) 55 | 56 | // Pause the view's session 57 | sceneView.session.pause() 58 | } 59 | 60 | override func didReceiveMemoryWarning() { 61 | super.didReceiveMemoryWarning() 62 | // Release any cached data, images, etc that aren't in use. 63 | } 64 | 65 | @objc func didTapScreen(recognizer: UITapGestureRecognizer) { 66 | if didInitializeScene, let camera = sceneView.session.currentFrame?.camera { 67 | let tapLocation = recognizer.location(in: sceneView) 68 | let hitTestResults = sceneView.hitTest(tapLocation) 69 | if let node = hitTestResults.first?.node, let scene = sceneController.scene, let sphere = node.topmost(until: scene.rootNode) as? Sphere { 70 | sphere.animate() 71 | } 72 | else { 73 | var translation = matrix_identity_float4x4 74 | translation.columns.3.z = -5.0 75 | let transform = camera.transform * translation 76 | let position = SCNVector3(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z) 77 | sceneController.addSphere(position: position) 78 | } 79 | } 80 | } 81 | 82 | // MARK: - ARSCNViewDelegate 83 | 84 | /* 85 | // Override to create and configure nodes for anchors added to the view's session. 86 | func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? { 87 | let node = SCNNode() 88 | 89 | return node 90 | } 91 | */ 92 | func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) { 93 | if let camera = sceneView.session.currentFrame?.camera { 94 | didInitializeScene = true 95 | 96 | let transform = camera.transform 97 | let position = SCNVector3(transform.columns.3.x, transform.columns.3.y, transform.columns.3.z) 98 | sceneController.makeUpdateCameraPos(towards: position) 99 | } 100 | } 101 | 102 | func session(_ session: ARSession, didFailWithError error: Error) { 103 | // Present an error message to the user 104 | 105 | } 106 | 107 | func sessionWasInterrupted(_ session: ARSession) { 108 | // Inform the user that the session has been interrupted, for example, by presenting an overlay 109 | 110 | } 111 | 112 | func sessionInterruptionEnded(_ session: ARSession) { 113 | // Reset tracking and/or remove existing anchors if consistent tracking is required 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Dan Wyszynski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AR Tutorial Part2 - SceneKit animations, camera and interaction 2 | 3 | Continuing this series of ARKit tutorials, this time adding animations, interacting with the models, and showing how to use the camera to drive the scene. Follow the [tutorial at the Nike S23NYC Engineering blog](https://medium.com/s23nyc-tech/arkit-scenekit-and-how-to-control-the-world-dc7377eb1dc6). 4 | 5 | 6 | 7 | 8 | # Requirements 9 | 10 | - Xcode 9.x 11 | - iOS 11 12 | - An iOS device with an A9 or better processor (iPhone 6s or superior, iPad Pro, iPad 2017) 13 | 14 | # Installation 15 | 1. Clone this repo. 16 | 2. Open the project in Xcode 9. 17 | 4. Run the project in a real device with iOS 11. AR can't work in the simulator, so you'll need to configure a team to be able to run your app on a device. 18 | 19 | # Credits 20 | The sphere 3D model was created by Vladimir Nikiforov: 21 | - This file is licensed under [Creative Commons Attribution](https://creativecommons.org/licenses/by/4.0/). 22 | 23 | 24 | # License 25 | MIT 26 | -------------------------------------------------------------------------------- /eye_patrol.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AbovegroundDan/ARTutorial_Part2/6bd7fdaa67b7d22510dc64c30d0c76cfb81e1504/eye_patrol.gif --------------------------------------------------------------------------------