SCNNode not showing in snapshot

I am attempting to take a screenshot of a SCNScene using SCNView's snapshot() function. However, when I take a snapshot the image turns out to be just the background color and does not contain any nodes.

      let tempScene = try SCNScene(url: SceneUrl!)
      let tempView = SCNView()
      tempView.scene = tempScene
      
      tempView.frame = CGRect(x: 0, y: 0, width: 1000, height: 1200)
      
      let cameraNode = SCNNode()
      cameraNode.camera = SCNCamera()
      cameraNode.name = "Camera"
      tempScene.rootNode.addChildNode(cameraNode)
      
      // place the camera
      cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
      
      let list = tempView.scene!.rootNode.childNodes(passingTest: { (node, stop) -> Bool in
        if node.childNodes.count == 0 {
            return true;
        } else {
            return false;
        }
      })
      
      cameraNode.constraints = [SCNLookAtConstraint(target: list.first)]
     
      
      //add a light to the scene
      let lightNode1 = SCNNode()
      lightNode1.light = SCNLight()
      lightNode1.light!.type = .ambient
      lightNode1.position = SCNVector3(x: 0, y: 30, z: 30)
      tempScene.rootNode.addChildNode(lightNode1)
     
      tempView.backgroundColor = UIColor.darkGray
      
      SCNTransaction.flush()
      
      let image = tempView.snapshot()
code-block
SCNNode not showing in snapshot
 
 
Q