diff --git a/PodPals/Calibration.swift b/PodPals/Calibration.swift index 119e1f7..17a5764 100644 --- a/PodPals/Calibration.swift +++ b/PodPals/Calibration.swift @@ -26,13 +26,13 @@ class Calibration: ObservableObject { private var data: CMDeviceMotion = .init() - // calibration + private var idleGravity: CMAcceleration = .init() private var idleQuaternion: CMQuaternion = .init(x: 0, y: 0, z: 0, w: 1) private var calibration: CMQuaternion = .init(x: 0, y: 0, z: 0, w: 1) init() { -// restoreCalibration() + restoreCalibration() } func update(data: CMDeviceMotion) { diff --git a/PodPals/HeadScene.swift b/PodPals/HeadScene.swift index 1447c48..c2d0683 100644 --- a/PodPals/HeadScene.swift +++ b/PodPals/HeadScene.swift @@ -35,7 +35,7 @@ class HeadScene: SCNScene, ObservableObject { let head = SCNNode() let headGeometry = SCNSphere(radius: 1) head.geometry = headGeometry -// headGeometry.firstMaterial?.diffuse.contents = NSColor(red: 156/255, green: 156/255, blue: 156/255, alpha: 1.0) + headGeometry.firstMaterial?.diffuse.contents = NSColor(red: 1, green: 1, blue: 1, alpha: 1.0) headGeometry.firstMaterial?.transparency = 0.8 head.position = SCNVector3(x: 0, y: 0, z: 0) @@ -89,9 +89,7 @@ class HeadScene: SCNScene, ObservableObject { let mouth = SCNNode() let mouthGeometry = SCNCylinder(radius: 0.2, height: 0.05) mouth.geometry = mouthGeometry -// mouthGeometry.firstMaterial?.diffuse.contents = NSColor( -// calibratedRed: 0.8, green: 0.2, blue: 0.2, alpha: 1 -// ) + mouthGeometry.firstMaterial?.diffuse.contents = NSColor( calibratedRed: 0, green: 0, blue: 0, alpha: 1 ) @@ -147,11 +145,7 @@ class HeadScene: SCNScene, ObservableObject { ringGeometry3.firstMaterial?.emission.contents = NSColor(.white) ring3.rotation = SCNVector4(x: 1, y: 0, z: 0, w: 3.14 / 2) -// headGroup.addChildNode(ring) -// headGroup.addChildNode(ring2) -// headGroup.addChildNode(ring3) - // add the light node to the scene rootNode.addChildNode(lightNode) rootNode.addChildNode(lightNode2) headGroup.addChildNode(head) @@ -162,19 +156,19 @@ class HeadScene: SCNScene, ObservableObject { headGroup.addChildNode(nose) headGroup.addChildNode(mouth) - // mirror + mirror.addChildNode(headGroup) - // set up scene + rootNode.addChildNode(mirror) - // set up camera + let cameraNode = SCNNode() cameraNode.camera = SCNCamera() cameraNode.position = SCNVector3(x: 0, y: 0, z: 3) rootNode.addChildNode(cameraNode) - // Set camera to look at the origin + let constraint = SCNLookAtConstraint(target: rootNode) cameraNode.constraints = [constraint] diff --git a/PodPals/PodPalsApp.swift b/PodPals/PodPalsApp.swift index 0539837..bd7416b 100644 --- a/PodPals/PodPalsApp.swift +++ b/PodPals/PodPalsApp.swift @@ -97,21 +97,19 @@ class AppState: ObservableObject { var headphoneMotionDetector = HeadphoneMotionDetector() init() { - // Initialize with stored values or defaults self.sensitivity = UserDefaults.standard.string(forKey: "sensitivity") ?? "Low" self.leftFlick = UserDefaults.standard.string(forKey: "leftFlick") ?? "Previous Track" self.rightFlick = UserDefaults.standard.string(forKey: "rightFlick") ?? "Next Track" self.nod = UserDefaults.standard.string(forKey: "nod") ?? "Play/Pause" self.trackingEnabled = UserDefaults.standard.bool(forKey: "trackingEnabled") self.mediaPlayerAvailability = MediaPlayerChecker.checkAvailability() - // Set up motion detector + headphoneMotionDetector.onUpdate = { [self] in quaternion = self.headphoneMotionDetector.correctedQuaternion } headphoneMotionDetector.start() - // repeatedly check if access has been granted by the user if !HeadphoneMotionDetector.isAuthorized() { if HeadphoneMotionDetector.authorizationStatus == CMAuthorizationStatus.notDetermined { accessCheckTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in diff --git a/PodPals/RotationViewer.swift b/PodPals/RotationViewer.swift index 28f7522..b0312d8 100644 --- a/PodPals/RotationViewer.swift +++ b/PodPals/RotationViewer.swift @@ -13,7 +13,7 @@ struct RotationViewer: NSViewRepresentable { var scene: HeadScene func makeNSView(context _: Context) -> SCNView { - // set up scene + let sceneView = SCNView() sceneView.scene = scene