Seems like you’re confused about utilization of hitTest in SCNView. Firstly, be aware that hitTest(_:choices:) will seek for objects/nodes within the given scene akin to the ray-cast hits from level of contact. This explains why generally your code does not work as a result of the hit check outcomes might be empty in case the objects are usually not discovered.
To make issues work as anticipated, you need to mission the purpose from CGPoint into scene utilizing following code which additionally requires you to offer depth.
func pointToSCNVector3(view: SCNView, depth: Float, level: CGPoint) -> SCNVector3 {
let projectedOrigin = view.projectPoint(SCNVector3Make(0, 0, depth))
let locationWithz = SCNVector3Make(Float(level.x), Float(level.y), projectedOrigin.z)
return view.unprojectPoint(locationWithz)
}
then use the output to set the node place
@objc func handleTapGesture(_ gesture: UITapGestureRecognizer) {
let location = gesture.location(in: scnView)
node.place = pointToSCNVector3(view: scnView, depth: 50, level: location)
}