SceneView new api in Big Sur: how to use it

I have discover that using SceneKit within Swift UI is now easier with the introduction of SceneView.

However, I would like to be able to click on the SceneView to add Sphere for example.
I would also like to use the hitTest, projectPoint and unprojectPoint define in SCNSceneRenderer.

So my questions are:
1) How to get the position of a click since onTap gesture modifier does not provide any information about the location of the click.
2) How to use the hitTest, projectPoint and unprojectPoint define in SCNSceneRenderer since SceneView, contrary to SCNView, does not comply to SCNSceneRenderer protocol.

Best regards

Vincent LIEGEOIS

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".


Code Block swift
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)
}
}


SceneView new api in Big Sur: how to use it
 
 
Q