I have the following code in viewDidLoad
let scene = SCNScene(named: "funModel")!
myNode = scene.rootNode.childNode(withName: "blah")!
myNode.position = SCNVector3Make(0, 0, -1)
sceneView.scene = scene
let pan = UIPanGestureRecognizer(target: self, action: #selector(panGesture(recognizer:)))
view.addGestureRecognizer(pan)
and then the following code in panGesture
from another SO answer, but it's not working. The node just goes to 0, 0, 0 it seems like. I just want to be able to drag the node around the screen.
let projectedOrigin = sceneView.projectPoint(SCNVector3Zero)
let vp = recognizer.location(in: sceneView)
let vpWithZ = SCNVector3(x: Float(vp.x), y: Float(vp.y), z: Float(projectedOrigin.z))
let worldPoint = sceneView.unprojectPoint(vpWithZ)
myNode.position = worldPoint