0

I have looked at this post and rickster's answer and lorenzo's sample code

Lorenzo's code works well. I am trying to extend it and add a conventional pan where you can move the scene left, right, up and down.

Here is what I have tried:

-(void) handlePan2F :(UIPanGestureRecognizer*)recognizer {

CGPoint translation = [recognizer translationInView:recognizer.view];

CGFloat xVal =  translation.x * 0.025 ; // apply some damping
CGFloat yVal =  translation.y * 0.025 ;  

if (recognizer.state == UIGestureRecognizerStateChanged) {
    self.cameraOrbit.position  = SCNVector3Make(-xVal, yVal ,0.0);   // what should the value be for z?
   }
}

The issues I am running into are:

  1. The pan works kind of - but not well.

  2. If I add a SCNLookAtConstraint to point an area in the scene then the pan2F gesture rotates the scene. Why is that?

  3. The behavior I am trying to implement is to just to pan left/right/up down over the scene without any scene rotation. How to fix this code?

I am willing to give up SCNLookAtConstraint as long as I can zoom to a specific area within the scene.

  • The code you linked to is great for rotating and not a good starting point for a simple panning situation. Ditch the camorbit node and instead update the position of the scnview.pointOfView.position. Also use setTranslation on the gesture and set it to cgpointzero to prevent the translation from accumulating. A lookat constraint indeed causes the camera to rotate towards whatever you have it look at. – Xartec Nov 12 '17 at 00:58
  • Good suggestion. That worked out for me. – user7860251 Nov 12 '17 at 23:02

0 Answers0