Dragging SCNNode in ARKit Using SceneKit

前端 未结 3 637
没有蜡笔的小新
没有蜡笔的小新 2020-12-08 11:45

I have a simple SCNNode in ARKit and I am trying to drag it wherever I moved my finger on the phone. Here is my code.

 @objc func pan(recognizer :UIGestureR         


        
3条回答
  •  悲&欢浪女
    2020-12-08 12:17

    Had the same issue. Using a SCNTransaction did the trick for me.

    @objc private func handlePan(_ gesture: UIPanGestureRecognizer) {
        [...]
    
        SCNTransaction.begin()
        SCNTransaction.animationDuration = 0
        imagePlane.position.x = hitTestResult.localCoordinates.x
        imagePlane.position.y = hitTestResult.localCoordinates.y
        SCNTransaction.commit()
    }
    

提交回复
热议问题