diff --git a/BrightsMacApp/AppDelegate.swift b/BrightsMacApp/AppDelegate.swift new file mode 100644 index 0000000..b0c2efd --- /dev/null +++ b/BrightsMacApp/AppDelegate.swift @@ -0,0 +1,18 @@ +// +// AppDelegate.swift +// BrightsMacApp +// +// Created by Mac Bellingrath on 4/14/19. +// Copyright © 2019 Mac Bellingrath. All rights reserved. +// + +import Cocoa + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + +} diff --git a/BrightsMacApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/BrightsMacApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/BrightsMacApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/BrightsMacApp/Assets.xcassets/Contents.json b/BrightsMacApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/BrightsMacApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/BrightsMacApp/Base.lproj/Main.storyboard b/BrightsMacApp/Base.lproj/Main.storyboard new file mode 100644 index 0000000..ce2328d --- /dev/null +++ b/BrightsMacApp/Base.lproj/Main.storyboard @@ -0,0 +1,719 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BrightsMacApp/BrightsMacApp.entitlements b/BrightsMacApp/BrightsMacApp.entitlements new file mode 100644 index 0000000..0c67376 --- /dev/null +++ b/BrightsMacApp/BrightsMacApp.entitlements @@ -0,0 +1,5 @@ + + + + + diff --git a/BrightsMacApp/GameViewController.swift b/BrightsMacApp/GameViewController.swift new file mode 100644 index 0000000..9540b8e --- /dev/null +++ b/BrightsMacApp/GameViewController.swift @@ -0,0 +1,27 @@ +// +// GameViewController.swift +// BrightsMacApp +// +// Created by Mac Bellingrath on 4/14/19. +// Copyright © 2019 Mac Bellingrath. All rights reserved. +// + +import SceneKit +import QuartzCore + +class GameViewController: NSViewController { + + var scnView = View() + + override func loadView() { + view = scnView + } + + override func viewDidLoad() { + super.viewDidLoad() + + scnView.loadScene() + scnView.allowsCameraControl = true + } + +} diff --git a/BrightsMacApp/Info.plist b/BrightsMacApp/Info.plist new file mode 100644 index 0000000..11b4d8f --- /dev/null +++ b/BrightsMacApp/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2019 Mac Bellingrath. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + NSAppTransportSecurity + + + diff --git a/FloatingCovers.xcodeproj/project.pbxproj b/FloatingCovers.xcodeproj/project.pbxproj index e0454ab..70c6736 100644 --- a/FloatingCovers.xcodeproj/project.pbxproj +++ b/FloatingCovers.xcodeproj/project.pbxproj @@ -14,6 +14,13 @@ E62E045D2262726A00017EC9 /* BrightScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67C886B226203E800DFB5D1 /* BrightScene.swift */; }; E62E045E2262727000017EC9 /* ImageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6EF2C2622525B7E0059DA76 /* ImageService.swift */; }; E62E045F2262727200017EC9 /* ImageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6EF2C2622525B7E0059DA76 /* ImageService.swift */; }; + E6707541226345E000749CBA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6707540226345E000749CBA /* AppDelegate.swift */; }; + E6707543226345E000749CBA /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6707542226345E000749CBA /* GameViewController.swift */; }; + E6707547226345E000749CBA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E6707546226345E000749CBA /* Assets.xcassets */; }; + E670754A226345E000749CBA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E6707548226345E000749CBA /* Main.storyboard */; }; + E67075502263461800749CBA /* BrightScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67C886B226203E800DFB5D1 /* BrightScene.swift */; }; + E67075512263461800749CBA /* BrightSaverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6EF2C24225252B50059DA76 /* BrightSaverView.swift */; }; + E67075522263461800749CBA /* ImageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6EF2C2622525B7E0059DA76 /* ImageService.swift */; }; E67C886C226203E800DFB5D1 /* BrightScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67C886B226203E800DFB5D1 /* BrightScene.swift */; }; E67C886D2262041600DFB5D1 /* BrightScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = E67C886B226203E800DFB5D1 /* BrightScene.swift */; }; E6D69F932250E7D300BFB157 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D69F922250E7D300BFB157 /* AppDelegate.swift */; }; @@ -35,6 +42,13 @@ E62E04572262719300017EC9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; E62E04592262719300017EC9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; E65A00E6225F483A00ED5FE7 /* SceneKitMacOS.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = SceneKitMacOS.playground; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + E670753E226345E000749CBA /* BrightsMacApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BrightsMacApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E6707540226345E000749CBA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + E6707542226345E000749CBA /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; + E6707546226345E000749CBA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + E6707549226345E000749CBA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + E670754B226345E000749CBA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E670754C226345E000749CBA /* BrightsMacApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = BrightsMacApp.entitlements; sourceTree = ""; }; E67C886B226203E800DFB5D1 /* BrightScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrightScene.swift; sourceTree = ""; }; E6D69F8F2250E7D300BFB157 /* FloatingCovers.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FloatingCovers.app; sourceTree = BUILT_PRODUCTS_DIR; }; E6D69F922250E7D300BFB157 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -58,6 +72,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E670753B226345E000749CBA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; E6D69F8C2250E7D300BFB157 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -87,12 +108,26 @@ path = BrightsTV; sourceTree = ""; }; + E670753F226345E000749CBA /* BrightsMacApp */ = { + isa = PBXGroup; + children = ( + E6707540226345E000749CBA /* AppDelegate.swift */, + E6707542226345E000749CBA /* GameViewController.swift */, + E6707546226345E000749CBA /* Assets.xcassets */, + E6707548226345E000749CBA /* Main.storyboard */, + E670754B226345E000749CBA /* Info.plist */, + E670754C226345E000749CBA /* BrightsMacApp.entitlements */, + ); + path = BrightsMacApp; + sourceTree = ""; + }; E6D69F862250E7D300BFB157 = { isa = PBXGroup; children = ( E6D69F912250E7D300BFB157 /* FloatingCovers */, E6EF2C1A22514BFE0059DA76 /* BrightsSaver */, E62E044F2262719200017EC9 /* BrightsTV */, + E670753F226345E000749CBA /* BrightsMacApp */, E6D69F902250E7D300BFB157 /* Products */, ); sourceTree = ""; @@ -103,6 +138,7 @@ E6D69F8F2250E7D300BFB157 /* FloatingCovers.app */, E6EF2C1922514BFE0059DA76 /* BrightsSaver.saver */, E62E044E2262719200017EC9 /* BrightsTV.app */, + E670753E226345E000749CBA /* BrightsMacApp.app */, ); name = Products; sourceTree = ""; @@ -163,6 +199,23 @@ productReference = E62E044E2262719200017EC9 /* BrightsTV.app */; productType = "com.apple.product-type.application"; }; + E670753D226345E000749CBA /* BrightsMacApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = E670754F226345E000749CBA /* Build configuration list for PBXNativeTarget "BrightsMacApp" */; + buildPhases = ( + E670753A226345E000749CBA /* Sources */, + E670753B226345E000749CBA /* Frameworks */, + E670753C226345E000749CBA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BrightsMacApp; + productName = BrightsMacApp; + productReference = E670753E226345E000749CBA /* BrightsMacApp.app */; + productType = "com.apple.product-type.application"; + }; E6D69F8E2250E7D300BFB157 /* FloatingCovers */ = { isa = PBXNativeTarget; buildConfigurationList = E6D69FA32250E7D500BFB157 /* Build configuration list for PBXNativeTarget "FloatingCovers" */; @@ -211,6 +264,9 @@ E62E044D2262719200017EC9 = { CreatedOnToolsVersion = 10.2; }; + E670753D226345E000749CBA = { + CreatedOnToolsVersion = 10.2; + }; E6D69F8E2250E7D300BFB157 = { CreatedOnToolsVersion = 10.2; }; @@ -236,6 +292,7 @@ E6D69F8E2250E7D300BFB157 /* FloatingCovers */, E6EF2C1822514BFE0059DA76 /* BrightsSaver */, E62E044D2262719200017EC9 /* BrightsTV */, + E670753D226345E000749CBA /* BrightsMacApp */, ); }; /* End PBXProject section */ @@ -250,6 +307,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E670753C226345E000749CBA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E670754A226345E000749CBA /* Main.storyboard in Resources */, + E6707547226345E000749CBA /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; E6D69F8D2250E7D300BFB157 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -283,6 +349,18 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + E670753A226345E000749CBA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E67075512263461800749CBA /* BrightSaverView.swift in Sources */, + E6707543226345E000749CBA /* GameViewController.swift in Sources */, + E6707541226345E000749CBA /* AppDelegate.swift in Sources */, + E67075522263461800749CBA /* ImageService.swift in Sources */, + E67075502263461800749CBA /* BrightScene.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; E6D69F8B2250E7D300BFB157 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -315,6 +393,14 @@ name = Main.storyboard; sourceTree = ""; }; + E6707548226345E000749CBA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + E6707549226345E000749CBA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; E6D69F982250E7D300BFB157 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -376,6 +462,46 @@ }; name = Release; }; + E670754D226345E000749CBA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = BrightsMacApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = com.macbellingrath.BrightsMacApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + E670754E226345E000749CBA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = BrightsMacApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = com.macbellingrath.BrightsMacApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; E6D69FA12250E7D500BFB157 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -589,6 +715,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + E670754F226345E000749CBA /* Build configuration list for PBXNativeTarget "BrightsMacApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E670754D226345E000749CBA /* Debug */, + E670754E226345E000749CBA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; E6D69F8A2250E7D300BFB157 /* Build configuration list for PBXProject "FloatingCovers" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/FloatingCovers/BrightScene.swift b/FloatingCovers/BrightScene.swift index 85edff3..b39e0fb 100644 --- a/FloatingCovers/BrightScene.swift +++ b/FloatingCovers/BrightScene.swift @@ -30,7 +30,7 @@ class BrightService { Brights.self, from: data) { completion(brights) } - }.resume() + }.resume() } } @@ -68,7 +68,7 @@ class Scene: SCNScene { let lightNode = SCNNode() lightNode.position = SCNVector3(x: 0, y: 10, z: 0) - + lightNode.eulerAngles = SCNVector3(x: 0, y: (.pi/2) - 0.02, z: 0) lightNode.light = light rootNode.addChildNode(lightNode) @@ -112,7 +112,7 @@ class Scene: SCNScene { position.y = 0.2 let margin = CGFloat(1) let width = CGFloat(1) - let height = CGFloat(0.15) + let height = CGFloat(0.05) let length = CGFloat(1) let chamferRadius = CGFloat(0.3) @@ -137,7 +137,20 @@ class Scene: SCNScene { #endif group.enter() self.imageService.getImage(url: column.image, completion: { result in - newBoxGeometry.firstMaterial?.diffuse.contents = try? result.get() + let imageMaterial = SCNMaterial() + imageMaterial.diffuse.contents = try? result.get() + var materials: [SCNMaterial] = [] + for _ in 0..<5 { + let side = SCNMaterial() + #if os(macOS) + side.diffuse.contents = NSColor.white + #else + side.diffuse.contents = UIColor.white + #endif + materials.append(side) + } + materials.insert(imageMaterial, at: 4) + newBoxGeometry.materials = materials self.rootNode.addChildNode(newBoxNode) group.leave() }) diff --git a/FloatingCovers/art.scnassets/brights.scn b/FloatingCovers/art.scnassets/brights.scn index 5fb36d3..dc52b6f 100644 Binary files a/FloatingCovers/art.scnassets/brights.scn and b/FloatingCovers/art.scnassets/brights.scn differ diff --git a/SceneKitMacOS.playground/Contents.swift b/SceneKitMacOS.playground/Contents.swift index 4f12255..9ede4ba 100644 --- a/SceneKitMacOS.playground/Contents.swift +++ b/SceneKitMacOS.playground/Contents.swift @@ -201,7 +201,7 @@ class View: SCNView, SCNSceneRendererDelegate { } } -let sceneView = View(frame: CGRect(x:0 , y:0, width: 1000, height: 1000)) +let sceneView = View(frame: CGRect(x:0 , y:0, width: 200, height: 200)) sceneView.loadScene() sceneView.allowsCameraControl = true sceneView.delegate = sceneView