I have a scene where, after some event, I want the user to be able to interact with the camera but just for the pinch/zoom gesture
. I would like to enable the allowsCameraControl
SCNView property for this purpose.
When you enable allowsCameraControl
all gestures are enabled, some of which aren't very intuitive to use nor easy to control. I also need to have the swipe gesture available for something different than controlling the camera.
Is there a way to constrain the camera control to just the pinch/zoom gesture
? In the documentation I have found a SCNCameraController
class, but its description is extremely sparse, and haven't figured out how to use it.
allowsCameraControl is kinda cool for generic stuff but agreed, sparse docs. Probably best to implement your own camera control. It's not too bad - add a cameraEye and cameraFocus nodes, then set with an SCNLookAtConstraint. Something like this:
func setView()
{
cameraEye.constraints = []
cameraEye.position = SCNVector3(x: 0, y: 10, z: 12)
cameraFocus.position = SCNVector3Make(0, 0, 0)
let vConstraint = SCNLookAtConstraint(target: cameraFocus)
vConstraint.isGimbalLockEnabled = true
cameraEye.constraints = [vConstraint]
}
From there - zooming in/out is a matter of just changing the cameraFocus.position, depending on how complex you want it. Hope that helps!