scenekit - zoom in/out to selected node of scene

I have a scene in which a human body is displayed. I want to zoom in to a specific body part when a user taps on it.

I changed the position of the camera to the position of Node but it points not exactly on it.

Also I need to keep the selected part in center of the screen when zoom in.

How can I accomplish zoom in / out?

1 answer

  • answered 2018-04-17 05:59 Vollan

    What you want to do is set a tapGestureRecognizer on each child node and when selecting them you want to call node.scale

    @objc func nodeSelected(_ node: SCNNode) {
         node.scale = SCNVector3Make(node.worldPosition.x, node.worldPosition.y, node.worldPosition.z/2)
    }