Posts

Post marked as solved
5 Replies
So is the suggestion to initialize one CloudKit container as punlic and initialize another CloudKit container as private and then manage the data‘s destination accordingly? I mean, I guess this sounds ok. But is it a good approach? What might be some of the pitfalls?
Post not yet marked as solved
79 Replies
Same battery problem. After watchOS 7.3 upgrade, battery life on my AW 6 GPS is less than a day.
Post not yet marked as solved
26 Replies
I’ll throw-in my 2¢ worth; editing xcdatamodeld was fine until Xcode 12.2b2 and Big Sur latest beta.
Post not yet marked as solved
15 Replies
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?
Post not yet marked as solved
4 Replies
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) 		} }
Post not yet marked as solved
1 Replies
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) 		} }
Post not yet marked as solved
4 Replies
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) 		} }
Post not yet marked as solved
5 Replies
Replied In @StateObject
How might one extend an existing reference type, say SCNScene, to conform to ObservableObject?
Post not yet marked as solved
23 Replies
I feel your pain. I have been unable to get the DTK and my LG 5K UltraFine (27MD5KL) to work together. Talk about Black Screen of Death.
Post not yet marked as solved
4 Replies
Bug report filed: https://feedbackassistant.apple.com/feedback/8229356
Post not yet marked as solved
4 Replies
I just want to add that running the above code on an iPhone 11 (iOS 14b3) results in a very bad user-experience with a frame rate of 2 fps. So, either I'm doing something horribly wrong, which is likely, or else SceneView may not be ready for prime-time, which would be sad.
Post not yet marked as solved
3 Replies
Sorry about that. The period somehow was included in the link. The link is https://developer.apple.com/forums/thread/650255 The good news is that this issue has been fixed in Xcode12b3.
Post marked as solved
7 Replies
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.
Post marked as solved
3 Replies
This is a known issue with the Xcode 12 betas and one that the Apple Graphics and Games team has said will be fixed in an upcoming Xcode 12 beta. Unfortunately, it didn't make it into Xcode 12b2. The other thread on which this is being discussed is here: https://developer.apple.com/forums/thread/650255. Here's hoping the fix will make it into Xcode 12b3.
Post marked as solved
7 Replies
For Xcode 12b2 (12A6163b), this issue still exists. Changing the scn file will result in a modal, "The document "filename.scn" could not be autosaved." And this means that the only way to exit Xcode 12 is to force-quit.