0 Replies
      Latest reply on Mar 12, 2019 2:06 AM by vasu090
      vasu090 Level 1 Level 1 (0 points)

        Hello,

         

        I was trying to make an app which first detects a plane and then puts a SCNPlane over it. There are a few nodes as a child node to the plane and I want to move them with a long press by the user using the long press gesture recogniser. Here's the code:

         

         

        @available(iOS 12.0, *)
            @objc func move( _ recognizer: UILongPressGestureRecognizer){
        
                guard let recognizerView = recognizer.view as? ARSCNView else { return }
        
                let touch = recognizer.location(in: recognizerView)
        
                let hitTestResult = self.sceneView.hitTest(touch)
                guard let modelNodeHit = hitTestResult.first?.node else { return }
        
               if !(modelNodeHit.categoryBitMask == BodyType.dynamicObjects.rawValue) { return }
        
               
                let hitResult = self.sceneView.hitTest(touch, types: .existingPlane)
                if !hitResult.isEmpty {
                    guard let hitResult = hitResult.last else { return }
                    modelNodeHit.position = SCNVector3Make(hitResult.worldTransform.columns.3.x, hitResult.worldTransform.columns.3.y, hitResult.worldTransform.columns.3.z)
                }
               
            }

         

        The plane is rotated 90deg in order to make it a horizontal plane. As told above, when I long press any child node, it just goes up and some right or left and not really moves. However, this somewhat works on the parent plane node. What could be the reason? Please help..

         

        Thanks.