0

I am working on an AR based application using ARKit. I am using https://developer.apple.com/documentation/arkit/handling_3d_interaction_and_ui_controls_in_augmented_reality as base for this. Using this i am able to move or rotate the whole Virtual Object.

Now there are lot of child nodes in the Virtual Object. I want to drag/move any child node with user finger irrespective of the axis. The child SCNode may be in ground or floating. I want to move the object wherever the user finger goes irrespective of the axis or irrespective of the euler angles of the child node. Is this even possible?

I followed the below links but it is just moving along a particular axis.

ARKit - Drag a node along a specific axis (not on a plane)

Dragging SCNNode in ARKit Using SceneKit

I tried using the below code and it is not at all helping,

    let tapPoint: CGPoint = gesture.location(in: sceneView)
    let result = sceneView.hitTest(tapPoint, options: nil)
    if result.count == 0 {
        return
    }
    let scnHitResult: SCNHitTestResult? = result.first
    movedObject = scnHitResult?.node //.parent?.parent

    let hitResults = self.sceneView.hitTest(tapPoint, types: .existingPlane)
    if !hitResults.isEmpty{
        guard let hitResult = hitResults.last else { return }
        movedObject?.position = SCNVector3Make(hitResult.worldTransform.columns.3.x, hitResult.worldTransform.columns.3.y, hitResult.worldTransform.columns.3.z)
    }
Vidhya Sri
  • 1,773
  • 1
  • 17
  • 46
  • When you say child node of virtual object what exactly do you mean? – BlackMirrorz May 26 '18 at 07:46
  • For ex. I have a wardrobe(with n number of clothes as child nodes) 3D virtual object placed in AR view. I want to move each and every dress or t shirt separately, rotate it and view it. – Vidhya Sri May 28 '18 at 05:02

0 Answers0