Post

Replies

Boosts

Views

Activity

Reply to watchOS 7 Extreme Battery Life Degradation
All through the watchOS 7 betas, I didn’t experience any watch battery issues on either of the 2 Apple Watch Series 5’s I have. But after I updated both to release watchOS 7, both are experiencing at least a 2x rate of battery drain. Am barely able to get from 8am to 10 pm without a recharge. What in the world happened between the last watchOS beta and GM to cause this?
Sep ’20
Reply to SceneView new api in Big Sur: how to use it
I posted this on another post dealing with MagnificationGesture, but frankly, it's more appropriate here. Here's how to swap between two cameras in a scene, "distantCamera" and "aircraftCamera". import SwiftUI import SceneKit extension SCNScene: ObservableObject { } struct SwiftUISceneKitUsingStateObjectVarsContentView: View { 		@State private var povSwitch				= true 	@State private var pointOfView			= "distantCamera" 		@StateObject var aircraftScene			= SCNScene(named: "art.scnassets/ship.scn")! 		var body: some View { 				ZStack { 						Color.black.edgesIgnoringSafeArea(.all) 						SceneView ( 								scene: aircraftScene, 								pointOfView: aircraftScene.rootNode.childNode(withName: pointOfView, recursively: true) 						) 						.background(Color.black) 						VStack() { 								Text("Hello, SceneKit!").multilineTextAlignment(.leading).padding() 										.foregroundColor(Color.gray) 										.font(.largeTitle) 								Text("Change the camera.") 										.foregroundColor(Color.gray) 										.font(.title) 								Spacer(minLength: 300) 								Button( action: { 										withAnimation{ 												self.povSwitch.toggle() 										} 										 if self.povSwitch == true { 												self.pointOfView = "distantCamera" 										} else { 												self.pointOfView = "aircraftCamera" 										} 								}) { 										Image(systemName: povSwitch ? "video.fill" : "video") 												.imageScale(.large) 												.accessibility(label: Text("Camera Switch")) 												.padding() 								} 						} 				} 				.statusBar(hidden: true) 		} }
Aug ’20
Reply to Using MagnificationGesture in SceneView
So, let's say you want to swap between cameras, provided you have more than one, in a scene. I banged my head on this for a bit of time, primarily because I'm either dim-witted (a real strong possibility) or just too set in my 57-year old ways, trying to change the pointOfView property in SceneView. Eventually, it hit me that all I'm trying to do is change the "withName" String in .childNode(withName: String, recursively: Bool). And boy!, that's easy. The above code I posted is junk and, frankly, embarrassing. Here's the better code. I hope it helps. import SwiftUI import SceneKit extension SCNScene: ObservableObject { } struct SwiftUISceneKitUsingStateObjectVarsContentView: View { 		@State private var povSwitch				= true 	@State private var pointOfView			= "distantCamera" 		@StateObject var aircraftScene			= SCNScene(named: "art.scnassets/ship.scn")! 		var body: some View { 				ZStack { 						Color.black.edgesIgnoringSafeArea(.all) 						SceneView ( 								scene: aircraftScene, 								pointOfView: aircraftScene.rootNode.childNode(withName: pointOfView, recursively: true) 						) 						.background(Color.black) 						VStack() { 								Text("Hello, SceneKit!").multilineTextAlignment(.leading).padding() 										.foregroundColor(Color.gray) 										.font(.largeTitle) 								Text("Change the camera.") 										.foregroundColor(Color.gray) 										.font(.title) 								Spacer(minLength: 300) 								Button( action: { 										withAnimation{ 												self.povSwitch.toggle() 										} 										 if self.povSwitch == true { 												self.pointOfView = "distantCamera" 										} else { 												self.pointOfView = "aircraftCamera" 										} 								}) { 										Image(systemName: sunlightSwitch ? "video.fill" : "video") 												.imageScale(.large) 												.accessibility(label: Text("Camera Switch")) 												.padding() 								} 						} 				} 				.statusBar(hidden: true) 		} }
Aug ’20
Reply to Using MagnificationGesture in SceneView
So, can't edit or correct my own previous posts. Nice! The above code of mine obviously doesn't work. Worse, it's bad code. Junk, really. There are a couple of ways to handle creating an "aircraftScene" instance of SCNScene, @StateObject and doing a copy( ). I chose, after talking asking friends more experienced than me for their advice, to use @StateObject implementation of the "aircraftScene". But guess what?!? Apple didn't change SCNScene to conform to ObservedObject like it did for . So one needs to extend SCNScene to conform to ObservableObject in order to use the @StateObject property wrapper on an instance of SCNScene. Unfortunately, this extension of SCNScene as an ObservableObject does not synthesize the objectWillChange publisher, which would emit a value change before any of its @Published properties changed. Below is the simplified version of what I've done. This works. But not well. The performance never exceeds 53 fps and so can't be used for production sims or games. If you find something amiss, which I'm sure you will, please post it here. import SwiftUI import SceneKit extension SCNScene: ObservableObject { } struct SwiftUISceneKitUsingStateObjectVarsContentView: View { 		@State private var sunlightSwitch	 = true 		@State private var magnify					= CGFloat(1.0) 		@StateObject var aircraftScene			= SCNScene(named: "art.scnassets/ship.scn")! 		var body: some View { 				ZStack { 						Color.black.edgesIgnoringSafeArea(.all) 						SceneView ( 								scene: aircraftScene, 								pointOfView: aircraftScene.rootNode.childNode(withName: "distantCameraNode", recursively: true) 						) 						.background(Color.black) 						.gesture(MagnificationGesture() 												.onChanged{ (value) in 														print("magnify = \(self.magnify)") 														self.magnify = value 														let camera = self.aircraftScene.rootNode.childNode(withName: "distantCameraNode", recursively: true)?.camera 														camera!.fieldOfView /= magnify 												} 												.onEnded{ _ in 														print("Ended pinch\n\n") 												} 						) 						VStack() { 								Text("Hello, SceneKit!").multilineTextAlignment(.leading).padding() 										.foregroundColor(Color.gray) 										.font(.largeTitle) 								Text("Pinch to zoom.") 										.foregroundColor(Color.gray) 										.font(.title) 								Text("Magnification: \(magnify, specifier: "%.2f")") 										.foregroundColor(Color.gray) 										.font(.title3) 										.padding() 								Text("FOV: \((self.aircraftScene.rootNode.childNode(withName: "distantCameraNode", recursively: true)?.camera!.fieldOfView)!, specifier: "%.2f")") 										.foregroundColor(Color.gray) 										.font(.title3) 								Spacer(minLength: 300) 								Button( action: { 										withAnimation{ 												self.sunlightSwitch.toggle() 										} 										let sunlight = self.aircraftScene.rootNode.childNode(withName: "sunlightNode", recursively: true)?.light 										if self.sunlightSwitch == true { 												sunlight!.intensity = 2000.0 										} else { 												sunlight!.intensity = 0.0 										} 								}) { 										Image(systemName: sunlightSwitch ? "lightbulb.fill" : "lightbulb") 												.imageScale(.large) 												.accessibility(label: Text("Light Switch")) 												.padding() 								} 						} 				} 				.statusBar(hidden: true) 		} }
Aug ’20
Reply to Cannot save .scn file changes in Xcode
Xcode 12b3 fixes the problem of not being able to save changes in Xcode 12. Thank you everyone in Apple's Graphics and Games Engineer team! Just one teeny favor from the Graphics and Games Engineer; sometime could someone post a best-practices on moving cameras and other Scene changes? Just worried that what I'm doing to get the desirable outcome may not be the best way. Thanks.
Jul ’20