SCNSceneRendererDelegate example in SwiftUI?

I've got a Game @StateObject in my app that's passed to my main ContentView. I'm trying to figure out how best create a SCNSceneRendererDelegate instance that has a reference to the Game state, and then pass that to the SceneView inside my ContentView.

I'm trying to do it like this, but obviously this doesn't work because self isn't available at init time:

struct
ContentView : View
{
	let	game				:	Game
	
	var	scene										=	SCNScene(named: "art.scnassets/ship.scn")
	var cameraNode			: SCNNode?					{ self.scene?.rootNode.childNode(withName: "camera", recursively: false) }
	var rendererDelegate							=	RendererDelegate(game: self.game)  //  Cannot find 'self' in scope
										
	var
	body: some View
	{
		SceneView(scene: self.scene,
					pointOfView: self.cameraNode,
					delegate: self.rendererDelegate)
	}
}

The intent is that in my renderer delegate, I'll update my game's simulation state. Because my game state is an ObservableObject, everything else (I have a bunch of SwiftUI) should update.

This is (for me) a common initialisation issue in Swift. You aren't able to use properties to calculate other properties until the type is fully initialised – which it can't be as you're still allocating values.

AFAIK you have to either make those variables lazy (which then makes the struct mutate when you access those variables, which can be a pain) or you set them in an explicit initialiser.

SCNSceneRendererDelegate example in SwiftUI?
 
 
Q