I've worked out every issue except as the title suggests.
My pertinent code:
import SwiftUI
import SceneKit
struct ContentView: View {
var scene : SCNScene = SCNScene = { () -> SCNScene in // DO NOT REPLACE OR MODIFY THE FIRST AND LAST LINES OF THIS VAR DECLARATION, e.g., "var scene:SCNScene{ ... }" else initScene(newScene) FAILS to create children!
let newScene = SCNScene()
initScene(newScene) // adds ChildNodes named: "precession" & "nuclearSpin"
let newCamera = SCNNode()
newCamera.position = SCNVector3(x: 0, y: 0 ,z: 40)
newCamera.name = "cameraNode"
newCamera.camera = SCNCamera()
newScene.rootNode.addChildNode(newCamera)
return newScene
}()
@EnvironmentObject var structures:Structures
@State private var Ncv = Int()
@State private var indexMoment
- cv = Int()
var body: some View {
ZStack{
21. scene: scene,
22. pointOfView: scene.rootNode.childNode(withName: "cameraNode", recursively: false),
23. options: [.allowsCameraControl, .autoenablesDefaultLighting, .temporalAntialiasingEnabled]
24. ).colorInvert()
25. VStack(alignment: .trailing){
26. Group{
27. HStack{
28. VStack{ // ... and so on
29.
I have verified the existence of all nodes created for the scene, i.e., the objects to be seen, using these useful functions:
func printChildNodeHierarchy(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode ) } ) } // SUPER handy
func printChildNodeTransform(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.simdTransform,"\t",anyNode.scale ) } ) }
func printChildNodeAction (node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.hasActions,"\t",anyNode.actionKeys ) } ) }
What I've tried:
Since I run in DarkMode theme I have cycled through the combinations of Dark/Light and with/without line 24's .colorInvert() and swapping ZStack with HStack.
Some combo's do wash-out, but still no objects.
I zero'd out the fog thinking it might be too foggy. Not.
I've created a scene.scn file as a resource, applied the above attributes to it, reference it with scene = SCNScene(named: scene.scn"), but get the same non-result.
Idk if some checkbox is errant in the build/target etc. area. Wouldn't know if it was. I'm not a professional programmer.
Any thoughts are appreciated. I've been stuck for days.
oh yeah: as of this posting I am up to date on all Apple software, running 2018 MacMini/Intel/SSD
First, I moved all scene initializing code into ContentView{},i.e., all node creation AND then included token nodes having drawn content (something to see).
Secondly, it seems .temporalAntialiasingEnabled was/is incompatible with the simulated device of choice, so I removed it.
Hope this helps.