SwiftUI SceneKit populated but not displayed

I am porting a functioning Swift App to SwiftUI with the ambitious intention of Multiple platform coding, so the project was created as such.
I've worked out every issue except as the title suggests.
My pertinent code:

import SwiftUI
import SceneKit
  1. struct ContentView: View {

  2. 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!

  3. let newScene = SCNScene()

  4. initScene(newScene)                            //  adds ChildNodes named: "precession" & "nuclearSpin"

  5. let newCamera = SCNNode()

  6. newCamera.position = SCNVector3(x: 0, y: 0 ,z: 40)

  7. newCamera.name = "cameraNode"

  8. newCamera.camera = SCNCamera()

  9. newScene.rootNode.addChildNode(newCamera)

10. newScene.fogDensityExponent = 0.0
  1. return newScene

  2. }()

  3. @EnvironmentObject var structures:Structures

  4. @State private var Ncv = Int()

  5. @State private var indexMoment

  6. cv = Int()
  7. var body: some View {

  8. ZStack{

20. SceneView(
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:
  1. func printChildNodeHierarchy(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode ) } ) }  //  SUPER handy

  2. func printChildNodeTransform(node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.simdTransform,"\t",anyNode.scale ) } ) }

  3. func printChildNodeAction   (node: SCNNode) { node.enumerateChildNodes( { (anyNode,false) -> Void in return print( anyNode.name!,"\t", anyNode.hasActions,"\t",anyNode.actionKeys ) } ) }

...which print in the debugging area. I have verified the materials assignments to the elements of those nodes. So, everything is in place as in the functioning Swift/macOS App but I just don't see the objects.
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
Answered by G.U.T.explorer in 665411022
Not sure why it is working now, but here is what I did:
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.
OK, discovered the problem which lead to another.
When porting my Delegate file from Swift to SwiftUI I had declared in a global variable file:
var proton = SCNGeometry() ,which the var is. It is user selectable between:
class Particle:SCNGeometry, SCNPhysicsContactDelegate {} and
class WireFrameParticle:SCNGeometry, SCNPhysicsContactDelegate {}

Experimenting, I found if I declare var proton = Particle() in the global var file, I get my desired SCNScene as SceneView.
Likewise if var = WireFrameParticle(), I get the desired SCNScene as SceneView.

When the user selects the "other" class from an options.toolbar where the var proton is reassigned, the program *****, e.g., "Cannot assign WireFrameParticle to Particle". So, I modify my global var file to:
var proton:SCNGeometry = Particle()
The program no longer ***** but neither do I have the desired SCNScene in SceneView, again.

There must be a way to declare/reassign the var proton, and have my scene too.
Accepted Answer
Not sure why it is working now, but here is what I did:
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.
SwiftUI SceneKit populated but not displayed
 
 
Q