ios - SceneKit: allow panning along X-axis and Y-axis for camera node -
the goal simulate camera in scenekit , let users pan camera's point of view panning screen.
the code below simulates camera panning in horizontal direction, how account simultaneous panning in vertical direction?
would concat rotation, altering x-axis , based on translation.y (to amount user panned vertically)? or there better way?
func dopan(sender: uipangesturerecognizer) { // horizonal pan distance & convert radians let translation = sender.translationinview(sender.view!) var xradians = glkmathdegreestoradians(float(translation.x)) // rotate camera xradians = (xradians / 20) + currentangle cameranode.transform = scnmatrix4makerotation(xradians, 0, 1, 0) // update preview block setpreviewblock(cameranode.position) // save value next rotation if (sender.state == uigesturerecognizerstate.ended) { currentangle = xradians } }
you can multiply rotation matrices new transform.
another approach use camera node's eulerangles
property. transform
, eulerangles
, , orientation
contgrol node's rotation, use different parameterizations.
see rotate scncamera node looking @ object around imaginary sphere thorough answer/explanation of camera rotations.
another approach rotate scene instead of moving camera. take @ scnaction
, rotateby...
, rotateto...
functions.
Comments
Post a Comment